@navios/commander 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClassType, ClassTypeWithInstance, Container, InjectionToken, NaviosModule } from "@navios/core";
1
+ import { ClassType, ClassTypeWithInstance, Container, InjectionToken, NaviosModule, Registry } from "@navios/core";
2
2
  import { ZodObject } from "zod";
3
3
  export * from "@navios/core";
4
4
 
@@ -199,6 +199,16 @@ interface CommandOptions {
199
199
  * If provided, options will be validated and parsed according to this schema.
200
200
  */
201
201
  optionsSchema?: ZodObject;
202
+ /**
203
+ * Priority level for the command.
204
+ * Higher priority commands will be loaded first.
205
+ */
206
+ priority?: number;
207
+ /**
208
+ * Registry to use for the command.
209
+ * Registry is used to store the command and its options schema.
210
+ */
211
+ registry?: Registry;
202
212
  }
203
213
  /**
204
214
  * Decorator that marks a class as a CLI command.
@@ -232,7 +242,9 @@ interface CommandOptions {
232
242
  */
233
243
  declare function Command({
234
244
  path,
235
- optionsSchema
245
+ optionsSchema,
246
+ priority,
247
+ registry
236
248
  }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
237
249
  //#endregion
238
250
  //#region src/decorators/cli-module.decorator.d.mts
@@ -252,6 +264,16 @@ interface CliModuleOptions {
252
264
  * Imported modules' commands will be available in this module.
253
265
  */
254
266
  imports?: ClassType[] | Set<ClassType>;
267
+ /**
268
+ * Priority level for the module.
269
+ * Higher priority modules will be loaded first.
270
+ */
271
+ priority?: number;
272
+ /**
273
+ * Registry to use for the module.
274
+ * Registry is used to store the module and its commands.
275
+ */
276
+ registry?: Registry;
255
277
  }
256
278
  /**
257
279
  * Decorator that marks a class as a CLI module.
@@ -277,7 +299,9 @@ interface CliModuleOptions {
277
299
  */
278
300
  declare function CliModule({
279
301
  commands,
280
- imports
302
+ imports,
303
+ priority,
304
+ registry
281
305
  }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
282
306
  //#endregion
283
307
  //#region src/interfaces/command-handler.interface.d.mts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["ClassTypeWithInstance","NaviosModule","Container","CommanderApplicationOptions","CommanderApplication","Promise","ClassTypeWithInstance","NaviosModule","CommanderApplicationOptions","CommanderApplication","CommanderFactory","Promise","ClassType","ZodObject","CommandOptions","Command","path","optionsSchema","ClassDecoratorContext","ClassType","CliModuleOptions","Set","CliModule","commands","imports","ClassDecoratorContext","CommandHandler","TOptions","Promise","ClassType","ZodObject","CommandMetadataKey","CommandMetadata","Map","getCommandMetadata","ClassDecoratorContext","extractCommandMetadata","hasCommandMetadata","CommandMetadata","CommanderExecutionContext","ClassType","CliModuleMetadataKey","CliModuleMetadata","Set","Map","getCliModuleMetadata","ClassDecoratorContext","extractCliModuleMetadata","hasCliModuleMetadata","ClassTypeWithInstance","NaviosModule","Container","CommandHandler","CliModuleMetadata","CommandMetadata","CommandWithMetadata","CliModuleLoaderService","Promise","Map","ZodObject","ParsedCliArgs","Record","CliParserService","Array","InjectionToken","CommanderExecutionContext","CommandExecutionContext"],"sources":["../src/commander.application.d.mts","../src/commander.factory.d.mts","../src/decorators/command.decorator.d.mts","../src/decorators/cli-module.decorator.d.mts","../src/interfaces/command-handler.interface.d.mts","../src/metadata/command.metadata.d.mts","../src/interfaces/commander-execution-context.interface.d.mts","../src/metadata/cli-module.metadata.d.mts","../src/services/module-loader.service.d.mts","../src/services/cli-parser.service.d.mts","../src/tokens/execution-context.token.d.mts"],"sourcesContent":["import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\n/**\n * Configuration options for CommanderApplication.\n *\n * @public\n */\nexport interface CommanderApplicationOptions {\n}\n/**\n * Main application class for managing CLI command execution.\n *\n * This class handles module loading, command registration, and command execution.\n * It provides both programmatic and CLI-based command execution capabilities.\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * ```\n */\nexport declare class CommanderApplication {\n private moduleLoader;\n private cliParser;\n protected container: Container;\n private appModule;\n private options;\n /**\n * Indicates whether the application has been initialized.\n * Set to `true` after `init()` is called successfully.\n */\n isInitialized: boolean;\n /**\n * @internal\n * Sets up the application with the provided module and options.\n * This is called automatically by CommanderFactory.create().\n */\n setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<void>;\n /**\n * Gets the dependency injection container used by this application.\n *\n * @returns The Container instance\n *\n * @example\n * ```typescript\n * const container = app.getContainer()\n * const service = await container.get(MyService)\n * ```\n */\n getContainer(): Container;\n /**\n * Initializes the application by loading all modules and registering commands.\n *\n * This method must be called before executing commands or running the CLI.\n * It traverses the module tree, loads all imported modules, and collects command metadata.\n *\n * @throws {Error} If the app module is not set (setup() was not called)\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init() // Must be called before run() or executeCommand()\n * ```\n */\n init(): Promise<void>;\n /**\n * Executes a command programmatically with the provided options.\n *\n * This method is useful for testing, automation, or programmatic workflows.\n * The options will be validated against the command's Zod schema if one is provided.\n *\n * @param commandPath - The command path (e.g., 'greet', 'user:create')\n * @param options - The command options object (will be validated if schema exists)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If the command is not found\n * @throws {Error} If the command does not implement the execute method\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * await app.executeCommand('greet', {\n * name: 'World',\n * greeting: 'Hi'\n * })\n * ```\n */\n executeCommand(commandPath: string, options?: any): Promise<void>;\n /**\n * Gets all registered commands with their paths and class references.\n *\n * @returns An array of objects containing the command path and class\n *\n * @example\n * ```typescript\n * const commands = app.getAllCommands()\n * commands.forEach(({ path }) => {\n * console.log(`Available: ${path}`)\n * })\n * ```\n */\n getAllCommands(): {\n path: string;\n class: ClassTypeWithInstance<any>;\n }[];\n /**\n * Runs the CLI application by parsing command-line arguments and executing the appropriate command.\n *\n * This is the main entry point for CLI usage. It parses `argv`, validates options,\n * and executes the matching command. Supports help command (`help`, `--help`, `-h`)\n * which displays all available commands.\n *\n * @param argv - Command-line arguments array (defaults to `process.argv`)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If no command is provided\n * @throws {Error} If the command is not found\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * // Parse and execute from process.argv\n * await app.run()\n *\n * // Or provide custom arguments\n * await app.run(['node', 'cli.js', 'greet', '--name', 'World'])\n * ```\n */\n run(argv?: string[]): Promise<void>;\n /**\n * @internal\n * Disposes of resources used by the application.\n */\n dispose(): Promise<void>;\n /**\n * Closes the application and cleans up resources.\n *\n * This should be called when the application is no longer needed to free up resources.\n *\n * @example\n * ```typescript\n * await app.run(process.argv)\n * await app.close()\n * ```\n */\n close(): Promise<void>;\n}\n//# sourceMappingURL=commander.application.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport type { CommanderApplicationOptions } from './commander.application.mjs';\nimport { CommanderApplication } from './commander.application.mjs';\n/**\n * Factory class for creating and configuring CLI applications.\n *\n * @example\n * ```typescript\n * import { CommanderFactory } from '@navios/commander'\n * import { AppModule } from './app.module'\n *\n * async function bootstrap() {\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * await app.close()\n * }\n * ```\n */\nexport declare class CommanderFactory {\n /**\n * Creates a new CommanderApplication instance and configures it with the provided module.\n *\n * @param appModule - The root CLI module class that contains commands and/or imports other modules\n * @param options - Optional configuration options for the application\n * @returns A promise that resolves to a configured CommanderApplication instance\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * ```\n */\n static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<CommanderApplication>;\n}\n//# sourceMappingURL=commander.factory.d.mts.map","import type { ClassType } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: ZodObject;\n}\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command({ path, optionsSchema }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=command.decorator.d.mts.map","import type { ClassType } from '@navios/core';\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>;\n /**\n * Array or Set of other CLI modules to import.\n * Imported modules' commands will be available in this module.\n */\n imports?: ClassType[] | Set<ClassType>;\n}\n/**\n * Decorator that marks a class as a CLI module.\n *\n * Modules organize commands and can import other modules to compose larger CLI applications.\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule({ commands, imports }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=cli-module.decorator.d.mts.map","/**\n * Interface that all command classes must implement.\n *\n * Commands decorated with `@Command` must implement this interface.\n * The `execute` method is called when the command is invoked.\n *\n * @template TOptions - The type of options that the command accepts\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string()\n * })\n *\n * type Options = z.infer<typeof optionsSchema>\n *\n * @Command({ path: 'greet', optionsSchema })\n * export class GreetCommand implements CommandHandler<Options> {\n * async execute(options: Options) {\n * console.log(`Hello, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport interface CommandHandler<TOptions = any> {\n /**\n * Executes the command with the provided options.\n *\n * @param options - The validated command options (validated against the command's schema if provided)\n * @returns A promise or void\n */\n execute(options: TOptions): void | Promise<void>;\n}\n//# sourceMappingURL=command-handler.interface.d.mts.map","import type { ClassType } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * @internal\n * Symbol key used to store command metadata on classes.\n */\nexport declare const CommandMetadataKey: unique symbol;\n/**\n * Metadata associated with a command.\n *\n * @public\n */\nexport interface CommandMetadata {\n /**\n * The command path (e.g., 'greet', 'user:create').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n */\n optionsSchema?: ZodObject;\n /**\n * Map of custom attributes that can be attached to the command.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates command metadata for a class.\n *\n * @internal\n * @param target - The command class\n * @param context - The decorator context\n * @param path - The command path\n * @param optionsSchema - Optional Zod schema\n * @returns The command metadata\n */\nexport declare function getCommandMetadata(target: ClassType, context: ClassDecoratorContext, path: string, optionsSchema?: ZodObject): CommandMetadata;\n/**\n * Extracts command metadata from a class.\n *\n * @param target - The command class\n * @returns The command metadata\n * @throws {Error} If the class is not decorated with @Command\n *\n * @example\n * ```typescript\n * const metadata = extractCommandMetadata(GreetCommand)\n * console.log(metadata.path) // 'greet'\n * ```\n */\nexport declare function extractCommandMetadata(target: ClassType): CommandMetadata;\n/**\n * Checks if a class has command metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @Command, `false` otherwise\n */\nexport declare function hasCommandMetadata(target: ClassType): boolean;\n//# sourceMappingURL=command.metadata.d.mts.map","import type { CommandMetadata } from '../metadata/command.metadata.mjs';\n/**\n * Execution context for a command execution.\n *\n * Provides access to command metadata, path, and validated options during command execution.\n * This context is automatically injected and available via the `CommandExecutionContext` token.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class CommandLogger {\n * private ctx = inject(CommandExecutionContext)\n *\n * log() {\n * console.log('Command:', this.ctx.getCommandPath())\n * console.log('Options:', this.ctx.getOptions())\n * }\n * }\n * ```\n */\nexport declare class CommanderExecutionContext {\n private readonly command;\n private readonly commandPath;\n private readonly options;\n /**\n * @internal\n * Creates a new execution context.\n */\n constructor(command: CommandMetadata, commandPath: string, options: any);\n /**\n * Gets the command metadata.\n *\n * @returns The command metadata including path and options schema\n */\n getCommand(): CommandMetadata;\n /**\n * Gets the command path that was invoked.\n *\n * @returns The command path (e.g., 'greet', 'user:create')\n */\n getCommandPath(): string;\n /**\n * Gets the validated command options.\n *\n * Options are validated against the command's Zod schema if one was provided.\n *\n * @returns The validated options object\n */\n getOptions(): any;\n}\n//# sourceMappingURL=commander-execution-context.interface.d.mts.map","import type { ClassType } from '@navios/core';\n/**\n * @internal\n * Symbol key used to store CLI module metadata on classes.\n */\nexport declare const CliModuleMetadataKey: unique symbol;\n/**\n * Metadata associated with a CLI module.\n *\n * @public\n */\nexport interface CliModuleMetadata {\n /**\n * Set of command classes registered in this module.\n */\n commands: Set<ClassType>;\n /**\n * Set of other modules imported by this module.\n */\n imports: Set<ClassType>;\n /**\n * Map of custom attributes that can be attached to the module.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates CLI module metadata for a class.\n *\n * @internal\n * @param target - The module class\n * @param context - The decorator context\n * @returns The module metadata\n */\nexport declare function getCliModuleMetadata(target: ClassType, context: ClassDecoratorContext): CliModuleMetadata;\n/**\n * Extracts CLI module metadata from a class.\n *\n * @param target - The module class\n * @returns The module metadata\n * @throws {Error} If the class is not decorated with @CliModule\n *\n * @example\n * ```typescript\n * const metadata = extractCliModuleMetadata(AppModule)\n * console.log(metadata.commands.size) // Number of commands\n * ```\n */\nexport declare function extractCliModuleMetadata(target: ClassType): CliModuleMetadata;\n/**\n * Checks if a class has CLI module metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @CliModule, `false` otherwise\n */\nexport declare function hasCliModuleMetadata(target: ClassType): boolean;\n//# sourceMappingURL=cli-module.metadata.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\nimport type { CommandHandler } from '../interfaces/index.mjs';\nimport type { CliModuleMetadata, CommandMetadata } from '../metadata/index.mjs';\n/**\n * Command class with its associated metadata.\n *\n * @public\n */\nexport interface CommandWithMetadata {\n /**\n * The command class constructor.\n */\n class: ClassTypeWithInstance<CommandHandler>;\n /**\n * The command metadata including path and options schema.\n */\n metadata: CommandMetadata;\n}\n/**\n * Service for loading and managing CLI modules and commands.\n *\n * Handles module traversal, command registration, and metadata collection.\n * This service is used internally by CommanderApplication.\n *\n * @public\n */\nexport declare class CliModuleLoaderService {\n protected container: Container;\n private modulesMetadata;\n private loadedModules;\n private commandsMetadata;\n private initialized;\n /**\n * Loads all modules starting from the root app module.\n *\n * Traverses the module tree, loads imported modules, and collects command metadata.\n *\n * @param appModule - The root CLI module\n */\n loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;\n private traverseModules;\n private mergeMetadata;\n /**\n * Gets all loaded module metadata.\n *\n * @returns Map of module names to their metadata\n */\n getAllModules(): Map<string, CliModuleMetadata>;\n /**\n * Gets all command classes indexed by command class name.\n *\n * @returns Map of command class names to command classes\n */\n getAllCommands(): Map<string, ClassTypeWithInstance<any>>;\n /**\n * Get all commands with their metadata, indexed by command path.\n * This is populated during loadModules, so path information is available\n * before parsing CLI argv.\n */\n getAllCommandsWithMetadata(): Map<string, CommandWithMetadata>;\n /**\n * Get a command by its path, with metadata already extracted.\n * Returns undefined if command is not found.\n */\n getCommandByPath(path: string): CommandWithMetadata | undefined;\n /**\n * Disposes of all loaded modules and commands, clearing internal state.\n */\n dispose(): void;\n}\n//# sourceMappingURL=module-loader.service.d.mts.map","import type { ZodObject } from 'zod';\n/**\n * Result of parsing command-line arguments.\n *\n * @public\n */\nexport interface ParsedCliArgs {\n /**\n * The command path (e.g., 'greet', 'user:create').\n * Multi-word commands are joined with spaces.\n */\n command: string;\n /**\n * Parsed options as key-value pairs.\n * Keys are converted from kebab-case to camelCase.\n */\n options: Record<string, any>;\n /**\n * Positional arguments that don't match any option flags.\n */\n positionals: string[];\n}\n/**\n * Service for parsing command-line arguments.\n *\n * Handles parsing of various CLI argument formats including:\n * - Long options: `--key value` or `--key=value`\n * - Short options: `-k value` or `-abc` (multiple flags)\n * - Boolean flags\n * - Array options\n * - Positional arguments\n *\n * @public\n */\nexport declare class CliParserService {\n /**\n * Parses command-line arguments from process.argv\n * Commands can be multi-word (e.g., 'db migrate', 'cache clear')\n * Expected format: node script.js command [subcommand...] --flag value --boolean-flag positional1 positional2\n *\n * @param argv - Array of command-line arguments (typically process.argv)\n * @param optionsSchema - Optional Zod schema to determine boolean flags and option types\n * @returns Parsed command (space-separated if multi-word), options, and positional arguments\n */\n parse(argv: string[], optionsSchema?: ZodObject): ParsedCliArgs;\n /**\n * Converts kebab-case to camelCase\n */\n private camelCase;\n /**\n * Attempts to parse string values into appropriate types\n */\n private parseValue;\n /**\n * Extracts boolean field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractBooleanFields;\n /**\n * Extracts array field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractArrayFields;\n /**\n * Checks if a Zod schema represents a boolean type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaBoolean;\n /**\n * Checks if a Zod schema represents an array type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaArray;\n /**\n * Formats help text listing all available commands.\n *\n * @param commands - Array of command objects with path and class\n * @returns Formatted string listing all commands\n */\n formatCommandList(commands: Array<{\n path: string;\n class: any;\n }>): string;\n}\n//# sourceMappingURL=cli-parser.service.d.mts.map","import { InjectionToken } from '@navios/core';\nimport type { CommanderExecutionContext } from '../interfaces/index.mjs';\n/**\n * Injection token for accessing the current command execution context.\n *\n * Use this token with `inject()` to access the `CommanderExecutionContext` in services\n * that need information about the currently executing command.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class MyService {\n * private ctx = inject(CommandExecutionContext)\n *\n * doSomething() {\n * const commandPath = this.ctx.getCommandPath()\n * const options = this.ctx.getOptions()\n * // Use context information...\n * }\n * }\n * ```\n */\nexport declare const CommandExecutionContext: InjectionToken<CommanderExecutionContext, undefined, false>;\n//# sourceMappingURL=execution-context.token.d.mts.map"],"mappings":";;;;;;;;;;AAOA;AAeqBI,UAfJD,2BAAAA,CAewB;;;;;;;;;;;;;;cAApBC,oBAAAA;;ECHAM,QAAAA,SAAAA;EAc8BH,UAAAA,SAAAA,EDR1BL,SCQ0BK;EAAtBD,QAAAA,SAAAA;EAA+CE,QAAAA,OAAAA;EAAsCC;;;;;;AC1BlH;AA0CA;;;EAAyDK,KAAAA,CAAAA,SAAAA,EFXpCd,qBEWoCc,CFXdb,YEWca,CAAAA,EAAAA,OAAAA,CAAAA,EFXWX,2BEWXW,CAAAA,EFXyCT,OEWzCS,CAAAA,IAAAA,CAAAA;EAA0BF;;;;;;;AC3CnF;;;;EAUcO,YAAAA,CAAAA,CAAAA,EHkCMjB,SGlCNiB;EAAkBA;;;AAwBhC;;;;;;;;;;;ECbiBO,IAAAA,CAAAA,CA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RLyD,cTQKzD,CSRU0D,yBTQV1D,EAAAA,SAAAA,EAAAA,KAAAA,CAAAA"}
1
+ {"version":3,"file":"index.d.cts","names":["ClassTypeWithInstance","NaviosModule","Container","CommanderApplicationOptions","CommanderApplication","Promise","ClassTypeWithInstance","NaviosModule","CommanderApplicationOptions","CommanderApplication","CommanderFactory","Promise","ClassType","Registry","ZodObject","CommandOptions","Command","path","optionsSchema","priority","registry","ClassDecoratorContext","ClassType","Registry","CliModuleOptions","Set","CliModule","commands","imports","priority","registry","ClassDecoratorContext","CommandHandler","TOptions","Promise","ClassType","ZodObject","CommandMetadataKey","CommandMetadata","Map","getCommandMetadata","ClassDecoratorContext","extractCommandMetadata","hasCommandMetadata","CommandMetadata","CommanderExecutionContext","ClassType","CliModuleMetadataKey","CliModuleMetadata","Set","Map","getCliModuleMetadata","ClassDecoratorContext","extractCliModuleMetadata","hasCliModuleMetadata","ClassTypeWithInstance","NaviosModule","Container","CommandHandler","CliModuleMetadata","CommandMetadata","CommandWithMetadata","CliModuleLoaderService","Promise","Map","ZodObject","ParsedCliArgs","Record","CliParserService","Array","InjectionToken","CommanderExecutionContext","CommandExecutionContext"],"sources":["../src/commander.application.d.mts","../src/commander.factory.d.mts","../src/decorators/command.decorator.d.mts","../src/decorators/cli-module.decorator.d.mts","../src/interfaces/command-handler.interface.d.mts","../src/metadata/command.metadata.d.mts","../src/interfaces/commander-execution-context.interface.d.mts","../src/metadata/cli-module.metadata.d.mts","../src/services/module-loader.service.d.mts","../src/services/cli-parser.service.d.mts","../src/tokens/execution-context.token.d.mts"],"sourcesContent":["import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\n/**\n * Configuration options for CommanderApplication.\n *\n * @public\n */\nexport interface CommanderApplicationOptions {\n}\n/**\n * Main application class for managing CLI command execution.\n *\n * This class handles module loading, command registration, and command execution.\n * It provides both programmatic and CLI-based command execution capabilities.\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * ```\n */\nexport declare class CommanderApplication {\n private moduleLoader;\n private cliParser;\n protected container: Container;\n private appModule;\n private options;\n /**\n * Indicates whether the application has been initialized.\n * Set to `true` after `init()` is called successfully.\n */\n isInitialized: boolean;\n /**\n * @internal\n * Sets up the application with the provided module and options.\n * This is called automatically by CommanderFactory.create().\n */\n setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<void>;\n /**\n * Gets the dependency injection container used by this application.\n *\n * @returns The Container instance\n *\n * @example\n * ```typescript\n * const container = app.getContainer()\n * const service = await container.get(MyService)\n * ```\n */\n getContainer(): Container;\n /**\n * Initializes the application by loading all modules and registering commands.\n *\n * This method must be called before executing commands or running the CLI.\n * It traverses the module tree, loads all imported modules, and collects command metadata.\n *\n * @throws {Error} If the app module is not set (setup() was not called)\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init() // Must be called before run() or executeCommand()\n * ```\n */\n init(): Promise<void>;\n /**\n * Executes a command programmatically with the provided options.\n *\n * This method is useful for testing, automation, or programmatic workflows.\n * The options will be validated against the command's Zod schema if one is provided.\n *\n * @param commandPath - The command path (e.g., 'greet', 'user:create')\n * @param options - The command options object (will be validated if schema exists)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If the command is not found\n * @throws {Error} If the command does not implement the execute method\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * await app.executeCommand('greet', {\n * name: 'World',\n * greeting: 'Hi'\n * })\n * ```\n */\n executeCommand(commandPath: string, options?: any): Promise<void>;\n /**\n * Gets all registered commands with their paths and class references.\n *\n * @returns An array of objects containing the command path and class\n *\n * @example\n * ```typescript\n * const commands = app.getAllCommands()\n * commands.forEach(({ path }) => {\n * console.log(`Available: ${path}`)\n * })\n * ```\n */\n getAllCommands(): {\n path: string;\n class: ClassTypeWithInstance<any>;\n }[];\n /**\n * Runs the CLI application by parsing command-line arguments and executing the appropriate command.\n *\n * This is the main entry point for CLI usage. It parses `argv`, validates options,\n * and executes the matching command. Supports help command (`help`, `--help`, `-h`)\n * which displays all available commands.\n *\n * @param argv - Command-line arguments array (defaults to `process.argv`)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If no command is provided\n * @throws {Error} If the command is not found\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * // Parse and execute from process.argv\n * await app.run()\n *\n * // Or provide custom arguments\n * await app.run(['node', 'cli.js', 'greet', '--name', 'World'])\n * ```\n */\n run(argv?: string[]): Promise<void>;\n /**\n * @internal\n * Disposes of resources used by the application.\n */\n dispose(): Promise<void>;\n /**\n * Closes the application and cleans up resources.\n *\n * This should be called when the application is no longer needed to free up resources.\n *\n * @example\n * ```typescript\n * await app.run(process.argv)\n * await app.close()\n * ```\n */\n close(): Promise<void>;\n}\n//# sourceMappingURL=commander.application.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport type { CommanderApplicationOptions } from './commander.application.mjs';\nimport { CommanderApplication } from './commander.application.mjs';\n/**\n * Factory class for creating and configuring CLI applications.\n *\n * @example\n * ```typescript\n * import { CommanderFactory } from '@navios/commander'\n * import { AppModule } from './app.module'\n *\n * async function bootstrap() {\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * await app.close()\n * }\n * ```\n */\nexport declare class CommanderFactory {\n /**\n * Creates a new CommanderApplication instance and configures it with the provided module.\n *\n * @param appModule - The root CLI module class that contains commands and/or imports other modules\n * @param options - Optional configuration options for the application\n * @returns A promise that resolves to a configured CommanderApplication instance\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * ```\n */\n static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<CommanderApplication>;\n}\n//# sourceMappingURL=commander.factory.d.mts.map","import type { ClassType, Registry } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: ZodObject;\n /**\n * Priority level for the command.\n * Higher priority commands will be loaded first.\n */\n priority?: number;\n /**\n * Registry to use for the command.\n * Registry is used to store the command and its options schema.\n */\n registry?: Registry;\n}\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command({ path, optionsSchema, priority, registry, }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=command.decorator.d.mts.map","import type { ClassType, Registry } from '@navios/core';\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>;\n /**\n * Array or Set of other CLI modules to import.\n * Imported modules' commands will be available in this module.\n */\n imports?: ClassType[] | Set<ClassType>;\n /**\n * Priority level for the module.\n * Higher priority modules will be loaded first.\n */\n priority?: number;\n /**\n * Registry to use for the module.\n * Registry is used to store the module and its commands.\n */\n registry?: Registry;\n}\n/**\n * Decorator that marks a class as a CLI module.\n *\n * Modules organize commands and can import other modules to compose larger CLI applications.\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule({ commands, imports, priority, registry }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=cli-module.decorator.d.mts.map","/**\n * Interface that all command classes must implement.\n *\n * Commands decorated with `@Command` must implement this interface.\n * The `execute` method is called when the command is invoked.\n *\n * @template TOptions - The type of options that the command accepts\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string()\n * })\n *\n * type Options = z.infer<typeof optionsSchema>\n *\n * @Command({ path: 'greet', optionsSchema })\n * export class GreetCommand implements CommandHandler<Options> {\n * async execute(options: Options) {\n * console.log(`Hello, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport interface CommandHandler<TOptions = any> {\n /**\n * Executes the command with the provided options.\n *\n * @param options - The validated command options (validated against the command's schema if provided)\n * @returns A promise or void\n */\n execute(options: TOptions): void | Promise<void>;\n}\n//# sourceMappingURL=command-handler.interface.d.mts.map","import type { ClassType } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * @internal\n * Symbol key used to store command metadata on classes.\n */\nexport declare const CommandMetadataKey: unique symbol;\n/**\n * Metadata associated with a command.\n *\n * @public\n */\nexport interface CommandMetadata {\n /**\n * The command path (e.g., 'greet', 'user:create').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n */\n optionsSchema?: ZodObject;\n /**\n * Map of custom attributes that can be attached to the command.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates command metadata for a class.\n *\n * @internal\n * @param target - The command class\n * @param context - The decorator context\n * @param path - The command path\n * @param optionsSchema - Optional Zod schema\n * @returns The command metadata\n */\nexport declare function getCommandMetadata(target: ClassType, context: ClassDecoratorContext, path: string, optionsSchema?: ZodObject): CommandMetadata;\n/**\n * Extracts command metadata from a class.\n *\n * @param target - The command class\n * @returns The command metadata\n * @throws {Error} If the class is not decorated with @Command\n *\n * @example\n * ```typescript\n * const metadata = extractCommandMetadata(GreetCommand)\n * console.log(metadata.path) // 'greet'\n * ```\n */\nexport declare function extractCommandMetadata(target: ClassType): CommandMetadata;\n/**\n * Checks if a class has command metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @Command, `false` otherwise\n */\nexport declare function hasCommandMetadata(target: ClassType): boolean;\n//# sourceMappingURL=command.metadata.d.mts.map","import type { CommandMetadata } from '../metadata/command.metadata.mjs';\n/**\n * Execution context for a command execution.\n *\n * Provides access to command metadata, path, and validated options during command execution.\n * This context is automatically injected and available via the `CommandExecutionContext` token.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class CommandLogger {\n * private ctx = inject(CommandExecutionContext)\n *\n * log() {\n * console.log('Command:', this.ctx.getCommandPath())\n * console.log('Options:', this.ctx.getOptions())\n * }\n * }\n * ```\n */\nexport declare class CommanderExecutionContext {\n private readonly command;\n private readonly commandPath;\n private readonly options;\n /**\n * @internal\n * Creates a new execution context.\n */\n constructor(command: CommandMetadata, commandPath: string, options: any);\n /**\n * Gets the command metadata.\n *\n * @returns The command metadata including path and options schema\n */\n getCommand(): CommandMetadata;\n /**\n * Gets the command path that was invoked.\n *\n * @returns The command path (e.g., 'greet', 'user:create')\n */\n getCommandPath(): string;\n /**\n * Gets the validated command options.\n *\n * Options are validated against the command's Zod schema if one was provided.\n *\n * @returns The validated options object\n */\n getOptions(): any;\n}\n//# sourceMappingURL=commander-execution-context.interface.d.mts.map","import type { ClassType } from '@navios/core';\n/**\n * @internal\n * Symbol key used to store CLI module metadata on classes.\n */\nexport declare const CliModuleMetadataKey: unique symbol;\n/**\n * Metadata associated with a CLI module.\n *\n * @public\n */\nexport interface CliModuleMetadata {\n /**\n * Set of command classes registered in this module.\n */\n commands: Set<ClassType>;\n /**\n * Set of other modules imported by this module.\n */\n imports: Set<ClassType>;\n /**\n * Map of custom attributes that can be attached to the module.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates CLI module metadata for a class.\n *\n * @internal\n * @param target - The module class\n * @param context - The decorator context\n * @returns The module metadata\n */\nexport declare function getCliModuleMetadata(target: ClassType, context: ClassDecoratorContext): CliModuleMetadata;\n/**\n * Extracts CLI module metadata from a class.\n *\n * @param target - The module class\n * @returns The module metadata\n * @throws {Error} If the class is not decorated with @CliModule\n *\n * @example\n * ```typescript\n * const metadata = extractCliModuleMetadata(AppModule)\n * console.log(metadata.commands.size) // Number of commands\n * ```\n */\nexport declare function extractCliModuleMetadata(target: ClassType): CliModuleMetadata;\n/**\n * Checks if a class has CLI module metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @CliModule, `false` otherwise\n */\nexport declare function hasCliModuleMetadata(target: ClassType): boolean;\n//# sourceMappingURL=cli-module.metadata.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\nimport type { CommandHandler } from '../interfaces/index.mjs';\nimport type { CliModuleMetadata, CommandMetadata } from '../metadata/index.mjs';\n/**\n * Command class with its associated metadata.\n *\n * @public\n */\nexport interface CommandWithMetadata {\n /**\n * The command class constructor.\n */\n class: ClassTypeWithInstance<CommandHandler>;\n /**\n * The command metadata including path and options schema.\n */\n metadata: CommandMetadata;\n}\n/**\n * Service for loading and managing CLI modules and commands.\n *\n * Handles module traversal, command registration, and metadata collection.\n * This service is used internally by CommanderApplication.\n *\n * @public\n */\nexport declare class CliModuleLoaderService {\n protected container: Container;\n private modulesMetadata;\n private loadedModules;\n private commandsMetadata;\n private initialized;\n /**\n * Loads all modules starting from the root app module.\n *\n * Traverses the module tree, loads imported modules, and collects command metadata.\n *\n * @param appModule - The root CLI module\n */\n loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;\n private traverseModules;\n private mergeMetadata;\n /**\n * Gets all loaded module metadata.\n *\n * @returns Map of module names to their metadata\n */\n getAllModules(): Map<string, CliModuleMetadata>;\n /**\n * Gets all command classes indexed by command class name.\n *\n * @returns Map of command class names to command classes\n */\n getAllCommands(): Map<string, ClassTypeWithInstance<any>>;\n /**\n * Get all commands with their metadata, indexed by command path.\n * This is populated during loadModules, so path information is available\n * before parsing CLI argv.\n */\n getAllCommandsWithMetadata(): Map<string, CommandWithMetadata>;\n /**\n * Get a command by its path, with metadata already extracted.\n * Returns undefined if command is not found.\n */\n getCommandByPath(path: string): CommandWithMetadata | undefined;\n /**\n * Disposes of all loaded modules and commands, clearing internal state.\n */\n dispose(): void;\n}\n//# sourceMappingURL=module-loader.service.d.mts.map","import type { ZodObject } from 'zod';\n/**\n * Result of parsing command-line arguments.\n *\n * @public\n */\nexport interface ParsedCliArgs {\n /**\n * The command path (e.g., 'greet', 'user:create').\n * Multi-word commands are joined with spaces.\n */\n command: string;\n /**\n * Parsed options as key-value pairs.\n * Keys are converted from kebab-case to camelCase.\n */\n options: Record<string, any>;\n /**\n * Positional arguments that don't match any option flags.\n */\n positionals: string[];\n}\n/**\n * Service for parsing command-line arguments.\n *\n * Handles parsing of various CLI argument formats including:\n * - Long options: `--key value` or `--key=value`\n * - Short options: `-k value` or `-abc` (multiple flags)\n * - Boolean flags\n * - Array options\n * - Positional arguments\n *\n * @public\n */\nexport declare class CliParserService {\n /**\n * Parses command-line arguments from process.argv\n * Commands can be multi-word (e.g., 'db migrate', 'cache clear')\n * Expected format: node script.js command [subcommand...] --flag value --boolean-flag positional1 positional2\n *\n * @param argv - Array of command-line arguments (typically process.argv)\n * @param optionsSchema - Optional Zod schema to determine boolean flags and option types\n * @returns Parsed command (space-separated if multi-word), options, and positional arguments\n */\n parse(argv: string[], optionsSchema?: ZodObject): ParsedCliArgs;\n /**\n * Converts kebab-case to camelCase\n */\n private camelCase;\n /**\n * Attempts to parse string values into appropriate types\n */\n private parseValue;\n /**\n * Extracts boolean field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractBooleanFields;\n /**\n * Extracts array field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractArrayFields;\n /**\n * Checks if a Zod schema represents a boolean type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaBoolean;\n /**\n * Checks if a Zod schema represents an array type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaArray;\n /**\n * Formats help text listing all available commands.\n *\n * @param commands - Array of command objects with path and class\n * @returns Formatted string listing all commands\n */\n formatCommandList(commands: Array<{\n path: string;\n class: any;\n }>): string;\n}\n//# sourceMappingURL=cli-parser.service.d.mts.map","import { InjectionToken } from '@navios/core';\nimport type { CommanderExecutionContext } from '../interfaces/index.mjs';\n/**\n * Injection token for accessing the current command execution context.\n *\n * Use this token with `inject()` to access the `CommanderExecutionContext` in services\n * that need information about the currently executing command.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class MyService {\n * private ctx = inject(CommandExecutionContext)\n *\n * doSomething() {\n * const commandPath = this.ctx.getCommandPath()\n * const options = this.ctx.getOptions()\n * // Use context information...\n * }\n * }\n * ```\n */\nexport declare const CommandExecutionContext: InjectionToken<CommanderExecutionContext, undefined, false>;\n//# sourceMappingURL=execution-context.token.d.mts.map"],"mappings":";;;;;;;;;;AAOA;AAeqBI,UAfJD,2BAAAA,CAewB;;;;;;;;;;;;;;cAApBC,oBAAAA;;ECHAM,QAAAA,SAAAA;EAc8BH,UAAAA,SAAAA,EDR1BL,SCQ0BK;EAAtBD,QAAAA,SAAAA;EAA+CE,QAAAA,OAAAA;EAAsCC;;;;;;AC1BlH;AAoDA;;;EAAuDU,KAAAA,CAAAA,SAAAA,EFr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;;;EAiEnFL,OAAAA,ESvFFmE,MTuFEnE,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAwBWK;;;EAiBN,WAAA,EAAA,MAAA,EAAA;;;;AC7HpB;;;;;;;;;;ACZiBU,cO2BIqD,gBAAAA,CPjBDtD;EA0CIE;;;;;;;;;EAAuI,KAAA,CAAA,IAAA,EAAA,MAAA,EAAA,EAAA,aAAA,CAAA,EOfrHiD,SPeqH,CAAA,EOfzGC,aPeyG;;;;ECrD9I1C,QAAAA,SAAAA;EAKFF;;;EAKDA,QAAAA,UAAAA;EAAkBA;;;;EAkCRI,QAAAA,oBAAS;EAAGC;;;;EAA0CH,QAAAA,kBAAAA;EAA4BF;;;;;;;ACvB1G;;;;ACrBA;AAMA;AAwBA;;;EAA4Hc,iBAAAA,CAAAA,QAAAA,EI2C5FiC,KJ3C4FjC,CAAAA;IAAYE,IAAAA,EAAAA,MAAAA;IAAe,KAAA,EAAA,GAAA;EAc/HI,CAAAA,CAAAA,CAAAA,EAAAA,MAAAA;AAOxB;;;;;;;ALlDA;AAeA;;;;;;;;;;;;;;;;;ACHA;AAcmDnC,cSR9BiE,uBTQ8BjE,ESRL+D,cTQK/D,CSRUgE,yBTQVhE,EAAAA,SAAAA,EAAAA,KAAAA,CAAAA"}
package/lib/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClassType, ClassTypeWithInstance, Container, InjectionToken, NaviosModule } from "@navios/core";
1
+ import { ClassType, ClassTypeWithInstance, Container, InjectionToken, NaviosModule, Registry } from "@navios/core";
2
2
  import { ZodObject } from "zod";
3
3
  export * from "@navios/core";
4
4
 
@@ -199,6 +199,16 @@ interface CommandOptions {
199
199
  * If provided, options will be validated and parsed according to this schema.
200
200
  */
201
201
  optionsSchema?: ZodObject;
202
+ /**
203
+ * Priority level for the command.
204
+ * Higher priority commands will be loaded first.
205
+ */
206
+ priority?: number;
207
+ /**
208
+ * Registry to use for the command.
209
+ * Registry is used to store the command and its options schema.
210
+ */
211
+ registry?: Registry;
202
212
  }
203
213
  /**
204
214
  * Decorator that marks a class as a CLI command.
@@ -232,7 +242,9 @@ interface CommandOptions {
232
242
  */
233
243
  declare function Command({
234
244
  path,
235
- optionsSchema
245
+ optionsSchema,
246
+ priority,
247
+ registry
236
248
  }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
237
249
  //#endregion
238
250
  //#region src/decorators/cli-module.decorator.d.mts
@@ -252,6 +264,16 @@ interface CliModuleOptions {
252
264
  * Imported modules' commands will be available in this module.
253
265
  */
254
266
  imports?: ClassType[] | Set<ClassType>;
267
+ /**
268
+ * Priority level for the module.
269
+ * Higher priority modules will be loaded first.
270
+ */
271
+ priority?: number;
272
+ /**
273
+ * Registry to use for the module.
274
+ * Registry is used to store the module and its commands.
275
+ */
276
+ registry?: Registry;
255
277
  }
256
278
  /**
257
279
  * Decorator that marks a class as a CLI module.
@@ -277,7 +299,9 @@ interface CliModuleOptions {
277
299
  */
278
300
  declare function CliModule({
279
301
  commands,
280
- imports
302
+ imports,
303
+ priority,
304
+ registry
281
305
  }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
282
306
  //#endregion
283
307
  //#region src/interfaces/command-handler.interface.d.mts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["ClassTypeWithInstance","NaviosModule","Container","CommanderApplicationOptions","CommanderApplication","Promise","ClassTypeWithInstance","NaviosModule","CommanderApplicationOptions","CommanderApplication","CommanderFactory","Promise","ClassType","ZodObject","CommandOptions","Command","path","optionsSchema","ClassDecoratorContext","ClassType","CliModuleOptions","Set","CliModule","commands","imports","ClassDecoratorContext","CommandHandler","TOptions","Promise","ClassType","ZodObject","CommandMetadataKey","CommandMetadata","Map","getCommandMetadata","ClassDecoratorContext","extractCommandMetadata","hasCommandMetadata","CommandMetadata","CommanderExecutionContext","ClassType","CliModuleMetadataKey","CliModuleMetadata","Set","Map","getCliModuleMetadata","ClassDecoratorContext","extractCliModuleMetadata","hasCliModuleMetadata","ClassTypeWithInstance","NaviosModule","Container","CommandHandler","CliModuleMetadata","CommandMetadata","CommandWithMetadata","CliModuleLoaderService","Promise","Map","ZodObject","ParsedCliArgs","Record","CliParserService","Array","InjectionToken","CommanderExecutionContext","CommandExecutionContext"],"sources":["../src/commander.application.d.mts","../src/commander.factory.d.mts","../src/decorators/command.decorator.d.mts","../src/decorators/cli-module.decorator.d.mts","../src/interfaces/command-handler.interface.d.mts","../src/metadata/command.metadata.d.mts","../src/interfaces/commander-execution-context.interface.d.mts","../src/metadata/cli-module.metadata.d.mts","../src/services/module-loader.service.d.mts","../src/services/cli-parser.service.d.mts","../src/tokens/execution-context.token.d.mts"],"sourcesContent":["import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\n/**\n * Configuration options for CommanderApplication.\n *\n * @public\n */\nexport interface CommanderApplicationOptions {\n}\n/**\n * Main application class for managing CLI command execution.\n *\n * This class handles module loading, command registration, and command execution.\n * It provides both programmatic and CLI-based command execution capabilities.\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * ```\n */\nexport declare class CommanderApplication {\n private moduleLoader;\n private cliParser;\n protected container: Container;\n private appModule;\n private options;\n /**\n * Indicates whether the application has been initialized.\n * Set to `true` after `init()` is called successfully.\n */\n isInitialized: boolean;\n /**\n * @internal\n * Sets up the application with the provided module and options.\n * This is called automatically by CommanderFactory.create().\n */\n setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<void>;\n /**\n * Gets the dependency injection container used by this application.\n *\n * @returns The Container instance\n *\n * @example\n * ```typescript\n * const container = app.getContainer()\n * const service = await container.get(MyService)\n * ```\n */\n getContainer(): Container;\n /**\n * Initializes the application by loading all modules and registering commands.\n *\n * This method must be called before executing commands or running the CLI.\n * It traverses the module tree, loads all imported modules, and collects command metadata.\n *\n * @throws {Error} If the app module is not set (setup() was not called)\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init() // Must be called before run() or executeCommand()\n * ```\n */\n init(): Promise<void>;\n /**\n * Executes a command programmatically with the provided options.\n *\n * This method is useful for testing, automation, or programmatic workflows.\n * The options will be validated against the command's Zod schema if one is provided.\n *\n * @param commandPath - The command path (e.g., 'greet', 'user:create')\n * @param options - The command options object (will be validated if schema exists)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If the command is not found\n * @throws {Error} If the command does not implement the execute method\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * await app.executeCommand('greet', {\n * name: 'World',\n * greeting: 'Hi'\n * })\n * ```\n */\n executeCommand(commandPath: string, options?: any): Promise<void>;\n /**\n * Gets all registered commands with their paths and class references.\n *\n * @returns An array of objects containing the command path and class\n *\n * @example\n * ```typescript\n * const commands = app.getAllCommands()\n * commands.forEach(({ path }) => {\n * console.log(`Available: ${path}`)\n * })\n * ```\n */\n getAllCommands(): {\n path: string;\n class: ClassTypeWithInstance<any>;\n }[];\n /**\n * Runs the CLI application by parsing command-line arguments and executing the appropriate command.\n *\n * This is the main entry point for CLI usage. It parses `argv`, validates options,\n * and executes the matching command. Supports help command (`help`, `--help`, `-h`)\n * which displays all available commands.\n *\n * @param argv - Command-line arguments array (defaults to `process.argv`)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If no command is provided\n * @throws {Error} If the command is not found\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * // Parse and execute from process.argv\n * await app.run()\n *\n * // Or provide custom arguments\n * await app.run(['node', 'cli.js', 'greet', '--name', 'World'])\n * ```\n */\n run(argv?: string[]): Promise<void>;\n /**\n * @internal\n * Disposes of resources used by the application.\n */\n dispose(): Promise<void>;\n /**\n * Closes the application and cleans up resources.\n *\n * This should be called when the application is no longer needed to free up resources.\n *\n * @example\n * ```typescript\n * await app.run(process.argv)\n * await app.close()\n * ```\n */\n close(): Promise<void>;\n}\n//# sourceMappingURL=commander.application.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport type { CommanderApplicationOptions } from './commander.application.mjs';\nimport { CommanderApplication } from './commander.application.mjs';\n/**\n * Factory class for creating and configuring CLI applications.\n *\n * @example\n * ```typescript\n * import { CommanderFactory } from '@navios/commander'\n * import { AppModule } from './app.module'\n *\n * async function bootstrap() {\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * await app.close()\n * }\n * ```\n */\nexport declare class CommanderFactory {\n /**\n * Creates a new CommanderApplication instance and configures it with the provided module.\n *\n * @param appModule - The root CLI module class that contains commands and/or imports other modules\n * @param options - Optional configuration options for the application\n * @returns A promise that resolves to a configured CommanderApplication instance\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * ```\n */\n static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<CommanderApplication>;\n}\n//# sourceMappingURL=commander.factory.d.mts.map","import type { ClassType } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: ZodObject;\n}\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command({ path, optionsSchema }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=command.decorator.d.mts.map","import type { ClassType } from '@navios/core';\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>;\n /**\n * Array or Set of other CLI modules to import.\n * Imported modules' commands will be available in this module.\n */\n imports?: ClassType[] | Set<ClassType>;\n}\n/**\n * Decorator that marks a class as a CLI module.\n *\n * Modules organize commands and can import other modules to compose larger CLI applications.\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule({ commands, imports }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=cli-module.decorator.d.mts.map","/**\n * Interface that all command classes must implement.\n *\n * Commands decorated with `@Command` must implement this interface.\n * The `execute` method is called when the command is invoked.\n *\n * @template TOptions - The type of options that the command accepts\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string()\n * })\n *\n * type Options = z.infer<typeof optionsSchema>\n *\n * @Command({ path: 'greet', optionsSchema })\n * export class GreetCommand implements CommandHandler<Options> {\n * async execute(options: Options) {\n * console.log(`Hello, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport interface CommandHandler<TOptions = any> {\n /**\n * Executes the command with the provided options.\n *\n * @param options - The validated command options (validated against the command's schema if provided)\n * @returns A promise or void\n */\n execute(options: TOptions): void | Promise<void>;\n}\n//# sourceMappingURL=command-handler.interface.d.mts.map","import type { ClassType } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * @internal\n * Symbol key used to store command metadata on classes.\n */\nexport declare const CommandMetadataKey: unique symbol;\n/**\n * Metadata associated with a command.\n *\n * @public\n */\nexport interface CommandMetadata {\n /**\n * The command path (e.g., 'greet', 'user:create').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n */\n optionsSchema?: ZodObject;\n /**\n * Map of custom attributes that can be attached to the command.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates command metadata for a class.\n *\n * @internal\n * @param target - The command class\n * @param context - The decorator context\n * @param path - The command path\n * @param optionsSchema - Optional Zod schema\n * @returns The command metadata\n */\nexport declare function getCommandMetadata(target: ClassType, context: ClassDecoratorContext, path: string, optionsSchema?: ZodObject): CommandMetadata;\n/**\n * Extracts command metadata from a class.\n *\n * @param target - The command class\n * @returns The command metadata\n * @throws {Error} If the class is not decorated with @Command\n *\n * @example\n * ```typescript\n * const metadata = extractCommandMetadata(GreetCommand)\n * console.log(metadata.path) // 'greet'\n * ```\n */\nexport declare function extractCommandMetadata(target: ClassType): CommandMetadata;\n/**\n * Checks if a class has command metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @Command, `false` otherwise\n */\nexport declare function hasCommandMetadata(target: ClassType): boolean;\n//# sourceMappingURL=command.metadata.d.mts.map","import type { CommandMetadata } from '../metadata/command.metadata.mjs';\n/**\n * Execution context for a command execution.\n *\n * Provides access to command metadata, path, and validated options during command execution.\n * This context is automatically injected and available via the `CommandExecutionContext` token.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class CommandLogger {\n * private ctx = inject(CommandExecutionContext)\n *\n * log() {\n * console.log('Command:', this.ctx.getCommandPath())\n * console.log('Options:', this.ctx.getOptions())\n * }\n * }\n * ```\n */\nexport declare class CommanderExecutionContext {\n private readonly command;\n private readonly commandPath;\n private readonly options;\n /**\n * @internal\n * Creates a new execution context.\n */\n constructor(command: CommandMetadata, commandPath: string, options: any);\n /**\n * Gets the command metadata.\n *\n * @returns The command metadata including path and options schema\n */\n getCommand(): CommandMetadata;\n /**\n * Gets the command path that was invoked.\n *\n * @returns The command path (e.g., 'greet', 'user:create')\n */\n getCommandPath(): string;\n /**\n * Gets the validated command options.\n *\n * Options are validated against the command's Zod schema if one was provided.\n *\n * @returns The validated options object\n */\n getOptions(): any;\n}\n//# sourceMappingURL=commander-execution-context.interface.d.mts.map","import type { ClassType } from '@navios/core';\n/**\n * @internal\n * Symbol key used to store CLI module metadata on classes.\n */\nexport declare const CliModuleMetadataKey: unique symbol;\n/**\n * Metadata associated with a CLI module.\n *\n * @public\n */\nexport interface CliModuleMetadata {\n /**\n * Set of command classes registered in this module.\n */\n commands: Set<ClassType>;\n /**\n * Set of other modules imported by this module.\n */\n imports: Set<ClassType>;\n /**\n * Map of custom attributes that can be attached to the module.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates CLI module metadata for a class.\n *\n * @internal\n * @param target - The module class\n * @param context - The decorator context\n * @returns The module metadata\n */\nexport declare function getCliModuleMetadata(target: ClassType, context: ClassDecoratorContext): CliModuleMetadata;\n/**\n * Extracts CLI module metadata from a class.\n *\n * @param target - The module class\n * @returns The module metadata\n * @throws {Error} If the class is not decorated with @CliModule\n *\n * @example\n * ```typescript\n * const metadata = extractCliModuleMetadata(AppModule)\n * console.log(metadata.commands.size) // Number of commands\n * ```\n */\nexport declare function extractCliModuleMetadata(target: ClassType): CliModuleMetadata;\n/**\n * Checks if a class has CLI module metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @CliModule, `false` otherwise\n */\nexport declare function hasCliModuleMetadata(target: ClassType): boolean;\n//# sourceMappingURL=cli-module.metadata.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\nimport type { CommandHandler } from '../interfaces/index.mjs';\nimport type { CliModuleMetadata, CommandMetadata } from '../metadata/index.mjs';\n/**\n * Command class with its associated metadata.\n *\n * @public\n */\nexport interface CommandWithMetadata {\n /**\n * The command class constructor.\n */\n class: ClassTypeWithInstance<CommandHandler>;\n /**\n * The command metadata including path and options schema.\n */\n metadata: CommandMetadata;\n}\n/**\n * Service for loading and managing CLI modules and commands.\n *\n * Handles module traversal, command registration, and metadata collection.\n * This service is used internally by CommanderApplication.\n *\n * @public\n */\nexport declare class CliModuleLoaderService {\n protected container: Container;\n private modulesMetadata;\n private loadedModules;\n private commandsMetadata;\n private initialized;\n /**\n * Loads all modules starting from the root app module.\n *\n * Traverses the module tree, loads imported modules, and collects command metadata.\n *\n * @param appModule - The root CLI module\n */\n loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;\n private traverseModules;\n private mergeMetadata;\n /**\n * Gets all loaded module metadata.\n *\n * @returns Map of module names to their metadata\n */\n getAllModules(): Map<string, CliModuleMetadata>;\n /**\n * Gets all command classes indexed by command class name.\n *\n * @returns Map of command class names to command classes\n */\n getAllCommands(): Map<string, ClassTypeWithInstance<any>>;\n /**\n * Get all commands with their metadata, indexed by command path.\n * This is populated during loadModules, so path information is available\n * before parsing CLI argv.\n */\n getAllCommandsWithMetadata(): Map<string, CommandWithMetadata>;\n /**\n * Get a command by its path, with metadata already extracted.\n * Returns undefined if command is not found.\n */\n getCommandByPath(path: string): CommandWithMetadata | undefined;\n /**\n * Disposes of all loaded modules and commands, clearing internal state.\n */\n dispose(): void;\n}\n//# sourceMappingURL=module-loader.service.d.mts.map","import type { ZodObject } from 'zod';\n/**\n * Result of parsing command-line arguments.\n *\n * @public\n */\nexport interface ParsedCliArgs {\n /**\n * The command path (e.g., 'greet', 'user:create').\n * Multi-word commands are joined with spaces.\n */\n command: string;\n /**\n * Parsed options as key-value pairs.\n * Keys are converted from kebab-case to camelCase.\n */\n options: Record<string, any>;\n /**\n * Positional arguments that don't match any option flags.\n */\n positionals: string[];\n}\n/**\n * Service for parsing command-line arguments.\n *\n * Handles parsing of various CLI argument formats including:\n * - Long options: `--key value` or `--key=value`\n * - Short options: `-k value` or `-abc` (multiple flags)\n * - Boolean flags\n * - Array options\n * - Positional arguments\n *\n * @public\n */\nexport declare class CliParserService {\n /**\n * Parses command-line arguments from process.argv\n * Commands can be multi-word (e.g., 'db migrate', 'cache clear')\n * Expected format: node script.js command [subcommand...] --flag value --boolean-flag positional1 positional2\n *\n * @param argv - Array of command-line arguments (typically process.argv)\n * @param optionsSchema - Optional Zod schema to determine boolean flags and option types\n * @returns Parsed command (space-separated if multi-word), options, and positional arguments\n */\n parse(argv: string[], optionsSchema?: ZodObject): ParsedCliArgs;\n /**\n * Converts kebab-case to camelCase\n */\n private camelCase;\n /**\n * Attempts to parse string values into appropriate types\n */\n private parseValue;\n /**\n * Extracts boolean field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractBooleanFields;\n /**\n * Extracts array field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractArrayFields;\n /**\n * Checks if a Zod schema represents a boolean type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaBoolean;\n /**\n * Checks if a Zod schema represents an array type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaArray;\n /**\n * Formats help text listing all available commands.\n *\n * @param commands - Array of command objects with path and class\n * @returns Formatted string listing all commands\n */\n formatCommandList(commands: Array<{\n path: string;\n class: any;\n }>): string;\n}\n//# sourceMappingURL=cli-parser.service.d.mts.map","import { InjectionToken } from '@navios/core';\nimport type { CommanderExecutionContext } from '../interfaces/index.mjs';\n/**\n * Injection token for accessing the current command execution context.\n *\n * Use this token with `inject()` to access the `CommanderExecutionContext` in services\n * that need information about the currently executing command.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class MyService {\n * private ctx = inject(CommandExecutionContext)\n *\n * doSomething() {\n * const commandPath = this.ctx.getCommandPath()\n * const options = this.ctx.getOptions()\n * // Use context information...\n * }\n * }\n * ```\n */\nexport declare const CommandExecutionContext: InjectionToken<CommanderExecutionContext, undefined, false>;\n//# sourceMappingURL=execution-context.token.d.mts.map"],"mappings":";;;;;;;;;;AAOA;AAeqBI,UAfJD,2BAAAA,CAewB;;;;;;;;;;;;;;cAApBC,oBAAAA;;ECHAM,QAAAA,SAAAA;EAc8BH,UAAAA,SAAAA,EDR1BL,SCQ0BK;EAAtBD,QAAAA,SAAAA;EAA+CE,QAAAA,OAAAA;EAAsCC;;;;;;AC1BlH;AA0CA;;;EAAyDK,KAAAA,CAAAA,SAAAA,EFXpCd,qBEWoCc,CFXdb,YEWca,CAAAA,EAAAA,OAAAA,CAAAA,EFXWX,2BEWXW,CAAAA,EFXyCT,OEWzCS,CAAAA,IAAAA,CAAAA;EAA0BF;;;;;;;AC3CnF;;;;EAUcO,YAAAA,CAAAA,CAAAA,EHkCMjB,SGlCNiB;EAAkBA;;;AAwBhC;;;;;;;;;;;ECbiBO,IAAAA,CAAAA,CAAAA,EJsCLrB,OItCKqB,CAAAA,IAAc,CAAA;;;;ACrB/B;AAMA;AAwBA;;;;;;AAcA;AAOA;;;;AClCA;;;;AClBA;EAMiBgB,cAAAA,CAAAA,WAAiB,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,CAAA,EP4EsBrC,OO5EtB,CAAA,IAAA,CAAA;EAIhBmC;;;;;;AAkBlB;;;;;AAcA;AAOA;;;WPiDexC;EQ9FEuD,CAAAA,EAAAA;EAIgBH;;;;AAcjC;;;;;;;;;;;;;;;;ACrBA;AA4BA;EAU0CO,GAAAA,CAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA,CAAAA,ETmFhBtD,OSnFgBsD,CAAAA,IAAAA,CAAAA;EAAYC;;;;aTwFvCvD;;AU3Gf;;;;;;;;;;WVuHaA;;;;;;;AAzIb;AAeA;;;;;;;;;;;;AA0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,CAAAA,CAAAA,EAAAA,IAAAA;AAMrB;;;;;;;;ALLiB5B,USDAyD,aAAAA,CTCAzD;EAeIC;;;;EAgB+CD,OAAAA,EAAAA,MAAAA;EAA8BE;;;;EAiEnFL,OAAAA,ESvFF6D,MTuFE7D,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAwBWK;;;EAiBN,WAAA,EAAA,MAAA,EAAA;;;;AC7HpB;;;;;;;;;;ACZiBS,cO2BIgD,gBAAAA,CPjBDjD;EAgCIE;;;;;;;;;wCOLkB4C,YAAYC;;ANtCtD;;EAKiCzC,QAAAA,SAAAA;EAAJE;;;EAKDA,QAAAA,UAAAA;EAAG;AAwB/B;;;EAA0DD,QAAAA,oBAAAA;EAA4BD;;;;;;;ACbtF;;;;ACrBA;AAMA;AAwBA;EAAmDU,QAAAA,aAAAA;EAAoBM;;;;AAcvE;AAOA;8BIsBgC4B;;;EHxDXxB,CAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;;;;;;ANhBrB;AAeA;;;;;;;;;;;;;;;;;ACHA;AAcmDhC,cSR9B2D,uBTQ8B3D,ESRLyD,cTQKzD,CSRU0D,yBTQV1D,EAAAA,SAAAA,EAAAA,KAAAA,CAAAA"}
1
+ {"version":3,"file":"index.d.mts","names":["ClassTypeWithInstance","NaviosModule","Container","CommanderApplicationOptions","CommanderApplication","Promise","ClassTypeWithInstance","NaviosModule","CommanderApplicationOptions","CommanderApplication","CommanderFactory","Promise","ClassType","Registry","ZodObject","CommandOptions","Command","path","optionsSchema","priority","registry","ClassDecoratorContext","ClassType","Registry","CliModuleOptions","Set","CliModule","commands","imports","priority","registry","ClassDecoratorContext","CommandHandler","TOptions","Promise","ClassType","ZodObject","CommandMetadataKey","CommandMetadata","Map","getCommandMetadata","ClassDecoratorContext","extractCommandMetadata","hasCommandMetadata","CommandMetadata","CommanderExecutionContext","ClassType","CliModuleMetadataKey","CliModuleMetadata","Set","Map","getCliModuleMetadata","ClassDecoratorContext","extractCliModuleMetadata","hasCliModuleMetadata","ClassTypeWithInstance","NaviosModule","Container","CommandHandler","CliModuleMetadata","CommandMetadata","CommandWithMetadata","CliModuleLoaderService","Promise","Map","ZodObject","ParsedCliArgs","Record","CliParserService","Array","InjectionToken","CommanderExecutionContext","CommandExecutionContext"],"sources":["../src/commander.application.d.mts","../src/commander.factory.d.mts","../src/decorators/command.decorator.d.mts","../src/decorators/cli-module.decorator.d.mts","../src/interfaces/command-handler.interface.d.mts","../src/metadata/command.metadata.d.mts","../src/interfaces/commander-execution-context.interface.d.mts","../src/metadata/cli-module.metadata.d.mts","../src/services/module-loader.service.d.mts","../src/services/cli-parser.service.d.mts","../src/tokens/execution-context.token.d.mts"],"sourcesContent":["import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\n/**\n * Configuration options for CommanderApplication.\n *\n * @public\n */\nexport interface CommanderApplicationOptions {\n}\n/**\n * Main application class for managing CLI command execution.\n *\n * This class handles module loading, command registration, and command execution.\n * It provides both programmatic and CLI-based command execution capabilities.\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * ```\n */\nexport declare class CommanderApplication {\n private moduleLoader;\n private cliParser;\n protected container: Container;\n private appModule;\n private options;\n /**\n * Indicates whether the application has been initialized.\n * Set to `true` after `init()` is called successfully.\n */\n isInitialized: boolean;\n /**\n * @internal\n * Sets up the application with the provided module and options.\n * This is called automatically by CommanderFactory.create().\n */\n setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<void>;\n /**\n * Gets the dependency injection container used by this application.\n *\n * @returns The Container instance\n *\n * @example\n * ```typescript\n * const container = app.getContainer()\n * const service = await container.get(MyService)\n * ```\n */\n getContainer(): Container;\n /**\n * Initializes the application by loading all modules and registering commands.\n *\n * This method must be called before executing commands or running the CLI.\n * It traverses the module tree, loads all imported modules, and collects command metadata.\n *\n * @throws {Error} If the app module is not set (setup() was not called)\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init() // Must be called before run() or executeCommand()\n * ```\n */\n init(): Promise<void>;\n /**\n * Executes a command programmatically with the provided options.\n *\n * This method is useful for testing, automation, or programmatic workflows.\n * The options will be validated against the command's Zod schema if one is provided.\n *\n * @param commandPath - The command path (e.g., 'greet', 'user:create')\n * @param options - The command options object (will be validated if schema exists)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If the command is not found\n * @throws {Error} If the command does not implement the execute method\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * await app.executeCommand('greet', {\n * name: 'World',\n * greeting: 'Hi'\n * })\n * ```\n */\n executeCommand(commandPath: string, options?: any): Promise<void>;\n /**\n * Gets all registered commands with their paths and class references.\n *\n * @returns An array of objects containing the command path and class\n *\n * @example\n * ```typescript\n * const commands = app.getAllCommands()\n * commands.forEach(({ path }) => {\n * console.log(`Available: ${path}`)\n * })\n * ```\n */\n getAllCommands(): {\n path: string;\n class: ClassTypeWithInstance<any>;\n }[];\n /**\n * Runs the CLI application by parsing command-line arguments and executing the appropriate command.\n *\n * This is the main entry point for CLI usage. It parses `argv`, validates options,\n * and executes the matching command. Supports help command (`help`, `--help`, `-h`)\n * which displays all available commands.\n *\n * @param argv - Command-line arguments array (defaults to `process.argv`)\n * @throws {Error} If the application is not initialized\n * @throws {Error} If no command is provided\n * @throws {Error} If the command is not found\n * @throws {ZodError} If options validation fails\n *\n * @example\n * ```typescript\n * // Parse and execute from process.argv\n * await app.run()\n *\n * // Or provide custom arguments\n * await app.run(['node', 'cli.js', 'greet', '--name', 'World'])\n * ```\n */\n run(argv?: string[]): Promise<void>;\n /**\n * @internal\n * Disposes of resources used by the application.\n */\n dispose(): Promise<void>;\n /**\n * Closes the application and cleans up resources.\n *\n * This should be called when the application is no longer needed to free up resources.\n *\n * @example\n * ```typescript\n * await app.run(process.argv)\n * await app.close()\n * ```\n */\n close(): Promise<void>;\n}\n//# sourceMappingURL=commander.application.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport type { CommanderApplicationOptions } from './commander.application.mjs';\nimport { CommanderApplication } from './commander.application.mjs';\n/**\n * Factory class for creating and configuring CLI applications.\n *\n * @example\n * ```typescript\n * import { CommanderFactory } from '@navios/commander'\n * import { AppModule } from './app.module'\n *\n * async function bootstrap() {\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * await app.run(process.argv)\n * await app.close()\n * }\n * ```\n */\nexport declare class CommanderFactory {\n /**\n * Creates a new CommanderApplication instance and configures it with the provided module.\n *\n * @param appModule - The root CLI module class that contains commands and/or imports other modules\n * @param options - Optional configuration options for the application\n * @returns A promise that resolves to a configured CommanderApplication instance\n *\n * @example\n * ```typescript\n * const app = await CommanderFactory.create(AppModule)\n * await app.init()\n * ```\n */\n static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: CommanderApplicationOptions): Promise<CommanderApplication>;\n}\n//# sourceMappingURL=commander.factory.d.mts.map","import type { ClassType, Registry } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: ZodObject;\n /**\n * Priority level for the command.\n * Higher priority commands will be loaded first.\n */\n priority?: number;\n /**\n * Registry to use for the command.\n * Registry is used to store the command and its options schema.\n */\n registry?: Registry;\n}\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command({ path, optionsSchema, priority, registry, }: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=command.decorator.d.mts.map","import type { ClassType, Registry } from '@navios/core';\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>;\n /**\n * Array or Set of other CLI modules to import.\n * Imported modules' commands will be available in this module.\n */\n imports?: ClassType[] | Set<ClassType>;\n /**\n * Priority level for the module.\n * Higher priority modules will be loaded first.\n */\n priority?: number;\n /**\n * Registry to use for the module.\n * Registry is used to store the module and its commands.\n */\n registry?: Registry;\n}\n/**\n * Decorator that marks a class as a CLI module.\n *\n * Modules organize commands and can import other modules to compose larger CLI applications.\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule({ commands, imports, priority, registry }?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;\n//# sourceMappingURL=cli-module.decorator.d.mts.map","/**\n * Interface that all command classes must implement.\n *\n * Commands decorated with `@Command` must implement this interface.\n * The `execute` method is called when the command is invoked.\n *\n * @template TOptions - The type of options that the command accepts\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string()\n * })\n *\n * type Options = z.infer<typeof optionsSchema>\n *\n * @Command({ path: 'greet', optionsSchema })\n * export class GreetCommand implements CommandHandler<Options> {\n * async execute(options: Options) {\n * console.log(`Hello, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport interface CommandHandler<TOptions = any> {\n /**\n * Executes the command with the provided options.\n *\n * @param options - The validated command options (validated against the command's schema if provided)\n * @returns A promise or void\n */\n execute(options: TOptions): void | Promise<void>;\n}\n//# sourceMappingURL=command-handler.interface.d.mts.map","import type { ClassType } from '@navios/core';\nimport type { ZodObject } from 'zod';\n/**\n * @internal\n * Symbol key used to store command metadata on classes.\n */\nexport declare const CommandMetadataKey: unique symbol;\n/**\n * Metadata associated with a command.\n *\n * @public\n */\nexport interface CommandMetadata {\n /**\n * The command path (e.g., 'greet', 'user:create').\n */\n path: string;\n /**\n * Optional Zod schema for validating command options.\n */\n optionsSchema?: ZodObject;\n /**\n * Map of custom attributes that can be attached to the command.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates command metadata for a class.\n *\n * @internal\n * @param target - The command class\n * @param context - The decorator context\n * @param path - The command path\n * @param optionsSchema - Optional Zod schema\n * @returns The command metadata\n */\nexport declare function getCommandMetadata(target: ClassType, context: ClassDecoratorContext, path: string, optionsSchema?: ZodObject): CommandMetadata;\n/**\n * Extracts command metadata from a class.\n *\n * @param target - The command class\n * @returns The command metadata\n * @throws {Error} If the class is not decorated with @Command\n *\n * @example\n * ```typescript\n * const metadata = extractCommandMetadata(GreetCommand)\n * console.log(metadata.path) // 'greet'\n * ```\n */\nexport declare function extractCommandMetadata(target: ClassType): CommandMetadata;\n/**\n * Checks if a class has command metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @Command, `false` otherwise\n */\nexport declare function hasCommandMetadata(target: ClassType): boolean;\n//# sourceMappingURL=command.metadata.d.mts.map","import type { CommandMetadata } from '../metadata/command.metadata.mjs';\n/**\n * Execution context for a command execution.\n *\n * Provides access to command metadata, path, and validated options during command execution.\n * This context is automatically injected and available via the `CommandExecutionContext` token.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class CommandLogger {\n * private ctx = inject(CommandExecutionContext)\n *\n * log() {\n * console.log('Command:', this.ctx.getCommandPath())\n * console.log('Options:', this.ctx.getOptions())\n * }\n * }\n * ```\n */\nexport declare class CommanderExecutionContext {\n private readonly command;\n private readonly commandPath;\n private readonly options;\n /**\n * @internal\n * Creates a new execution context.\n */\n constructor(command: CommandMetadata, commandPath: string, options: any);\n /**\n * Gets the command metadata.\n *\n * @returns The command metadata including path and options schema\n */\n getCommand(): CommandMetadata;\n /**\n * Gets the command path that was invoked.\n *\n * @returns The command path (e.g., 'greet', 'user:create')\n */\n getCommandPath(): string;\n /**\n * Gets the validated command options.\n *\n * Options are validated against the command's Zod schema if one was provided.\n *\n * @returns The validated options object\n */\n getOptions(): any;\n}\n//# sourceMappingURL=commander-execution-context.interface.d.mts.map","import type { ClassType } from '@navios/core';\n/**\n * @internal\n * Symbol key used to store CLI module metadata on classes.\n */\nexport declare const CliModuleMetadataKey: unique symbol;\n/**\n * Metadata associated with a CLI module.\n *\n * @public\n */\nexport interface CliModuleMetadata {\n /**\n * Set of command classes registered in this module.\n */\n commands: Set<ClassType>;\n /**\n * Set of other modules imported by this module.\n */\n imports: Set<ClassType>;\n /**\n * Map of custom attributes that can be attached to the module.\n */\n customAttributes: Map<string | symbol, any>;\n}\n/**\n * Gets or creates CLI module metadata for a class.\n *\n * @internal\n * @param target - The module class\n * @param context - The decorator context\n * @returns The module metadata\n */\nexport declare function getCliModuleMetadata(target: ClassType, context: ClassDecoratorContext): CliModuleMetadata;\n/**\n * Extracts CLI module metadata from a class.\n *\n * @param target - The module class\n * @returns The module metadata\n * @throws {Error} If the class is not decorated with @CliModule\n *\n * @example\n * ```typescript\n * const metadata = extractCliModuleMetadata(AppModule)\n * console.log(metadata.commands.size) // Number of commands\n * ```\n */\nexport declare function extractCliModuleMetadata(target: ClassType): CliModuleMetadata;\n/**\n * Checks if a class has CLI module metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @CliModule, `false` otherwise\n */\nexport declare function hasCliModuleMetadata(target: ClassType): boolean;\n//# sourceMappingURL=cli-module.metadata.d.mts.map","import type { ClassTypeWithInstance, NaviosModule } from '@navios/core';\nimport { Container } from '@navios/core';\nimport type { CommandHandler } from '../interfaces/index.mjs';\nimport type { CliModuleMetadata, CommandMetadata } from '../metadata/index.mjs';\n/**\n * Command class with its associated metadata.\n *\n * @public\n */\nexport interface CommandWithMetadata {\n /**\n * The command class constructor.\n */\n class: ClassTypeWithInstance<CommandHandler>;\n /**\n * The command metadata including path and options schema.\n */\n metadata: CommandMetadata;\n}\n/**\n * Service for loading and managing CLI modules and commands.\n *\n * Handles module traversal, command registration, and metadata collection.\n * This service is used internally by CommanderApplication.\n *\n * @public\n */\nexport declare class CliModuleLoaderService {\n protected container: Container;\n private modulesMetadata;\n private loadedModules;\n private commandsMetadata;\n private initialized;\n /**\n * Loads all modules starting from the root app module.\n *\n * Traverses the module tree, loads imported modules, and collects command metadata.\n *\n * @param appModule - The root CLI module\n */\n loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;\n private traverseModules;\n private mergeMetadata;\n /**\n * Gets all loaded module metadata.\n *\n * @returns Map of module names to their metadata\n */\n getAllModules(): Map<string, CliModuleMetadata>;\n /**\n * Gets all command classes indexed by command class name.\n *\n * @returns Map of command class names to command classes\n */\n getAllCommands(): Map<string, ClassTypeWithInstance<any>>;\n /**\n * Get all commands with their metadata, indexed by command path.\n * This is populated during loadModules, so path information is available\n * before parsing CLI argv.\n */\n getAllCommandsWithMetadata(): Map<string, CommandWithMetadata>;\n /**\n * Get a command by its path, with metadata already extracted.\n * Returns undefined if command is not found.\n */\n getCommandByPath(path: string): CommandWithMetadata | undefined;\n /**\n * Disposes of all loaded modules and commands, clearing internal state.\n */\n dispose(): void;\n}\n//# sourceMappingURL=module-loader.service.d.mts.map","import type { ZodObject } from 'zod';\n/**\n * Result of parsing command-line arguments.\n *\n * @public\n */\nexport interface ParsedCliArgs {\n /**\n * The command path (e.g., 'greet', 'user:create').\n * Multi-word commands are joined with spaces.\n */\n command: string;\n /**\n * Parsed options as key-value pairs.\n * Keys are converted from kebab-case to camelCase.\n */\n options: Record<string, any>;\n /**\n * Positional arguments that don't match any option flags.\n */\n positionals: string[];\n}\n/**\n * Service for parsing command-line arguments.\n *\n * Handles parsing of various CLI argument formats including:\n * - Long options: `--key value` or `--key=value`\n * - Short options: `-k value` or `-abc` (multiple flags)\n * - Boolean flags\n * - Array options\n * - Positional arguments\n *\n * @public\n */\nexport declare class CliParserService {\n /**\n * Parses command-line arguments from process.argv\n * Commands can be multi-word (e.g., 'db migrate', 'cache clear')\n * Expected format: node script.js command [subcommand...] --flag value --boolean-flag positional1 positional2\n *\n * @param argv - Array of command-line arguments (typically process.argv)\n * @param optionsSchema - Optional Zod schema to determine boolean flags and option types\n * @returns Parsed command (space-separated if multi-word), options, and positional arguments\n */\n parse(argv: string[], optionsSchema?: ZodObject): ParsedCliArgs;\n /**\n * Converts kebab-case to camelCase\n */\n private camelCase;\n /**\n * Attempts to parse string values into appropriate types\n */\n private parseValue;\n /**\n * Extracts boolean field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractBooleanFields;\n /**\n * Extracts array field names from a Zod schema\n * Handles ZodObject, ZodOptional, and ZodDefault wrappers\n */\n private extractArrayFields;\n /**\n * Checks if a Zod schema represents a boolean type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaBoolean;\n /**\n * Checks if a Zod schema represents an array type\n * Unwraps ZodOptional and ZodDefault\n */\n private isSchemaArray;\n /**\n * Formats help text listing all available commands.\n *\n * @param commands - Array of command objects with path and class\n * @returns Formatted string listing all commands\n */\n formatCommandList(commands: Array<{\n path: string;\n class: any;\n }>): string;\n}\n//# sourceMappingURL=cli-parser.service.d.mts.map","import { InjectionToken } from '@navios/core';\nimport type { CommanderExecutionContext } from '../interfaces/index.mjs';\n/**\n * Injection token for accessing the current command execution context.\n *\n * Use this token with `inject()` to access the `CommanderExecutionContext` in services\n * that need information about the currently executing command.\n *\n * @example\n * ```typescript\n * import { inject, Injectable } from '@navios/di'\n * import { CommandExecutionContext } from '@navios/commander'\n *\n * @Injectable()\n * class MyService {\n * private ctx = inject(CommandExecutionContext)\n *\n * doSomething() {\n * const commandPath = this.ctx.getCommandPath()\n * const options = this.ctx.getOptions()\n * // Use context information...\n * }\n * }\n * ```\n */\nexport declare const CommandExecutionContext: InjectionToken<CommanderExecutionContext, undefined, false>;\n//# sourceMappingURL=execution-context.token.d.mts.map"],"mappings":";;;;;;;;;;AAOA;AAeqBI,UAfJD,2BAAAA,CAewB;;;;;;;;;;;;;;cAApBC,oBAAAA;;ECHAM,QAAAA,SAAAA;EAc8BH,UAAAA,SAAAA,EDR1BL,SCQ0BK;EAAtBD,QAAAA,SAAAA;EAA+CE,QAAAA,OAAAA;EAAsCC;;;;;;AC1BlH;AAoDA;;;EAAuDU,KAAAA,CAAAA,SAAAA,EFrBlCnB,qBEqBkCmB,CFrBZlB,YEqBYkB,CAAAA,EAAAA,OAAAA,CAAAA,EFrBahB,2BEqBbgB,CAAAA,EFrB2Cd,OEqB3Cc,CAAAA,IAAAA,CAAAA;EAAUC;;;;;;;;;ACrDjE;;EAKiCE,YAAAA,CAAAA,CAAAA,EHuCbpB,SGvCaoB;EAAJG;;;;;;AAuC7B;;;;;;;;EAAwJH,IAAAA,CAAAA,CAAAA,EHe5IjB,OGf4IiB,CAAAA,IAAAA,CAAAA;EAAS;;;;ACvBjK;;;;ACrBA;AAMA;AAwBA;;;;;;AAcA;AAOA;;;;EClCqBuB,cAAAA,CAAAA,WAAAA,EAAyB,MAAA,EAAA,OAQrBD,CAAAA,EAAAA,GAAAA,CAAAA,ENwD+BvC,OMlDtCuC,CAAAA,IAAAA,CAAAA;;;;AChClB;AAMA;;;;;;;AAsBA;;EAAyE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AAAA,EAAAA,MAAAA;IAAe,KAAA,EAAA,GAAA;EAc/HI,CAAAA,CAAAA,CAAAA,EAAAA,MAAAA;AAOxB;;;;;;;ALlDA;AAeA;;;;;;;;;;;;;;;;;ACHA;AAcmDnC,cSR9BiE,uBTQ8BjE,ESRL+D,cTQK/D,CSRUgE,yBTQVhE,EAAAA,SAAAA,EAAAA,KAAAA,CAAAA"}
package/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Container, Factory, Injectable, InjectableScope, InjectableType, InjectionToken, getInjectableToken, inject } from "@navios/di";
1
+ import { Container, Factory, Injectable, InjectableScope, InjectionToken, getInjectableToken, inject } from "@navios/di";
2
2
  import { env } from "node:process";
3
3
  import z, { z as z$1 } from "zod/v4";
4
4
  import { inspect } from "util";
@@ -41,7 +41,7 @@ var __copyProps = (to, from, except, desc) => {
41
41
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
42
42
 
43
43
  //#endregion
44
- //#region ../core/lib/use-guards.decorator-CUww54Nt.mjs
44
+ //#region ../core/lib/use-guards.decorator-CzVXuLkz.mjs
45
45
  const EndpointMetadataKey = Symbol("EndpointMetadataKey");
46
46
  function getAllEndpointMetadata(context) {
47
47
  if (context.metadata) {
@@ -151,7 +151,7 @@ function hasModuleMetadata(target) {
151
151
  * }
152
152
  * }
153
153
  * ```
154
- */ function Controller({ guards, registry } = {}) {
154
+ */ function Controller({ guards, registry, priority, scope } = {}) {
155
155
  return function(target, context) {
156
156
  if (context.kind !== "class") throw new Error("[Navios] @Controller decorator can only be used on classes.");
157
157
  const token = InjectionToken.create(target);
@@ -161,7 +161,9 @@ function hasModuleMetadata(target) {
161
161
  }
162
162
  return Injectable({
163
163
  token,
164
- registry
164
+ registry,
165
+ priority,
166
+ scope
165
167
  })(target, context);
166
168
  };
167
169
  }
@@ -246,13 +248,13 @@ function Endpoint(endpoint) {
246
248
  }
247
249
  /**
248
250
  * Decorator that marks a class as a Navios module.
249
- *
251
+ *
250
252
  * Modules are the basic building blocks of a Navios application.
251
253
  * They organize controllers, services, and other modules into logical units.
252
- *
254
+ *
253
255
  * @param options - Module configuration options
254
256
  * @returns A class decorator
255
- *
257
+ *
256
258
  * @example
257
259
  * ```typescript
258
260
  * @Module({
@@ -262,7 +264,7 @@ function Endpoint(endpoint) {
262
264
  * })
263
265
  * export class AppModule {}
264
266
  * ```
265
- */ function Module({ controllers = [], imports = [], guards = [] } = {
267
+ */ function Module({ controllers = [], imports = [], guards = [], priority, registry } = {
266
268
  controllers: [],
267
269
  imports: [],
268
270
  guards: []
@@ -276,7 +278,9 @@ function Endpoint(endpoint) {
276
278
  for (const guard of Array.from(guards).reverse()) moduleMetadata.guards.add(guard);
277
279
  return Injectable({
278
280
  token,
279
- scope: InjectableScope.Singleton
281
+ scope: InjectableScope.Singleton,
282
+ priority,
283
+ registry
280
284
  })(target, context);
281
285
  };
282
286
  }
@@ -380,7 +384,7 @@ function Stream(endpoint) {
380
384
  };
381
385
 
382
386
  //#endregion
383
- //#region ../core/lib/src-gBAChVRL.mjs
387
+ //#region ../core/lib/src-Bo23RIo-.mjs
384
388
  function envInt(key, defaultValue) {
385
389
  const envKey = env[key] || process.env[key];
386
390
  return envKey ? parseInt(envKey, 10) : defaultValue;
@@ -3054,7 +3058,7 @@ _dec$9 = Injectable();
3054
3058
  async traverseModules(module, parentMetadata) {
3055
3059
  const metadata = extractModuleMetadata(module);
3056
3060
  if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
3057
- const moduleName = module.name;
3061
+ const moduleName = getInjectableToken(module).id;
3058
3062
  if (this.modulesMetadata.has(moduleName)) return;
3059
3063
  try {
3060
3064
  this.modulesMetadata.set(moduleName, metadata);
@@ -3451,7 +3455,7 @@ _dec$8 = Injectable();
3451
3455
  }
3452
3456
  httpTokens = /* @__PURE__ */ new Map();
3453
3457
  setupHttpEnvironment(tokens) {
3454
- this.httpTokens = tokens;
3458
+ for (const [token, value] of tokens) this.httpTokens.set(token, value);
3455
3459
  }
3456
3460
  getHttpToken(token) {
3457
3461
  return this.httpTokens.get(token);
@@ -6088,9 +6092,9 @@ _dec$15 = Injectable();
6088
6092
  * })
6089
6093
  * ```
6090
6094
  */ static async create(appModule, options = { adapter: [] }) {
6091
- const container = options.container ?? new Container();
6095
+ const container = options.container ?? new Container(options.registry);
6092
6096
  if (options.enableRequestId === true) setRequestIdEnabled(true);
6093
- container.getServiceLocator().getManager().storeCreatedHolder(NaviosOptionsToken.toString(), options, InjectableType.Class, InjectableScope.Singleton);
6097
+ container.addInstance(NaviosOptionsToken, options);
6094
6098
  await this.registerLoggerConfiguration(container, options);
6095
6099
  const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
6096
6100
  for (const adapter of adapters) await this.registerEnvironment(container, adapter);
@@ -6105,11 +6109,14 @@ _dec$15 = Injectable();
6105
6109
  }
6106
6110
  static async registerLoggerConfiguration(container, options) {
6107
6111
  const { logger } = options;
6108
- if (Array.isArray(logger) || isNil(logger)) {
6109
- (await container.get(LoggerOutput))?.setup({ logLevels: logger });
6112
+ if (Array.isArray(logger) || isNil(logger) || options.enableRequestId) {
6113
+ (await container.get(LoggerOutput))?.setup({
6114
+ logLevels: Array.isArray(logger) ? logger : void 0,
6115
+ requestId: options.enableRequestId ?? false
6116
+ });
6110
6117
  return;
6111
6118
  }
6112
- if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, InjectableType.Class, InjectableScope.Singleton);
6119
+ if (logger !== true && !isNil(logger)) container.addInstance(LoggerOutput, logger);
6113
6120
  }
6114
6121
  };
6115
6122
 
@@ -6685,7 +6692,7 @@ var CliModuleLoaderService = class {
6685
6692
  async traverseModules(module, parentMetadata) {
6686
6693
  const metadata = extractCliModuleMetadata(module);
6687
6694
  if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
6688
- const moduleName = module.name;
6695
+ const moduleName = (0, lib_exports.getInjectableToken)(module).id;
6689
6696
  if (this.modulesMetadata.has(moduleName)) return;
6690
6697
  this.modulesMetadata.set(moduleName, metadata);
6691
6698
  for (const command of metadata.commands) {
@@ -7774,14 +7781,16 @@ var CommanderApplication = class {
7774
7781
  * }
7775
7782
  * }
7776
7783
  * ```
7777
- */ function Command({ path, optionsSchema }) {
7784
+ */ function Command({ path, optionsSchema, priority, registry }) {
7778
7785
  return function(target, context) {
7779
7786
  if (context.kind !== "class") throw new Error("[Navios Commander] @Command decorator can only be used on classes.");
7780
7787
  const token = lib_exports.InjectionToken.create(target);
7781
7788
  if (context.metadata) getCommandMetadata(target, context, path, optionsSchema);
7782
7789
  return (0, lib_exports.Injectable)({
7783
7790
  token,
7784
- scope: lib_exports.InjectableScope.Singleton
7791
+ scope: lib_exports.InjectableScope.Singleton,
7792
+ priority,
7793
+ registry
7785
7794
  })(target, context);
7786
7795
  };
7787
7796
  }
@@ -7809,7 +7818,7 @@ var CommanderApplication = class {
7809
7818
  * })
7810
7819
  * export class AppModule {}
7811
7820
  * ```
7812
- */ function CliModule({ commands = [], imports = [] } = {
7821
+ */ function CliModule({ commands = [], imports = [], priority, registry } = {
7813
7822
  commands: [],
7814
7823
  imports: []
7815
7824
  }) {
@@ -7821,7 +7830,9 @@ var CommanderApplication = class {
7821
7830
  for (const importedModule of imports) moduleMetadata.imports.add(importedModule);
7822
7831
  return (0, lib_exports.Injectable)({
7823
7832
  token,
7824
- scope: lib_exports.InjectableScope.Singleton
7833
+ scope: lib_exports.InjectableScope.Singleton,
7834
+ priority,
7835
+ registry
7825
7836
  })(target, context);
7826
7837
  };
7827
7838
  }