@kosdev-code/kos-ui-sdk 2.0.32 → 2.0.34

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.
Files changed (82) hide show
  1. package/common/events/async-event-bus.d.ts +96 -0
  2. package/common/events/async-event-bus.d.ts.map +1 -0
  3. package/core/core/context/kos-context-manager.d.ts +1 -0
  4. package/core/core/context/kos-context-manager.d.ts.map +1 -1
  5. package/core/core/decorators/index.d.ts +1 -0
  6. package/core/core/decorators/index.d.ts.map +1 -1
  7. package/core/core/decorators/kos-http-decorators.d.ts +110 -0
  8. package/core/core/decorators/kos-http-decorators.d.ts.map +1 -0
  9. package/core/core/decorators/kos-topic-handler-flow-control.d.ts +130 -0
  10. package/core/core/decorators/kos-topic-handler-flow-control.d.ts.map +1 -0
  11. package/core/core/decorators/kosTopicHandler.d.ts +97 -3
  12. package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
  13. package/core/core/decorators/propKeys.d.ts +1 -0
  14. package/core/core/decorators/propKeys.d.ts.map +1 -1
  15. package/core/core/kosModel.d.ts +4 -0
  16. package/core/core/kosModel.d.ts.map +1 -1
  17. package/core/core/log/log.d.ts +3 -3
  18. package/core/core/log/log.d.ts.map +1 -1
  19. package/core/core/model/kos-http-route-manager.d.ts +85 -0
  20. package/core/core/model/kos-http-route-manager.d.ts.map +1 -0
  21. package/core/core/model/kos-model-component-factory.d.ts +2 -0
  22. package/core/core/model/kos-model-component-factory.d.ts.map +1 -1
  23. package/core/core/model/kos-subscription-manager.d.ts +11 -0
  24. package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
  25. package/core/core/model/model-introspection-utils.d.ts +1 -0
  26. package/core/core/model/model-introspection-utils.d.ts.map +1 -1
  27. package/core/core/model-instantiator.d.ts.map +1 -1
  28. package/core/core/services/app-startup-service.d.ts.map +1 -1
  29. package/core/core/services/browser-router.d.ts +20 -0
  30. package/core/core/services/browser-router.d.ts.map +1 -1
  31. package/core/core/services/index.d.ts +1 -0
  32. package/core/core/services/index.d.ts.map +1 -1
  33. package/core/util/feature-flags.d.ts +3 -0
  34. package/core/util/feature-flags.d.ts.map +1 -1
  35. package/core/util/kos-service-request.d.ts +1 -1
  36. package/core/util/kos-service-request.d.ts.map +1 -1
  37. package/index.cjs +73 -73
  38. package/index.cjs.map +1 -1
  39. package/index.d.cts +1 -0
  40. package/index.d.ts +1 -0
  41. package/index.d.ts.map +1 -1
  42. package/index.js +6709 -5689
  43. package/index.js.map +1 -1
  44. package/models/models/browser-router/browser-router-model.d.ts +20 -0
  45. package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
  46. package/models/models/canvas-dispatcher/canvas-dispatcher-model.d.ts +5 -1
  47. package/models/models/canvas-dispatcher/canvas-dispatcher-model.d.ts.map +1 -1
  48. package/models/models/canvas-dispatcher/types/index.d.ts +25 -3
  49. package/models/models/canvas-dispatcher/utils/renderers/looping-video-renderer.d.ts +30 -0
  50. package/models/models/canvas-dispatcher/utils/renderers/looping-video-renderer.d.ts.map +1 -0
  51. package/models/models/canvas-dispatcher/utils/renderers/renderer-factory.d.ts.map +1 -1
  52. package/models/models/canvas-dispatcher/utils/renderers/sequence-renderer.d.ts +46 -0
  53. package/models/models/canvas-dispatcher/utils/renderers/sequence-renderer.d.ts.map +1 -0
  54. package/models/models/canvas-renderer/canvas-renderer-model.d.ts.map +1 -1
  55. package/models/models/index.d.ts +1 -0
  56. package/models/models/index.d.ts.map +1 -1
  57. package/models/models/kos-log-manager/index.d.ts +5 -0
  58. package/models/models/kos-log-manager/index.d.ts.map +1 -0
  59. package/models/models/kos-log-manager/kos-log-manager-model.d.ts +92 -0
  60. package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -0
  61. package/models/models/kos-log-manager/kos-log-manager-registration.d.ts +92 -0
  62. package/models/models/kos-log-manager/kos-log-manager-registration.d.ts.map +1 -0
  63. package/models/models/kos-log-manager/services/index.d.ts +2 -0
  64. package/models/models/kos-log-manager/services/index.d.ts.map +1 -0
  65. package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts +12 -0
  66. package/models/models/kos-log-manager/services/kos-log-manager-services.d.ts.map +1 -0
  67. package/models/models/kos-log-manager/types/index.d.ts +14 -0
  68. package/models/models/studio-properties/services/studio-properties-services.d.ts +3 -3
  69. package/models/models/studio-properties/services/studio-properties-services.d.ts.map +1 -1
  70. package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
  71. package/models/models/trouble/index.d.ts +1 -0
  72. package/models/models/trouble/index.d.ts.map +1 -1
  73. package/models/models/trouble/trouble-model.d.ts.map +1 -1
  74. package/models/models/trouble/types/index.d.ts +353 -9
  75. package/models/models/trouble/utils/is-trouble-aware.d.ts +98 -0
  76. package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -0
  77. package/models/utils/client.d.ts +5 -1
  78. package/models/utils/client.d.ts.map +1 -1
  79. package/models/utils/core-registration-manager.d.ts.map +1 -1
  80. package/models/utils/service.d.ts +11 -6
  81. package/models/utils/service.d.ts.map +1 -1
  82. package/package.json +2 -2
@@ -3,98 +3,442 @@ import { FutureResponse } from '../../../services/future';
3
3
  import { IKosDataModel } from '../../../core';
4
4
 
5
5
 
6
+ /**
7
+ * Configuration options for creating or updating a Trouble model.
8
+ *
9
+ * This interface defines all the properties that can be set when initializing
10
+ * a trouble instance. Troubles represent issues, alerts, or conditions that
11
+ * require attention in the KOS system.
12
+ *
13
+ * @template AdditionalData - Optional type parameter for domain-specific trouble data
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const troubleOptions: TroubleOptions = {
18
+ * id: 'low-fluid-001',
19
+ * type: 'FLUID_LEVEL',
20
+ * reason: 'Fluid level below minimum threshold',
21
+ * rank: 7,
22
+ * role: 'operator',
23
+ * color: 'orange',
24
+ * resolvable: true,
25
+ * ifaces: ['fluid-monitor', 'alert-system'],
26
+ * tags: ['maintenance', 'fluid', 'warning'],
27
+ * createTime: new Date().toISOString()
28
+ * };
29
+ * ```
30
+ *
31
+ * @category Trouble Management
32
+ * @subcategory Types
33
+ */
6
34
  export interface TroubleOptions<AdditionalData extends object = any> {
35
+ /** Whether this trouble can be resolved through user action */
7
36
  resolvable?: boolean;
37
+ /** Human-readable description of why the trouble occurred */
8
38
  reason?: string;
39
+ /** ISO timestamp when the trouble was created */
9
40
  createTime?: string;
41
+ /** List of interface identifiers this trouble affects */
10
42
  ifaces: string[];
43
+ /** Unique identifier for the trouble instance */
11
44
  id: string;
45
+ /** Priority rank from 1-10 (10 being most critical) */
12
46
  rank: number;
47
+ /** User role required to view/resolve this trouble */
13
48
  role: string;
49
+ /** Display color for UI representation (e.g., 'red', 'yellow', 'orange') */
14
50
  color: string;
51
+ /** Client-specific data attached to the trouble */
15
52
  clientData: unknown;
53
+ /** Classification type of the trouble (e.g., 'ERROR', 'WARNING', 'INFO') */
16
54
  type: string;
55
+ /** Searchable tags for categorizing troubles */
17
56
  tags: string[];
57
+ /** Additional information about the trouble state */
18
58
  info: unknown;
59
+ /** Optional grouping identifier for related troubles */
19
60
  group?: string;
61
+ /** Index signature for additional domain-specific data */
20
62
  [key: keyof AdditionalData]: AdditionalData[key];
21
63
  }
22
64
 
23
65
  /**
24
- * Trouble Model
25
- * @category Model
66
+ * Represents a trouble (issue, alert, or condition) in the KOS system.
67
+ *
68
+ * TroubleModel is the core interface for managing system issues, warnings, and
69
+ * alerts throughout the KOS platform. It provides a unified way to track,
70
+ * display, resolve, and defer various types of operational issues.
71
+ *
72
+ * ## Key Features
73
+ * - **Priority ranking** - Troubles are ranked 1-10 for severity
74
+ * - **Role-based visibility** - Troubles can be filtered by user role
75
+ * - **Resolution support** - Resolvable troubles can be cleared through actions
76
+ * - **Deferral capability** - Troubles can be temporarily deferred
77
+ * - **Future integration** - Async resolution through futures
78
+ * - **Type categorization** - Troubles grouped by type for filtering
79
+ * - **Visual indicators** - Color coding for UI representation
80
+ *
81
+ * @template AdditionalData - Type parameter for domain-specific trouble data
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Check trouble severity
86
+ * function handleTrouble(trouble: TroubleModel) {
87
+ * if (trouble.rank >= 8) {
88
+ * console.error(`Critical trouble: ${trouble.reason}`);
89
+ * notifyOperator(trouble);
90
+ * } else if (trouble.rank >= 5) {
91
+ * console.warn(`Warning: ${trouble.reason}`);
92
+ * }
93
+ *
94
+ * // Check if user can resolve
95
+ * if (trouble.resolvable && hasRole(trouble.role)) {
96
+ * showResolveButton(trouble);
97
+ * }
98
+ * }
99
+ * ```
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * // Resolve a trouble with proper future handling
104
+ * async function resolveTrouble(trouble: TroubleModel) {
105
+ * if (!trouble.resolvable) {
106
+ * throw new Error('Trouble is not resolvable');
107
+ * }
108
+ *
109
+ * try {
110
+ * // Resolution returns a FutureResponse with future tracking
111
+ * const futureResponse = await trouble.resolve();
112
+ * if (futureResponse) {
113
+ * console.log(`Resolution started, future ID: ${futureResponse.id}`);
114
+ *
115
+ * // The trouble's future property will be updated with the resolution future
116
+ * // You can track progress through the future model
117
+ * if (trouble.future) {
118
+ * const endState = await trouble.future.waitForCompletion();
119
+ * if (endState === 'COMPLETED') {
120
+ * console.log('Trouble resolved successfully');
121
+ * } else if (endState === 'FAILED') {
122
+ * console.error('Resolution failed');
123
+ * }
124
+ * }
125
+ * }
126
+ * } catch (error) {
127
+ * console.error('Failed to initiate resolution:', error);
128
+ * }
129
+ * }
130
+ * ```
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * // Using cancellable promise utilities with trouble resolution
135
+ * import { createCancellablePromise } from '@kosdev-code/kos-ui-sdk';
136
+ *
137
+ * async function resolveTroubleWithCancel(trouble: TroubleModel) {
138
+ * const futureResponse = await trouble.resolve();
139
+ *
140
+ * if (futureResponse && trouble.future) {
141
+ * // Create a cancellable promise for the resolution
142
+ * const cancellableResolve = createCancellablePromise(
143
+ * trouble.future.waitForCompletion(),
144
+ * undefined,
145
+ * () => trouble.future?.cancelFuture(),
146
+ * trouble.future
147
+ * );
148
+ *
149
+ * // Subscribe to progress updates
150
+ * const unsubscribe = cancellableResolve.onProgressUpdate((progress, status) => {
151
+ * console.log(`Resolution progress: ${(progress * 100).toFixed(0)}% - ${status}`);
152
+ * });
153
+ *
154
+ * try {
155
+ * const endState = await cancellableResolve;
156
+ * console.log(`Resolution completed with state: ${endState}`);
157
+ * } catch (error) {
158
+ * if (cancellableResolve.isCancelled()) {
159
+ * console.log('Resolution was cancelled');
160
+ * } else {
161
+ * console.error('Resolution failed:', error);
162
+ * }
163
+ * } finally {
164
+ * unsubscribe();
165
+ * }
166
+ * }
167
+ * }
168
+ * ```
169
+ *
170
+ *
171
+ * @category KOS Model
172
+ * @subcategory Trouble Management
173
+ *
174
+ * @see {@link TroubleAware} - Interface for models that can have troubles
175
+ * @see {@link DeferAware} - Deferral capabilities
176
+ * @see {@link ResolveAware} - Resolution capabilities
26
177
  */
27
178
  export interface TroubleModel<AdditionalData extends object = any>
28
179
  extends IKosDataModel,
29
180
  DeferAware,
