Skip to content

v2: Commands DSL - Add command() function and update CommandMetadata #754

Description

@javiertoledo

Parent

Part of #739

Status: Completed

This work was completed in PR #733.

What Was Done

  1. Created command() DSL function in packages/core/src/dsl/command.ts

    • Functional API: command(name, options, handler)
    • Auto-registers commands in Magek.config.commandHandlers
    • Supports authorization, before hooks, and property metadata
  2. Updated CommandMetadata in packages/common/src/concepts/command.ts

    • Changed from class: CommandInterface<TCommand> to handler: CommandHandler<TInput, TResult>
    • Added name: string property
    • Defined CommandHandler type for type safety
  3. Updated CommandDispatcher in packages/core/src/command-dispatcher.ts

    • Now calls commandMetadata.handler(input, register) directly
    • No longer instantiates classes at runtime
  4. Reimplemented @Command decorator in packages/core/src/decorators/command.ts

    • Thin wrapper around the DSL command() function
    • Creates an adapter handler that instantiates classes for backwards compatibility
  5. Updated GraphQL infrastructure

    • TargetTypeMetadata uses name instead of class
    • Added generateGraphQLTypeForMetadata() for metadata-based type generation
    • Created commandMetadataToTargetTypes() transform
  6. Updated all tests to use handler-based metadata format

    • 327 tests passing in @magek/core

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions