1 |
|
2 | import { ICommand } from './ICommand';
|
3 | import { IEvent } from './IEvent';
|
4 | import { IEventListener } from './IEventListener';
|
5 | import { ICommandInterceptor } from './ICommandInterceptor';
|
6 | import { ValidationResult } from '../validate/ValidationResult';
|
7 | import { Parameters } from '../run/Parameters';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | export declare class CommandSet {
|
44 | private readonly _commands;
|
45 | private readonly _events;
|
46 | private readonly _interceptors;
|
47 | private _commandsByName;
|
48 | private _eventsByName;
|
49 | |
50 |
|
51 |
|
52 | constructor();
|
53 | /**
|
54 | * Gets all commands registered in this command set.
|
55 | *
|
56 | * @returns a list of commands.
|
57 | *
|
58 | * @see [[ICommand]]
|
59 | */
|
60 | getCommands(): ICommand[];
|
61 | /**
|
62 | * Gets all events registred in this command set.
|
63 | *
|
64 | * @returns a list of events.
|
65 | *
|
66 | * @see [[IEvent]]
|
67 | */
|
68 | getEvents(): IEvent[];
|
69 | /**
|
70 | * Searches for a command by its name.
|
71 | *
|
72 | * @param commandName the name of the command to search for.
|
73 | * @returns the command, whose name matches the provided name.
|
74 | *
|
75 | * @see [[ICommand]]
|
76 | */
|
77 | findCommand(commandName: string): ICommand;
|
78 | /**
|
79 | * Searches for an event by its name in this command set.
|
80 | *
|
81 | * @param eventName the name of the event to search for.
|
82 | * @returns the event, whose name matches the provided name.
|
83 | *
|
84 | * @see [[IEvent]]
|
85 | */
|
86 | findEvent(eventName: string): IEvent;
|
87 | private buildCommandChain;
|
88 | private rebuildAllCommandChains;
|
89 | /**
|
90 | * Adds a [[ICommand command]] to this command set.
|
91 | *
|
92 | * @param command the command to add.
|
93 | *
|
94 | * @see [[ICommand]]
|
95 | */
|
96 | addCommand(command: ICommand): void;
|
97 | /**
|
98 | * Adds multiple [[ICommand commands]] to this command set.
|
99 | *
|
100 | * @param commands the array of commands to add.
|
101 | *
|
102 | * @see [[ICommand]]
|
103 | */
|
104 | addCommands(commands: ICommand[]): void;
|
105 | /**
|
106 | * Adds an [[IEvent event]] to this command set.
|
107 | *
|
108 | * @param event the event to add.
|
109 | * @see [[IEvent]]
|
110 | */
|
111 | addEvent(event: IEvent): void;
|
112 | /**
|
113 | * Adds multiple [[IEvent events]] to this command set.
|
114 | *
|
115 | * @param events the array of events to add.
|
116 | *
|
117 | * @see [[IEvent]]
|
118 | */
|
119 | addEvents(events: IEvent[]): void;
|
120 | /**
|
121 | * Adds all of the commands and events from specified [[CommandSet command set]]
|
122 | * into this one.
|
123 | *
|
124 | * @param commandSet the CommandSet to add.
|
125 | */
|
126 | addCommandSet(commandSet: CommandSet): void;
|
127 | /**
|
128 | * Adds a [[IEventListener listener]] to receive notifications on fired events.
|
129 | *
|
130 | * @param listener the listener to add.
|
131 | *
|
132 | * @see [[IEventListener]]
|
133 | */
|
134 | addListener(listener: IEventListener): void;
|
135 | /**
|
136 | * Removes previosly added [[IEventListener listener]].
|
137 | *
|
138 | * @param listener the listener to remove.
|
139 | *
|
140 | * @see [[IEventListener]]
|
141 | */
|
142 | removeListener(listener: IEventListener): void;
|
143 | /**
|
144 | * Adds a [[ICommandInterceptor command interceptor]] to this command set.
|
145 | *
|
146 | * @param interceptor the interceptor to add.
|
147 | *
|
148 | * @see [[ICommandInterceptor]]
|
149 | */
|
150 | addInterceptor(interceptor: ICommandInterceptor): void;
|
151 | /**
|
152 | * Executes a [[ICommand command]] specificed by its name.
|
153 | *
|
154 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
155 | * @param commandName the name of that command that is to be executed.
|
156 | * @param args the parameters (arguments) to pass to the command for execution.
|
157 | * @param callback the function that is to be called once execution is complete. If an exception is raised, then
|
158 | * it will be called with the error (for example: a ValidationException can be thrown).
|
159 | *
|
160 | * @see [[ICommand]]
|
161 | * @see [[Parameters]]
|
162 | */
|
163 | execute(correlationId: string, commandName: string, args: Parameters, callback: (err: any, result: any) => void): void;
|
164 | /**
|
165 | * Validates [[Parameters args]] for command specified by its name using defined schema.
|
166 | * If validation schema is not defined than the methods returns no errors.
|
167 | * It returns validation error if the command is not found.
|
168 | *
|
169 | * @param commandName the name of the command for which the 'args' must be validated.
|
170 | * @param args the parameters (arguments) to validate.
|
171 | * @returns an array of ValidationResults. If no command is found by the given
|
172 | * name, then the returned array of ValidationResults will contain a
|
173 | * single entry, whose type will be ValidationResultType.Error.
|
174 | *
|
175 | * @see [[Command]]
|
176 | * @see [[Parameters]]
|
177 | * @see [[ValidationResult]]
|
178 | */
|
179 | validate(commandName: string, args: Parameters): ValidationResult[];
|
180 | /**
|
181 | * Fires event specified by its name and notifies all registered
|
182 | * [[IEventListener listeners]]
|
183 | *
|
184 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
185 | * @param eventName the name of the event that is to be fired.
|
186 | * @param args the event arguments (parameters).
|
187 | */
|
188 | notify(correlationId: string, eventName: string, args: Parameters): void;
|
189 | }
|