30
181
  FutureContainer {
182
+ /** Unique identifier for the trouble instance */
31
183
  id: string;
184
+ /** Whether this trouble can be resolved through user action */
32
185
  resolvable?: boolean;
186
+ /** Human-readable description of why the trouble occurred */
33
187
  reason?: string;
188
+ /** ISO timestamp when the trouble was created */
34
189
  createTime?: string;
190
+ /** List of interface identifiers this trouble affects */
35
191
  ifaces: string[];
36
- id: string;
192
+ /** Client-specific data attached to the trouble */
37
193
  clientData: unknown;
194
+ /** Associated future for async resolution operations */
38
195
  future?: IFutureModel;
196
+ /** Classification type of the trouble (e.g., 'ERROR', 'WARNING', 'INFO') */
39
197
  type: string;
198
+ /** Searchable tags for categorizing troubles */
40
199
  tags: string[];
200
+ /** Additional information about the trouble state */
41
201
  info: unknown;
202
+ /** Original trouble ID before any transformations */
42
203
  rawId: string;
204
+ /** Resolves the trouble, returning a promise with the resolution response */
43
205
  resolve: () => Promise<FutureResponse | undefined>;
206
+ /** Domain-specific additional data attached to the trouble */
44
207
  data: AdditionalData;
208
+ /** Priority rank from 1-10 (10 being most critical) */
45
209
  rank: number;
210
+ /** User role required to view/resolve this trouble */
46
211
  role: string;
212
+ /** Display color for UI representation (e.g., 'red', 'yellow', 'orange') */
47
213
  color: string;
214
+ /** Whether this trouble has been deferred */
48
215
  deferred: boolean;
216
+ /** Optional grouping identifier for related troubles */
49
217
  group?: string;
50
218
  }
51
219
 
220
+ /**
221
+ * Domain-specific trouble data for handle-related issues.
222
+ *
223
+ * @category Trouble Management
224
+ * @subcategory Domain Data
225
+ */
52
226
  export interface HandleTroubleData {
227
+ /** Path to the affected handle component */
53
228
  path: string;
54
229
  }
55
230
 
231
+ /**
232
+ * Domain-specific trouble data for nozzle-related issues.
233
+ *
234
+ * @category Trouble Management
235
+ * @subcategory Domain Data
236
+ */
56
237
  export interface NozzleTroubleData {
238
+ /** Path to the affected nozzle component */
57
239
  nozzlePath: string;
58
240
  }
59
241
 
242
+ /**
243
+ * Domain-specific trouble data for container-related issues.
244
+ *
245
+ * @category Trouble Management
246
+ * @subcategory Domain Data
247
+ */
60
248
  export interface ContainerTroubleData {
249
+ /** Identifier of the affected container */
61
250
  containerId: string;
251
+ /** List of ingredients involved in the trouble */
62
252
  ingredients: string[];
63
253
  }
64
254
 
255
+ /**
256
+ * Interface for objects that can be resolved asynchronously.
257
+ *
258
+ * Provides a standard resolution mechanism for troubles and other
259
+ * resolvable conditions in the KOS system. Resolution typically
260
+ * involves sending a command to clear the condition.
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * class ResolvableTrouble implements ResolveAware {
265
+ * async resolve(tracker?: string) {
266
+ * console.log(`Resolving with tracker: ${tracker}`);
267
+ * const response = await sendResolveCommand(this.id, tracker);
268
+ * return response;
269
+ * }
270
+ * }
271
+ * ```
272
+ *
273
+ * @category Trouble Management
274
+ * @subcategory Capabilities
275
+ */
65
276
  export interface ResolveAware {
277
+ /**
278
+ * Resolves the condition asynchronously.
279
+ *
280
+ * @param tracker - Optional tracking identifier for the resolution operation
281
+ * @returns Promise resolving to the future response, or undefined if resolution fails
282
+ */
66
283
  resolve: (tracker?: string) => Promise<FutureResponse | undefined>;
67
284
  }
68
285
 
