@kosdev-code/kos-ui-sdk 2.1.4 → 2.1.6

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.
@@ -3,6 +3,7 @@ export * from './kos-companion';
3
3
  export * from './kos-container-aware';
4
4
  export * from './kos-context';
5
5
  export * from './kos-future-aware';
6
+ export * from './kos-multiple-future-aware';
6
7
  export * from './kos-http-decorators';
7
8
  export * from './kos-log';
8
9
  export * from './kos-logger-aware';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,193 @@
1
+ import { IFutureModel } from '../../../models/models/future/future-types';
2
+ import { MultipleFutureHandler } from '../../../models/models/future/future-aware';
3
+
4
+ export interface KosMultipleFutureAwareOptions {
5
+ /** Setup mode: 'full' includes all UI properties, 'minimal' only futureHandler. Default: 'full' */
6
+ mode?: "full" | "minimal";
7
+ /** Custom futureHandler property name. Default: 'futureHandler' */
8
+ handlerProperty?: string;
9
+ }
10
+ /**
11
+ * Interface for models using @kosMultipleFutureAware in minimal mode.
12
+ * Use TypeScript interface merging to add the futureHandler property and named futures to your model class.
13
+ *
14
+ * @example
15
+ * Add ESLint disable comment at top of file, then:
16
+ * ```typescript
17
+ * interface MaintenanceModelImpl extends KosMultipleFutureAwareMinimal {
18
+ * // Add your specific named futures manually for strong typing:
19
+ * calibrationFuture?: IFutureModel;
20
+ * cleaningFuture?: IFutureModel;
21
+ * }
22
+ *
23
+ * @kosMultipleFutureAware({ mode: 'minimal' })
24
+ * class MaintenanceModelImpl implements IKosDataModel {
25
+ * // futureHandler and named futures are now available via interface merging
26
+ * }
27
+ * ```
28
+ */
29
+ export interface KosMultipleFutureAwareMinimal {
30
+ /**
31
+ * Core multiple future management container that handles concurrent Future lifecycle operations.
32
+ * Provides methods to add, remove, and query multiple Future instances.
33
+ * Automatically injected by @kosMultipleFutureAware decorator.
34
+ */
35
+ futureHandler: MultipleFutureHandler;
36
+ /**
37
+ * Default future from the handler.
38
+ * Returns the most recently added future or undefined if no futures are active.
39
+ */
40
+ future?: IFutureModel;
41
+ }
42
+ /**
43
+ * Utility types to generate future property names for multiple futures (for internal use)
44
+ */
45
+ type FutureGetters<T extends string> = {
46
+ readonly [K in T as `${K}Future`]?: IFutureModel;
47
+ };
48
+ type ProgressGetters<T extends string> = {
49
+ readonly [K in T as `${K}Progress`]: number;
50
+ };
51
+ type StatusGetters<T extends string> = {
52
+ readonly [K in T as `${K}Status`]: string;
53
+ };
54
+ type IsRunningGetters<T extends string> = {
55
+ readonly [K in T as `${K}IsRunning`]: boolean;
56
+ };
57
+ type IsCancelledGetters<T extends string> = {
58
+ readonly [K in T as `${K}IsCancelled`]: boolean;
59
+ };
60
+ type CancelMethods<T extends string> = {
61
+ readonly [K in T as `cancel${Capitalize<K>}`]: () => Promise<void>;
62
+ };
63
+ export type MultipleFutureProperties<T extends string> = FutureGetters<T> & ProgressGetters<T> & StatusGetters<T> & IsRunningGetters<T> & IsCancelledGetters<T> & CancelMethods<T>;
64
+ /**
65
+ * Interface for models using @kosMultipleFutureAware in full mode (default).
66
+ * Use TypeScript interface merging to add all Future Container properties and named futures to your model class.
67
+ *
68
+ * @example
69
+ * Add ESLint disable comment at top of file, then:
70
+ * ```typescript
71
+ * interface IceAgitatorModelImpl extends KosMultipleFutureAwareFull<"pour" | "agitate" | "gate"> {}
72
+ *
73
+ * @kosMultipleFutureAware() // defaults to full mode
74
+ * class IceAgitatorModelImpl implements IKosDataModel {
75
+ * // All Future Container properties and named futures are now available automatically
76
+ * // Access: this.pourFuture, this.agitateFuture, this.gateFuture
77
+ *
78
+ * onFutureUpdate?(future: IFutureModel): void {
79
+ * // Handle updates from any managed Future
80
+ * }
81
+ * }
82
+ * ```
83
+ */
84
+ export type KosMultipleFutureAwareFull<T extends string = string> = KosMultipleFutureAwareMinimal & MultipleFutureProperties<T> & {
85
+ /**
86
+ * Current operation progress as a percentage (0-100) for the default future.
87
+ * Returns 0 when no default Future is active. Updates automatically as the
88
+ * Future operation progresses via WebSocket events.
89
+ */
90
+ progress: number;
91
+ /**
92
+ * Current operation status string representation for the default future.
93
+ * Common values: "IDLE", "IN_PROGRESS", "SUCCESS", "ERROR", "CANCELLED".
94
+ * Returns "IDLE" when no default Future is active.
95
+ */
96
+ status: string;
97
+ /**
98
+ * Whether the default operation is currently actively executing.
99
+ * True when default Future exists and has not reached an end state.
100
+ * False when no Future exists or operation has completed/failed/cancelled.
101
+ */
102
+ isRunning: boolean;
103
+ /**
104
+ * Whether the current or most recent default operation was cancelled.
105
+ * Remains true after cancellation for status tracking until a new
106
+ * operation starts. False if operation completed normally or failed.
107
+ */
108
+ isCancelled: boolean;
109
+ /**
110
+ * Cancels the currently running default Future operation.
111
+ * Sends cancellation request to the backend service managing the Future.
112
+ * No-op if no default Future is currently active.
113
+ * @returns Promise that resolves when cancellation is acknowledged
114
+ * @throws Error if cancellation request fails
115
+ */
116
+ cancelFuture(): Promise<void>;
117
+ };
118
+ /**
119
+ * Class decorator that automatically adds Multiple Future Container capabilities to a KOS model.
120
+ *
121
+ * This decorator eliminates the need for manual MultipleFutureHandler setup by:
122
+ * - Adding a futureHandler property for managing multiple concurrent Future operations
123
+ * - Adding reactive getters for default future, progress, status, isRunning, isCancelled (in full mode)
124
+ * - Adding dynamic named future getters based on @kosFuture aliases
125
+ * - Adding cancelFuture method for canceling the default operation (in full mode)
126
+ *
127
+ * **Important**: Use TypeScript interface merging to get proper type information:
128
+ *
129
+ * ```typescript
130
+ * // Add ESLint disable comment at top of file, then:
131
+ * interface MyModelImpl extends KosMultipleFutureAwareFull<"operation1" | "operation2"> {}
132
+ *
133
+ * @kosMultipleFutureAware()
134
+ * class MyModelImpl implements IKosDataModel {
135
+ * // All Future properties and named futures are now available with full type safety
136
+ * }
137
+ * ```
138
+ *
139
+ * Note: This decorator supports multiple concurrent Future operations. For models that only need
140
+ * single Future support, use @kosFutureAware instead.
141
+ *
142
+ * @param options Configuration options for the decorator
143
+ * @returns A class decorator
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * // Full mode example with multiple futures
148
+ * interface IceAgitatorModelImpl extends KosMultipleFutureAwareFull<"pour" | "agitate" | "gate"> {}
149
+ *
150
+ * @kosMultipleFutureAware()
151
+ * class IceAgitatorModelImpl implements IKosDataModel {
152
+ * get isPouring() {
153
+ * return !!(this.pourFuture && !this.pourFuture?.endState);
154
+ * }
155
+ *
156
+ * onFutureUpdate?(future: IFutureModel): void {
157
+ * // Handle Future updates from any operation
158
+ * }
159
+ *
160
+ * @kosFuture({ alias: "pour" })
161
+ * async pourIce(): Promise<void> {
162
+ * // Pour operation
163
+ * }
164
+ *
165
+ * @kosFuture({ alias: "agitate" })
166
+ * async testAgitate(): Promise<void> {
167
+ * // Agitation operation
168
+ * }
169
+ * }
170
+ *
171
+ * // Minimal mode example
172
+ * interface BackgroundServiceModelImpl extends KosMultipleFutureAwareMinimal<"task1" | "task2"> {}
173
+ *
174
+ * @kosMultipleFutureAware({ mode: 'minimal' })
175
+ * class BackgroundServiceModelImpl implements IKosDataModel {
176
+ * @kosFuture({ alias: "task1" })
177
+ * async backgroundTask1() {
178
+ * return "done";
179
+ * }
180
+ *
181
+ * @kosFuture({ alias: "task2" })
182
+ * async backgroundTask2() {
183
+ * return "done";
184
+ * }
185
+ * }
186
+ * ```
187
+ *
188
+ * @category KOS Model Decorator
189
+ * @since 2.0.0
190
+ */
191
+ export declare function kosMultipleFutureAware(options?: KosMultipleFutureAwareOptions): ClassDecorator;
192
+ export {};
193
+ //# sourceMappingURL=kos-multiple-future-aware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kos-multiple-future-aware.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kos-multiple-future-aware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAG/E,MAAM,WAAW,6BAA6B;IAC5C,mGAAmG;IACnG,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;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,CAAC,GACrB,aAAa,CAAC,CAAC,CAAC,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAC9D,6BAA6B,GAC3B,wBAAwB,CAAC,CAAC,CAAC,GAAG;IAC5B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;;;;OAMG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,6BAA6B,GACtC,cAAc,CAchB"}
@@ -1 +1 @@
1
- {"version":3,"file":"kosModel.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kosModel.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA8b5C,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAqDjD"}
1
+ {"version":3,"file":"kosModel.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kosModel.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAykB5C,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAqDjD"}
@@ -12,6 +12,8 @@ export declare const KosModelSymbol: unique symbol;
12
12
  export declare const ModelEffects: unique symbol;
13
13
  export declare const CompanionParentModel: unique symbol;
14
14
  export declare const FutureContainerSetup: unique symbol;
15
+ export declare const MultipleFutureContainerSetup: unique symbol;
16
+ export declare const FutureAliases: unique symbol;
15
17
  export declare const TroubleAwareSetup: unique symbol;
16
18
  export declare const LoggerSetup: unique symbol;
17
19
  export declare const ContainerAwareSetup: unique symbol;
@@ -1 +1 @@
1
- {"version":3,"file":"propKeys.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/propKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,SAAS,eAAsB,CAAC;AAC7C,eAAO,MAAM,eAAe,eAA4B,CAAC;AACzD,eAAO,MAAM,cAAc,eAA2B,CAAC;AACvD,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAC7D,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,mBAAmB,eAAgC,CAAC"}
1
+ {"version":3,"file":"propKeys.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/propKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,SAAS,eAAsB,CAAC;AAC7C,eAAO,MAAM,eAAe,eAA4B,CAAC;AACzD,eAAO,MAAM,cAAc,eAA2B,CAAC;AACvD,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,4BAA4B,eAExC,CAAC;AACF,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAC7D,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,mBAAmB,eAAgC,CAAC"}