@auto-engineer/message-bus 0.14.0 → 0.15.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/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "tsx": "^4.20.3",
18
18
  "typescript": "^5.0.0"
19
19
  },
20
- "version": "0.14.0",
20
+ "version": "0.15.0",
21
21
  "scripts": {
22
22
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
23
23
  "clean": "rm -rf dist",
@@ -1,4 +1,4 @@
1
- import type { Command, CommandHandler, Event } from './types';
1
+ import type { Command, CommandHandler, Event, EventDefinition } from './types';
2
2
 
3
3
  // Helper types to extract command details
4
4
  type CommandData<C> = C extends Command<string, infer D> ? D : never;
@@ -18,18 +18,10 @@ export interface PackageMetadata {
18
18
  description?: string;
19
19
  }
20
20
 
21
- type ExtractEventTypes<T> =
22
- T extends Promise<infer U>
23
- ? U extends Event<infer EventType, Record<string, unknown>>
24
- ? EventType
25
- : U extends Event<infer EventType1, Record<string, unknown>> | Event<infer EventType2, Record<string, unknown>>
26
- ? EventType1 | EventType2
27
- : never
28
- : never;
29
-
30
21
  export interface UnifiedCommandHandler<C extends Command<string, Record<string, unknown>>> extends CommandHandler {
31
22
  alias: string;
32
23
  description: string;
24
+ displayName?: string;
33
25
  category?: string;
34
26
  icon?: string;
35
27
  package?: PackageMetadata; // Made optional since plugin loader will extract from package.json
@@ -37,7 +29,7 @@ export interface UnifiedCommandHandler<C extends Command<string, Record<string,
37
29
  [K in keyof CommandData<C>]: FieldDefinition<CommandData<C>[K]>;
38
30
  };
39
31
  examples: string[];
40
- events?: string[];
32
+ events?: EventDefinition[];
41
33
  // Override the handle type to match CommandHandler but with the specific command type
42
34
  handle: (command: Command) => Promise<Event | Event[]>;
43
35
  }
@@ -54,6 +46,7 @@ export function defineCommandHandler<
54
46
  name: CommandType<C>;
55
47
  alias: string;
56
48
  description: string;
49
+ displayName?: string;
57
50
  category?: string;
58
51
  icon?: string;
59
52
  package?: PackageMetadata; // Made optional since plugin loader will extract from package.json
@@ -62,7 +55,7 @@ export function defineCommandHandler<
62
55
  };
63
56
  examples: string[];
64
57
  handle: H;
65
- events: Array<ExtractEventTypes<ReturnType<H>>>;
58
+ events: EventDefinition[];
66
59
  }): UnifiedCommandHandler<C>;
67
60
 
68
61
  /**
@@ -74,26 +67,28 @@ export function defineCommandHandler(config: {
74
67
  name: string;
75
68
  alias: string;
76
69
  description: string;
70
+ displayName?: string;
77
71
  category?: string;
78
72
  icon?: string;
79
73
  package?: PackageMetadata;
80
74
  fields: Record<string, FieldDefinition<unknown>>;
81
75
  examples: string[];
82
76
  handle: (command: Command) => Promise<Event | Event[]>;
83
- events: string[];
77
+ events: EventDefinition[];
84
78
  }): CommandHandler;
85
79
 
86
80
  export function defineCommandHandler(config: {
87
81
  name: string;
88
82
  alias: string;
89
83
  description: string;
84
+ displayName?: string;
90
85
  category?: string;
91
86
  icon?: string;
92
87
  package?: PackageMetadata;
93
88
  fields: Record<string, FieldDefinition<unknown>>;
94
89
  examples: string[];
95
90
  handle: (command: Command) => Promise<Event | Event[]>;
96
- events: string[];
91
+ events: EventDefinition[];
97
92
  }): CommandHandler {
98
93
  // Cast the handle function to the base Command type for interface compatibility
99
94
  return {
package/src/types.ts CHANGED
@@ -31,3 +31,5 @@ export type EventHandler<TEvent extends Event = Event> = {
31
31
  export type EventSubscription = {
32
32
  unsubscribe: () => void;
33
33
  };
34
+
35
+ export type EventDefinition = string | { name: string; displayName: string };