286
+ /**
287
+ * Interface for objects that support deferral of actions.
288
+ *
289
+ * Deferral allows temporary postponement of trouble handling or
290
+ * other actions. Deferred items can be cleared to restore normal
291
+ * processing. This is useful for managing low-priority issues
292
+ * during critical operations.
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * class DeferrableTrouble implements DeferAware {
297
+ * shouldDefer = false;
298
+ * deferred = false;
299
+ *
300
+ * defer() {
301
+ * this.deferred = true;
302
+ * console.log('Trouble deferred');
303
+ * }
304
+ *
305
+ * clearDefer() {
306
+ * this.deferred = false;
307
+ * console.log('Deferral cleared');
308
+ * }
309
+ * }
310
+ *
311
+ * // Usage
312
+ * if (trouble.shouldDefer && !trouble.deferred) {
313
+ * trouble.defer();
314
+ * }
315
+ * ```
316
+ *
317
+ * @category Trouble Management
318
+ * @subcategory Capabilities
319
+ */
69
320
  export interface DeferAware {
321
+ /** Whether this item should be deferred based on current conditions */
70
322
  shouldDefer: boolean;
323
+ /** Current deferral state */
71
324
  deferred: boolean;
325
+ /** Defers the item, preventing normal processing */
72
326
  defer: VoidFunction;
327
+ /** Clears the deferral, allowing normal processing to resume */
73
328
  clearDefer: VoidFunction;
74
329
  }
75
330
  /**
76
- * Provides a common interface for all trouble containers
331
+ * Interface for models that can track and expose trouble states.
332
+ *
333
+ * TroubleAware provides a standardized way for KOS models to expose
334
+ * their trouble states, making it easy to monitor, display, and react
335
+ * to issues throughout the system. Any model implementing this interface
336
+ * can be monitored for troubles and integrated with trouble management UI.
337
+ *
338
+ * ## Key Concepts
339
+ * - **Trouble aggregation** - Models can aggregate troubles from multiple sources
340
+ * - **Status summary** - Provides a single status string for quick checks
341
+ * - **Type grouping** - Troubles organized by type for filtering and display
342
+ * - **Read-only access** - Troubles are exposed as readonly for safety
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * // Check if a model has troubles
347
+ * function checkModelHealth(model: TroubleAware) {
348
+ * if (model.troubles.length > 0) {
349
+ * console.warn(`Model has ${model.troubles.length} troubles`);
350
+ * console.warn(`Status: ${model.troubleStatus}`);
351
+ *
352
+ * // Check specific trouble types
353
+ * const errors = model.troublesByType['ERROR'] || [];
354
+ * const warnings = model.troublesByType['WARNING'] || [];
355
+ *
356
+ * if (errors.length > 0) {
357
+ * handleCriticalErrors(errors);
358
+ * }
359
+ * }
360
+ * }
361
+ * ```
362
+ *
363
+ * @example
364
+ * ```typescript
365
+ * // React component using TroubleAware
366
+ * const TroubleIndicator: React.FC<{ model: TroubleAware }> = ({ model }) => {
367
+ * const troubles = model.troubles;
368
+ * const highPriority = troubles.filter(t => t.rank >= 7);
369
+ *
370
+ * if (troubles.length === 0) {
371
+ * return <StatusIcon color="green" />;
372
+ * }
373
+ *
374
+ * return (
375
+ * <div className="trouble-indicator">
376
+ * <StatusIcon color={highPriority.length > 0 ? 'red' : 'yellow'} />
377
+ * <span>{model.troubleStatus}</span>
378
+ * <Badge count={troubles.length} />
379
+ * </div>
380
+ * );
381
+ * };
382
+ * ```
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * // Implementing TroubleAware
387
+ * class MyModel implements TroubleAware {
388
+ * private _troubles: TroubleModel[] = [];
77
389
  *
78
- * Allows a model to expose the troubles that are directly related to it.
79
- * Also provides a standard interface to get the status of the highest priority trouble.
390
+ * get troubles(): readonly TroubleModel[] {
391
+ * return this._troubles;
392
+ * }
80
393
  *
394
+ * get troubleStatus(): string {
395
+ * if (this._troubles.length === 0) return 'OK';
396
+ * const highest = this._troubles.reduce((max, t) =>
397
+ * t.rank > max.rank ? t : max
398
+ * );
399
+ * return highest.reason || 'Unknown issue';
400
+ * }
81
401
  *
402
+ * get troublesByType(): Record<string, TroubleModel[]> {
403
+ * return this._troubles.reduce((groups, trouble) => {
404
+ * const type = trouble.type;
405
+ * groups[type] = groups[type] || [];
406
+ * groups[type].push(trouble);
407
+ * return groups;
408
+ * }, {} as Record<string, TroubleModel[]>);
409
+ * }
410
+ * }
411
+ * ```
82
412
  *
413
+ * @category Trouble Management
414
+ * @subcategory Interfaces
83
415
  *
416
+ * @see {@link TroubleModel} - The trouble model interface
417
+ * @see {@link isTroubleAware} - Type guard for checking TroubleAware
418
+ * @see {@link useTroubleDecoration} - Hook for trouble-based styling
84
419
  */
