• Decorator to register a class as a command with a unique identifier.

    The @Command decorator marks a class as a command and assigns it a unique ID that can be used for command lookup, registration, and execution. This decorator is essential for the command pattern implementation and enables type-safe command creation through the CommandRegistry.

    Returns

    Decorator function that registers the command class

    Example

    // Basic command definition
    @Command({ id: 'generate-pdf-report' })
    export class GeneratePdfReportCommand implements AnyCommand {
    public reportType: string;
    public includeCharts: boolean;
    }

    Example

    // Single-object command with context
    @Command({ id: 'archive-deal' })
    export class ArchiveDealCommand implements LimeObjectCommand {
    public context: LimeWebComponentContext & { limetype: string; id: number };
    public reason: string;
    }

    Example

    // Bulk command with filter
    @Command({ id: 'bulk-update-status' })
    export class BulkUpdateStatusCommand implements LimeObjectBulkCommand {
    public context: LimeWebComponentContext & { limetype: string };
    public filter: Expression | null;
    public newStatus: string;
    }

    Example

    // Register in CommandRegistry for type safety
    declare module '@limetech/lime-web-components' {
    interface CommandRegistry {
    'generate-pdf-report': GeneratePdfReportCommand;
    'archive-deal': ArchiveDealCommand;
    'bulk-update-status': BulkUpdateStatusCommand;
    }
    }

    // Now you can use createCommand with type safety
    const command = commandBus.createCommand({
    id: 'generate-pdf-report',
    params: { reportType: 'monthly', includeCharts: true }
    });

    Parameters

    Returns ((commandClass: CommandClass<AnyCommand>) => void)