@limetech/lime-web-components 6.4.0 → 6.5.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/CHANGELOG.md +16 -0
- package/dist/action/action.d.ts +305 -13
- package/dist/action/action.d.ts.map +1 -1
- package/dist/application/decorators/application.d.ts +57 -3
- package/dist/application/decorators/application.d.ts.map +1 -1
- package/dist/application/decorators/session.d.ts +44 -3
- package/dist/application/decorators/session.d.ts.map +1 -1
- package/dist/application/decorators/user.d.ts +47 -3
- package/dist/application/decorators/user.d.ts.map +1 -1
- package/dist/application/repository.d.ts +102 -5
- package/dist/application/repository.d.ts.map +1 -1
- package/dist/application/session.d.ts +105 -15
- package/dist/application/session.d.ts.map +1 -1
- package/dist/application/user.d.ts +122 -13
- package/dist/application/user.d.ts.map +1 -1
- package/dist/commandbus/commandbus.d.ts +364 -23
- package/dist/commandbus/commandbus.d.ts.map +1 -1
- package/dist/conditionregistry/conditionregistry.d.ts +310 -27
- package/dist/conditionregistry/conditionregistry.d.ts.map +1 -1
- package/dist/config/decorator.d.ts +50 -3
- package/dist/config/decorator.d.ts.map +1 -1
- package/dist/config/repository.d.ts +131 -10
- package/dist/config/repository.d.ts.map +1 -1
- package/dist/core/context.d.ts +94 -4
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/lime-web-component.d.ts +59 -3
- package/dist/core/lime-web-component.d.ts.map +1 -1
- package/dist/core/metadata.d.ts +113 -13
- package/dist/core/metadata.d.ts.map +1 -1
- package/dist/core/platform.d.ts +175 -14
- package/dist/core/platform.d.ts.map +1 -1
- package/dist/core/state.d.ts +138 -14
- package/dist/core/state.d.ts.map +1 -1
- package/dist/datetimeformatter/datetimeformatter.d.ts +97 -34
- package/dist/datetimeformatter/datetimeformatter.d.ts.map +1 -1
- package/dist/device/decorator.d.ts +56 -4
- package/dist/device/decorator.d.ts.map +1 -1
- package/dist/device/device.d.ts +51 -6
- package/dist/device/device.d.ts.map +1 -1
- package/dist/dialog/dialog.d.ts +155 -19
- package/dist/dialog/dialog.d.ts.map +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/limeobject/file.d.ts +6 -0
- package/dist/limeobject/file.d.ts.map +1 -1
- package/package.json +10 -9
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { LimeWebComponentContext, ConfigMetadata } from '../core';
|
|
2
2
|
import { Expression } from '../query';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Base marker interface for all commands in the command bus pattern.
|
|
5
|
+
*
|
|
6
|
+
* {@link AnyCommand} serves as the root interface for the command pattern implementation.
|
|
7
|
+
* All commands must extend this interface (either directly or through {@link LimeObjectCommand}
|
|
8
|
+
* or {@link LimeObjectBulkCommand}) to be handled by the {@link CommandBus}.
|
|
9
|
+
*
|
|
10
|
+
* Commands represent user actions or operations that can be executed, such as:
|
|
11
|
+
* - Exporting data to Excel
|
|
12
|
+
* - Sending emails
|
|
13
|
+
* - Generating reports
|
|
14
|
+
* - Creating or deleting records
|
|
15
|
+
* - Custom business logic operations
|
|
16
|
+
*
|
|
17
|
+
* > **Important:** All properties of a command must be serializable and publicly assignable:
|
|
18
|
+
* >
|
|
19
|
+
* > **Serialization requirements:**
|
|
20
|
+
* > - Use primitive types (string, number, boolean)
|
|
21
|
+
* > - Use plain objects and arrays
|
|
22
|
+
* > - Use serializable custom types (like {@link Expression})
|
|
23
|
+
* > - Avoid functions, DOM elements, class instances with methods, circular references, etc.
|
|
24
|
+
* >
|
|
25
|
+
* > **Assignability requirements:**
|
|
26
|
+
* > - All properties must be public (not private or protected)
|
|
27
|
+
* > - Properties cannot be readonly after instantiation
|
|
28
|
+
* > - Constructor parameters are optional for command creation
|
|
29
|
+
* >
|
|
30
|
+
* > The platform creates commands by instantiating the class without constructor arguments,
|
|
31
|
+
* > then directly assigning values to properties. Commands may also be serialized for storage,
|
|
32
|
+
* > transmission, or recreation via {@link CommandBus.createCommand}.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* @Command({ id: 'generate-report' })
|
|
37
|
+
* export class GenerateReportCommand implements AnyCommand {
|
|
38
|
+
* public reportType: string;
|
|
39
|
+
* public startDate: string; // ISO date string, not Date object
|
|
40
|
+
* public endDate: string;
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see {@link LimeObjectCommand} for commands operating on a single object
|
|
45
|
+
* @see {@link LimeObjectBulkCommand} for commands operating on multiple objects
|
|
46
|
+
* @see {@link CommandBus} for executing commands
|
|
5
47
|
*
|
|
6
48
|
* @public
|
|
7
49
|
* @group Command bus
|
|
@@ -9,14 +51,57 @@ import { Expression } from '../query';
|
|
|
9
51
|
export interface AnyCommand {
|
|
10
52
|
}
|
|
11
53
|
/**
|
|
12
|
-
* A command
|
|
54
|
+
* A command that operates on a single {@link LimeObject}.
|
|
55
|
+
*
|
|
56
|
+
* {@link LimeObjectCommand} is used for actions that target a specific record,
|
|
57
|
+
* such as sending an email to a contact, generating a PDF for a deal, or
|
|
58
|
+
* archiving a specific company. The context property identifies which object
|
|
59
|
+
* the command should operate on.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* @Command({ id: 'send-email' })
|
|
64
|
+
* export class SendEmailCommand implements LimeObjectCommand {
|
|
65
|
+
* public context: LimeWebComponentContext & { limetype: string; id: number };
|
|
66
|
+
* public subject: string;
|
|
67
|
+
* public body: string;
|
|
68
|
+
*
|
|
69
|
+
* constructor(
|
|
70
|
+
* context?: LimeWebComponentContext & { limetype: string; id: number },
|
|
71
|
+
* subject?: string,
|
|
72
|
+
* body?: string
|
|
73
|
+
* ) {
|
|
74
|
+
* this.context = context;
|
|
75
|
+
* this.subject = subject;
|
|
76
|
+
* this.body = body;
|
|
77
|
+
* }
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // Execute a single-object command
|
|
84
|
+
* const commandBus = platform.get(PlatformServiceName.CommandBus);
|
|
85
|
+
*
|
|
86
|
+
* const command = new SendEmailCommand(
|
|
87
|
+
* context,
|
|
88
|
+
* 'Meeting Invitation',
|
|
89
|
+
* 'Please join us for a meeting...'
|
|
90
|
+
* );
|
|
91
|
+
*
|
|
92
|
+
* await commandBus.handle(command);
|
|
93
|
+
* ```
|
|
13
94
|
*
|
|
14
95
|
* @public
|
|
15
96
|
* @group Command bus
|
|
16
97
|
*/
|
|
17
98
|
export interface LimeObjectCommand extends AnyCommand {
|
|
18
99
|
/**
|
|
19
|
-
* Context describing the {@link LimeObject} the command will operate on
|
|
100
|
+
* Context describing the {@link LimeObject} the command will operate on.
|
|
101
|
+
*
|
|
102
|
+
* Must include both `limetype` (the type of object) and `id` (the specific
|
|
103
|
+
* object's identifier). This ensures the command knows exactly which record
|
|
104
|
+
* to target.
|
|
20
105
|
*/
|
|
21
106
|
context: LimeWebComponentContext & {
|
|
22
107
|
limetype: string;
|
|
@@ -24,23 +109,124 @@ export interface LimeObjectCommand extends AnyCommand {
|
|
|
24
109
|
};
|
|
25
110
|
}
|
|
26
111
|
/**
|
|
27
|
-
* A command
|
|
112
|
+
* A command that operates on multiple {@link LimeObject | LimeObjects} of a single {@link LimeType}.
|
|
113
|
+
*
|
|
114
|
+
* {@link LimeObjectBulkCommand} is used for batch operations on multiple records,
|
|
115
|
+
* such as exporting selected deals to Excel, sending bulk emails, or mass-updating
|
|
116
|
+
* status fields. The filter property determines which objects are included in the operation.
|
|
117
|
+
*
|
|
118
|
+
* > **Important:** Do not assume a specific filter structure in your command handler.
|
|
119
|
+
* > The filter expression can vary depending on the user's selection:
|
|
120
|
+
* > - **Specific selection**: `{ key: 'id', op: 'IN', exp: [1, 2, 3] }` (selected rows)
|
|
121
|
+
* > - **Select all with criteria**: `{ key: 'status', op: '=', exp: 'won' }` (filtered view)
|
|
122
|
+
* > - **Select all**: `null` (all objects in the limetype)
|
|
123
|
+
* >
|
|
124
|
+
* > Always pass the filter to your data queries rather than parsing its structure.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* @Command({ id: 'export-to-excel' })
|
|
129
|
+
* export class ExportToExcelCommand implements LimeObjectBulkCommand {
|
|
130
|
+
* public context: LimeWebComponentContext & { limetype: string };
|
|
131
|
+
* public filter: Expression | null;
|
|
132
|
+
* public includeRelations: boolean;
|
|
133
|
+
*
|
|
134
|
+
* constructor(
|
|
135
|
+
* context?: LimeWebComponentContext & { limetype: string },
|
|
136
|
+
* filter?: Expression | null,
|
|
137
|
+
* includeRelations: boolean = false
|
|
138
|
+
* ) {
|
|
139
|
+
* this.context = context;
|
|
140
|
+
* this.filter = filter;
|
|
141
|
+
* this.includeRelations = includeRelations;
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* // Execute a bulk command on selected items
|
|
149
|
+
* const commandBus = platform.get(PlatformServiceName.CommandBus);
|
|
150
|
+
*
|
|
151
|
+
* const selectedFilter: Expression = {
|
|
152
|
+
* key: 'id',
|
|
153
|
+
* op: 'IN',
|
|
154
|
+
* exp: [1, 2, 3, 4, 5]
|
|
155
|
+
* };
|
|
156
|
+
*
|
|
157
|
+
* const command = new ExportToExcelCommand(
|
|
158
|
+
* { limetype: 'deal' },
|
|
159
|
+
* selectedFilter,
|
|
160
|
+
* true
|
|
161
|
+
* );
|
|
162
|
+
*
|
|
163
|
+
* await commandBus.handle(command);
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* // Bulk command with parent context (related objects)
|
|
169
|
+
* const command = new UpdateStatusCommand(
|
|
170
|
+
* {
|
|
171
|
+
* limetype: 'deal',
|
|
172
|
+
* parent: { limetype: 'company', id: 123 }
|
|
173
|
+
* },
|
|
174
|
+
* {
|
|
175
|
+
* key: 'status',
|
|
176
|
+
* op: '=',
|
|
177
|
+
* exp: 'pending'
|
|
178
|
+
* },
|
|
179
|
+
* 'active' // New status value
|
|
180
|
+
* );
|
|
181
|
+
* // This will update all pending deals for company #123
|
|
182
|
+
* ```
|
|
28
183
|
*
|
|
29
184
|
* @public
|
|
30
185
|
* @group Command bus
|
|
31
186
|
*/
|
|
32
187
|
export interface LimeObjectBulkCommand extends AnyCommand {
|
|
33
188
|
/**
|
|
34
|
-
* Context describing the {@link LimeType} the command will operate on.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
189
|
+
* Context describing the {@link LimeType} the command will operate on.
|
|
190
|
+
*
|
|
191
|
+
* Must include `limetype` to identify which type of objects to operate on.
|
|
192
|
+
* If `parent` is set on the context, it indicates that the {@link LimeObject | LimeObjects}
|
|
193
|
+
* are all related to a common parent {@link LimeObject} via a `belongsto` relation.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // All deals (no parent filter)
|
|
198
|
+
* context = { limetype: 'deal' }
|
|
199
|
+
*
|
|
200
|
+
* // Only deals related to a specific company
|
|
201
|
+
* context = { limetype: 'deal', parent: { limetype: 'company', id: 456 } }
|
|
202
|
+
* ```
|
|
38
203
|
*/
|
|
39
204
|
context: LimeWebComponentContext & {
|
|
40
205
|
limetype: string;
|
|
41
206
|
};
|
|
42
207
|
/**
|
|
43
|
-
* An
|
|
208
|
+
* An {@link Expression} describing which {@link LimeObject | LimeObjects} to operate on.
|
|
209
|
+
*
|
|
210
|
+
* Can be `null` to operate on all objects (subject to parent context filtering),
|
|
211
|
+
* or a filter expression to limit the operation to specific records.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* // Operate on selected IDs
|
|
216
|
+
* filter = { key: 'id', op: 'IN', exp: [1, 2, 3] };
|
|
217
|
+
*
|
|
218
|
+
* // Operate on objects matching criteria
|
|
219
|
+
* filter = {
|
|
220
|
+
* op: 'AND',
|
|
221
|
+
* exp: [
|
|
222
|
+
* { key: 'status', op: '=', exp: 'active' },
|
|
223
|
+
* { key: 'value', op: '>', exp: 10000 }
|
|
224
|
+
* ]
|
|
225
|
+
* };
|
|
226
|
+
*
|
|
227
|
+
* // Operate on all objects
|
|
228
|
+
* filter = null;
|
|
229
|
+
* ```
|
|
44
230
|
*/
|
|
45
231
|
filter: Expression | null;
|
|
46
232
|
}
|
|
@@ -55,16 +241,80 @@ export type CommandClass<T extends AnyCommand = AnyCommand> = new (...args: unkn
|
|
|
55
241
|
*/
|
|
56
242
|
export type CommandIdentifier<T extends AnyCommand = AnyCommand> = CommandClass<T> | string;
|
|
57
243
|
/**
|
|
58
|
-
* Service for registering and executing commands
|
|
244
|
+
* Service for registering and executing commands using the command pattern.
|
|
245
|
+
*
|
|
246
|
+
* The {@link CommandBus} is the central hub for the command pattern implementation.
|
|
247
|
+
* It manages command registration, handler lookup, and command execution. Commands
|
|
248
|
+
* are decoupled from their handlers, allowing for flexible middleware chains and
|
|
249
|
+
* cross-cutting concerns like logging, validation, and authorization.
|
|
250
|
+
*
|
|
251
|
+
* Key responsibilities:
|
|
252
|
+
* - Register commands with their handlers
|
|
253
|
+
* - Execute commands through their registered handlers
|
|
254
|
+
* - Support middleware for command pipeline
|
|
255
|
+
* - Dispatch command lifecycle events
|
|
256
|
+
* - Provide command metadata and discovery
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* // Register and execute a command
|
|
261
|
+
* const commandBus = platform.get(PlatformServiceName.CommandBus);
|
|
262
|
+
*
|
|
263
|
+
* if (commandBus.isSupported(SendEmailCommand)) {
|
|
264
|
+
* const command = new SendEmailCommand(context, 'Subject', 'Body');
|
|
265
|
+
* await commandBus.handle(command);
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* // Register a custom command handler
|
|
272
|
+
* const commandBus = platform.get(PlatformServiceName.CommandBus);
|
|
273
|
+
*
|
|
274
|
+
* const handler = {
|
|
275
|
+
* handle: async (command: GenerateReportCommand) => {
|
|
276
|
+
* console.log('Generating report...');
|
|
277
|
+
* return { success: true, reportUrl: '/reports/123.pdf' };
|
|
278
|
+
* }
|
|
279
|
+
* };
|
|
280
|
+
*
|
|
281
|
+
* commandBus.register(
|
|
282
|
+
* GenerateReportCommand,
|
|
283
|
+
* handler,
|
|
284
|
+
* {
|
|
285
|
+
* title: 'Generate Report',
|
|
286
|
+
* description: 'Creates a PDF report',
|
|
287
|
+
* icon: 'file-pdf'
|
|
288
|
+
* }
|
|
289
|
+
* );
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @see {@link AnyCommand} for base command interface
|
|
293
|
+
* @see {@link CommandHandler} for handler interface
|
|
294
|
+
* @see {@link CommandMiddleware} for middleware implementation
|
|
295
|
+
*
|
|
59
296
|
* @public
|
|
60
297
|
* @group Command bus
|
|
61
298
|
*/
|
|
62
299
|
export interface CommandBus extends CommandHandler {
|
|
63
300
|
/**
|
|
64
|
-
* Register a command to be executed by the given handler
|
|
301
|
+
* Register a command to be executed by the given handler.
|
|
65
302
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
303
|
+
* Associates a command class with a handler that will process instances
|
|
304
|
+
* of that command when {@link CommandBus.handle} is called.
|
|
305
|
+
*
|
|
306
|
+
* @param commandClass - The command class to register
|
|
307
|
+
* @param handler - The {@link CommandHandler} instance that will execute the command
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* commandBus.register(SendEmailCommand, {
|
|
312
|
+
* handle: async (command: SendEmailCommand) => {
|
|
313
|
+
* // Send email logic
|
|
314
|
+
* return { success: true };
|
|
315
|
+
* }
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
68
318
|
*/
|
|
69
319
|
register(commandClass: CommandClass, handler: CommandHandler): void;
|
|
70
320
|
/**
|
|
@@ -152,7 +402,33 @@ export interface CommandMiddleware {
|
|
|
152
402
|
execute(command: AnyCommand, next: CallableCommandMiddleware): any;
|
|
153
403
|
}
|
|
154
404
|
/**
|
|
155
|
-
* Events dispatched by the commandbus event middleware
|
|
405
|
+
* Events dispatched by the commandbus event middleware.
|
|
406
|
+
*
|
|
407
|
+
* The command bus dispatches events at key points in the command lifecycle,
|
|
408
|
+
* allowing you to observe command execution, access results, handle errors,
|
|
409
|
+
* or even prevent commands from executing.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```typescript
|
|
413
|
+
* // Listen for command results
|
|
414
|
+
* document.addEventListener(CommandEventName.Handled, (event: CommandEvent) => {
|
|
415
|
+
* console.log('Command executed:', event.detail.command);
|
|
416
|
+
* console.log('Result:', event.detail.result);
|
|
417
|
+
* });
|
|
418
|
+
*
|
|
419
|
+
* // Handle command errors
|
|
420
|
+
* document.addEventListener(CommandEventName.Failed, (event: CommandEvent) => {
|
|
421
|
+
* console.error('Command failed:', event.detail.error);
|
|
422
|
+
* });
|
|
423
|
+
*
|
|
424
|
+
* // Prevent a command from executing
|
|
425
|
+
* document.addEventListener(CommandEventName.Received, (event: CommandEvent) => {
|
|
426
|
+
* if (shouldBlockCommand(event.detail.command)) {
|
|
427
|
+
* event.preventDefault();
|
|
428
|
+
* }
|
|
429
|
+
* });
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
156
432
|
* @public
|
|
157
433
|
* @group Command bus
|
|
158
434
|
*/
|
|
@@ -165,13 +441,15 @@ export declare enum CommandEventName {
|
|
|
165
441
|
*/
|
|
166
442
|
Received = "command.received",
|
|
167
443
|
/**
|
|
168
|
-
* Dispatched when the command has been handled by the commandbus
|
|
444
|
+
* Dispatched when the command has been handled by the commandbus.
|
|
445
|
+
* The event detail includes the result returned by the command handler.
|
|
169
446
|
*
|
|
170
447
|
* @see {@link CommandEvent}
|
|
171
448
|
*/
|
|
172
449
|
Handled = "command.handled",
|
|
173
450
|
/**
|
|
174
|
-
* Dispatched if an error occurs while handling the command
|
|
451
|
+
* Dispatched if an error occurs while handling the command.
|
|
452
|
+
* The event detail includes the error that was thrown.
|
|
175
453
|
*
|
|
176
454
|
* @see {@link CommandEvent}
|
|
177
455
|
*/
|
|
@@ -202,19 +480,28 @@ export interface CommandOptions {
|
|
|
202
480
|
id: string;
|
|
203
481
|
}
|
|
204
482
|
/**
|
|
205
|
-
* Config for describing a command
|
|
483
|
+
* Config for describing a command.
|
|
484
|
+
*
|
|
485
|
+
* Used with {@link CommandBus.createCommand} to create command instances from
|
|
486
|
+
* configuration data. This is useful for storing command definitions or
|
|
487
|
+
* transmitting them across boundaries.
|
|
488
|
+
*
|
|
206
489
|
* @public
|
|
490
|
+
* @group Command bus
|
|
207
491
|
*/
|
|
208
492
|
export interface CommandConfig<TCommand = any, TKey extends string = string> {
|
|
209
493
|
/**
|
|
210
|
-
* Id of the command
|
|
494
|
+
* Id of the command.
|
|
211
495
|
*
|
|
212
|
-
* Specified by the {@link Command} decorator when declaring the command
|
|
496
|
+
* Specified by the {@link Command} decorator when declaring the command.
|
|
213
497
|
*/
|
|
214
498
|
id: TKey;
|
|
215
499
|
/**
|
|
216
500
|
* Optional parameters to set when creating the command from the config.
|
|
217
|
-
*
|
|
501
|
+
*
|
|
502
|
+
* **All values must be serializable** (primitive types, plain objects, arrays).
|
|
503
|
+
* This matches the requirement that all command properties must be serializable
|
|
504
|
+
* as defined in {@link AnyCommand}.
|
|
218
505
|
*/
|
|
219
506
|
params?: {
|
|
220
507
|
[K in keyof TCommand]?: TCommand[K];
|
|
@@ -255,11 +542,65 @@ export type CommandMetadata = ConfigMetadata & {
|
|
|
255
542
|
id: keyof CommandRegistry | (string & {});
|
|
256
543
|
};
|
|
257
544
|
/**
|
|
258
|
-
*
|
|
545
|
+
* Decorator to register a class as a command with a unique identifier.
|
|
259
546
|
*
|
|
260
|
-
*
|
|
547
|
+
* The `@Command` decorator marks a class as a command and assigns it a unique ID
|
|
548
|
+
* that can be used for command lookup, registration, and execution. This decorator
|
|
549
|
+
* is essential for the command pattern implementation and enables type-safe command
|
|
550
|
+
* creation through the {@link CommandRegistry}.
|
|
551
|
+
*
|
|
552
|
+
* @param options - A {@link CommandOptions} object containing the unique command ID
|
|
553
|
+
* @returns Decorator function that registers the command class
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* ```typescript
|
|
557
|
+
* // Basic command definition
|
|
558
|
+
* @Command({ id: 'generate-pdf-report' })
|
|
559
|
+
* export class GeneratePdfReportCommand implements AnyCommand {
|
|
560
|
+
* public reportType: string;
|
|
561
|
+
* public includeCharts: boolean;
|
|
562
|
+
* }
|
|
563
|
+
* ```
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* // Single-object command with context
|
|
568
|
+
* @Command({ id: 'archive-deal' })
|
|
569
|
+
* export class ArchiveDealCommand implements LimeObjectCommand {
|
|
570
|
+
* public context: LimeWebComponentContext & { limetype: string; id: number };
|
|
571
|
+
* public reason: string;
|
|
572
|
+
* }
|
|
573
|
+
* ```
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* // Bulk command with filter
|
|
578
|
+
* @Command({ id: 'bulk-update-status' })
|
|
579
|
+
* export class BulkUpdateStatusCommand implements LimeObjectBulkCommand {
|
|
580
|
+
* public context: LimeWebComponentContext & { limetype: string };
|
|
581
|
+
* public filter: Expression | null;
|
|
582
|
+
* public newStatus: string;
|
|
583
|
+
* }
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* // Register in CommandRegistry for type safety
|
|
589
|
+
* declare module '@limetech/lime-web-components' {
|
|
590
|
+
* interface CommandRegistry {
|
|
591
|
+
* 'generate-pdf-report': GeneratePdfReportCommand;
|
|
592
|
+
* 'archive-deal': ArchiveDealCommand;
|
|
593
|
+
* 'bulk-update-status': BulkUpdateStatusCommand;
|
|
594
|
+
* }
|
|
595
|
+
* }
|
|
596
|
+
*
|
|
597
|
+
* // Now you can use createCommand with type safety
|
|
598
|
+
* const command = commandBus.createCommand({
|
|
599
|
+
* id: 'generate-pdf-report',
|
|
600
|
+
* params: { reportType: 'monthly', includeCharts: true }
|
|
601
|
+
* });
|
|
602
|
+
* ```
|
|
261
603
|
*
|
|
262
|
-
* @returns callback which accepts a `CommandClass` and sets the command id
|
|
263
604
|
* @public
|
|
264
605
|
* @group Command bus
|
|
265
606
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandbus.d.ts","sourceRoot":"","sources":["../../src/commandbus/commandbus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMtC
|
|
1
|
+
{"version":3,"file":"commandbus.d.ts","sourceRoot":"","sources":["../../src/commandbus/commandbus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,WAAW,UAAU;CAAG;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACjD;;;;;;OAMG;IACH,OAAO,EAAE,uBAAuB,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,MAAM,WAAW,qBAAsB,S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