85
420
  export interface TroubleAware {
86
421
  /**
87
- * Returns the troubles that are directly related to this model.
422
+ * Array of troubles directly related to this model.
423
+ * Troubles are typically sorted by rank (highest priority first).
88
424
  */
89
425
  readonly troubles: TroubleModel[];
90
426
 
91
427
  /**
92
- * Returns the highest priority trouble status.
428
+ * Summary status string representing the highest priority trouble.
429
+ * Returns a human-readable status or 'OK' if no troubles exist.
93
430
  */
94
431
  readonly troubleStatus: string;
95
432
 
96
433
  /**
97
- * Returns the troubles that are directly related to this model, grouped by type.
434
+ * Troubles organized by their type property.
435
+ * Useful for filtering and categorized display of issues.
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * const errorTroubles = model.troublesByType['ERROR'] || [];
440
+ * const warningTroubles = model.troublesByType['WARNING'] || [];
441
+ * ```
98
442
  */
99
443
  readonly troublesByType: Record<string, TroubleModel[]>;
100
444
  }
@@ -0,0 +1,98 @@
1
+ import { TroubleAware } from '../types';
2
+
3
+ /**
4
+ * Type guard function to check if an object implements the TroubleAware interface.
5
+ *
6
+ * This function performs runtime validation to determine whether a given object
7
+ * has the necessary properties and structure to be considered trouble-aware.
8
+ * It checks for the presence of both the `troubles` array and `troublesByType`
9
+ * object, which are required by the TroubleAware interface.
10
+ *
11
+ * @category Utilities
12
+ * @subcategory Trouble Management
13
+ *
14
+ * @param obj - The object to check for trouble awareness. Can be any type.
15
+ *
16
+ * @returns `true` if the object implements TroubleAware interface, `false` otherwise.
17
+ * When this function returns true, TypeScript will narrow the type of `obj`
18
+ * to `TroubleAware` in the current scope.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Basic type guard usage
23
+ * function processModel(model: IKosDataModel) {
24
+ * if (isTroubleAware(model)) {
25
+ * // TypeScript now knows model has troubles property
26
+ * console.log(`Found ${model.troubles.length} troubles`);
27
+ * console.log(`Trouble status: ${model.troubleStatus}`);
28
+ * } else {
29
+ * console.log('Model is not trouble-aware');
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // Using with React hooks for conditional trouble handling
37
+ * const TroubleDisplay: React.FC<{ model: IKosDataModel }> = ({ model }) => {
38
+ * if (!isTroubleAware(model)) {
39
+ * return <div>No trouble tracking available</div>;
40
+ * }
41
+ *
42
+ * // Safe to access trouble properties here
43
+ * const criticalTroubles = model.troubles.filter(t => t.rank > 8);
44
+ * const troubleTypes = Object.keys(model.troublesByType);
45
+ *
46
+ * return (
47
+ * <div>
48
+ * <h3>Trouble Status: {model.troubleStatus}</h3>
49
+ * <p>Critical issues: {criticalTroubles.length}</p>
50
+ * <p>Types: {troubleTypes.join(', ')}</p>
51
+ * </div>
52
+ * );
53
+ * };
54
+ * ```
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Filtering trouble-aware models from a collection
59
+ * const models: IKosDataModel[] = getAllModels();
60
+ * const troubleAwareModels = models.filter(isTroubleAware);
61
+ *
62
+ * // TypeScript knows troubleAwareModels is TroubleAware[]
63
+ * troubleAwareModels.forEach(model => {
64
+ * const troublesByType = model.troublesByType;
65
+ * Object.entries(troublesByType).forEach(([type, troubles]) => {
66
+ * console.log(`Type ${type}: ${troubles.length} troubles`);
67
+ * });
68
+ * });
69
+ * ```
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // Early return pattern for non-trouble-aware models
74
+ * function calculateTroubleSeverity(model: any): number {
75
+ * if (!isTroubleAware(model)) {
76
+ * return 0; // No troubles means no severity
77
+ * }
78
+ *
79
+ * // Calculate weighted severity based on trouble ranks
80
+ * return model.troubles.reduce((total, trouble) => {
81
+ * return total + (trouble.rank * (trouble.deferred ? 0.5 : 1));
82
+ * }, 0);
83
+ * }
84
+ * ```
85
+ *
86
+ * @remarks
87
+ * - This is a runtime check, not a compile-time check
88
+ * - The function checks for structural compatibility, not nominal typing
89
+ * - It validates that `troubles` is specifically an Array instance, not just array-like
90
+ * - The `troublesByType` property must be an object (not null or undefined)
91
+ * - Does not validate the contents of the arrays or object, only their presence and type
92
+ * - This function is commonly used as a guard before accessing trouble-related properties
93
+ *
94
+ * @see {@link TroubleAware} - The interface this function checks for
95
+ * @see {@link useTroubleDecoration} - Hook that uses this guard internally
96
+ */
97
+ export declare function isTroubleAware(obj: any): obj is TroubleAware;
98
+ //# sourceMappingURL=is-trouble-aware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-trouble-aware.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/trouble/utils/is-trouble-aware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY,CAO5D"}
@@ -57,7 +57,11 @@ export declare const api: {
57
57
  } | undefined) => Promise<import('../../core').ServiceResponse<ClientResponse<paths, K_2, "put">>>;
