Parent
Part of #739
Status: Completed
This work was completed in PR #733.
What Was Done
-
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
-
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
-
Updated CommandDispatcher in packages/core/src/command-dispatcher.ts
- Now calls
commandMetadata.handler(input, register) directly
- No longer instantiates classes at runtime
-
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
-
Updated GraphQL infrastructure
TargetTypeMetadata uses name instead of class
- Added
generateGraphQLTypeForMetadata() for metadata-based type generation
- Created
commandMetadataToTargetTypes() transform
-
Updated all tests to use handler-based metadata format
- 327 tests passing in
@magek/core
Related Issues
Parent
Part of #739
Status: Completed
This work was completed in PR #733.
What Was Done
Created
command()DSL function inpackages/core/src/dsl/command.tscommand(name, options, handler)Magek.config.commandHandlersUpdated
CommandMetadatainpackages/common/src/concepts/command.tsclass: CommandInterface<TCommand>tohandler: CommandHandler<TInput, TResult>name: stringpropertyCommandHandlertype for type safetyUpdated
CommandDispatcherinpackages/core/src/command-dispatcher.tscommandMetadata.handler(input, register)directlyReimplemented
@Commanddecorator inpackages/core/src/decorators/command.tscommand()functionUpdated GraphQL infrastructure
TargetTypeMetadatausesnameinstead ofclassgenerateGraphQLTypeForMetadata()for metadata-based type generationcommandMetadataToTargetTypes()transformUpdated all tests to use handler-based metadata format
@magek/coreRelated Issues