58
58
  delete: <K_3 extends "/api/ext/dispense/nozzle/nozzle/pipeline/beverage/select" | "/api/app/kosdev.ddk/copyLogs/{id}" | "/api/ext/dispense/metrics/{name}" | "/api/ext/dispense/metrics/{nozzle}/{name}" | "/api/ext/dispense/assignments/{holderPath}" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests/{manifestId}" | "/api/kos/nodeMgr/blockedManifests/{manifestId}" | "/api/kos/criticalData/data/{name}" | "/api/app/tccc.fits/medusa/profiles/{profileId}" | "/api/app/tccc.fits/medusa/profiles/{profileId}/recipes/{name}" | "/api/app/tccc.fits/medusa/profiles/{profileId}/tests/{testId}" | "/api/app/tccc.fits/medusa/profiles/{profileId}/builder/blocks" | "/api/app/tccc.fits/medusa/profiles/{profileId}/builder/bevs/{bevId}" | "/api/app/tccc.fits/medusa/profiles/{profileId}/results/{resultsId}" | "/api/app/tccc.fits/scales/{serialNum}" | "/api/app/tccc.fits.sim/scales/{serialNum}" | "/api/app/tccc.fits/session/data/{key}">(endpoint: K_3, params?: (paths[K_3]["delete"] extends {
59
59
  parameters: infer P_3;
60
- } ? P_3 : never) | undefined, options?: {
60
+ } ? P_3 : never) | undefined, body?: (paths[K_3]["put"] extends {
61
+ requestBody: {
62
+ content: infer B_1;
63
+ };
64
+ } ? B_1[keyof B_1] : never) | undefined, options?: {
61
65
  ordered?: boolean | undefined;
62
66
  tracker?: string | undefined;
63
67
  timeout?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/models/utils/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEzC,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,MAAM,KAAK,EACrB,CAAC,SAAS,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAClC,cAAc,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/models/utils/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEzC,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,MAAM,KAAK,EACrB,CAAC,SAAS,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAClC,cAAc,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"core-registration-manager.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/models/utils/core-registration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAkBpB,eAAO,MAAM,kBAAkB,YACnB,CAAC;;;;;CA6BV,CAAC;AAEJ,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC;IAC9C,OAAO,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACnE,KAAK,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7D,SAAS,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;CACtE,CAAC;AAEF,QAAA,MAAM,iBAAiB,IAAK,CAAC;AAc7B,KAAK,oBAAoB,GAAG,aAAa,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEpE,QAAA,MAAM,gBAAgB,EAAE,oBAA+C,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"core-registration-manager.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/models/utils/core-registration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAkBpB,eAAO,MAAM,kBAAkB,YACnB,CAAC;;;;;CA8BV,CAAC;AAEJ,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC;IAC9C,OAAO,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACnE,KAAK,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7D,SAAS,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;CACtE,CAAC;AAEF,QAAA,MAAM,iBAAiB,IAAK,CAAC;AAc7B,KAAK,oBAAoB,GAAG,aAAa,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEpE,QAAA,MAAM,gBAAgB,EAAE,oBAA+C,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,CAAC"}