@kosdev-code/kos-ui-sdk 2.0.41 → 2.1.1
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/core/core/decorators/index.d.ts +4 -0
- package/core/core/decorators/index.d.ts.map +1 -1
- package/core/core/decorators/kos-companion.d.ts +125 -8
- package/core/core/decorators/kos-companion.d.ts.map +1 -1
- package/core/core/decorators/kos-container-aware.d.ts +465 -0
- package/core/core/decorators/kos-container-aware.d.ts.map +1 -0
- package/core/core/decorators/kos-future-aware.d.ts +150 -0
- package/core/core/decorators/kos-future-aware.d.ts.map +1 -0
- package/core/core/decorators/kos-logger-aware.d.ts +96 -0
- package/core/core/decorators/kos-logger-aware.d.ts.map +1 -0
- package/core/core/decorators/kos-trouble-aware.d.ts +71 -0
- package/core/core/decorators/kos-trouble-aware.d.ts.map +1 -0
- package/core/core/decorators/kosModel.d.ts +8 -2
- package/core/core/decorators/kosModel.d.ts.map +1 -1
- package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
- package/core/core/decorators/propKeys.d.ts +4 -0
- package/core/core/decorators/propKeys.d.ts.map +1 -1
- package/core/core/extension/extension-manager.d.ts +1 -1
- package/core/core/extension/extension-manager.d.ts.map +1 -1
- package/core/core/kosCore.d.ts.map +1 -1
- package/core/core/registration/index.d.ts +1 -0
- package/core/core/registration/index.d.ts.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/util/container-utils.d.ts +3 -2
- package/core/util/container-utils.d.ts.map +1 -1
- package/core/util/observable-proxy-map.d.ts.map +1 -1
- package/index.cjs +79 -76
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +9672 -7760
- package/index.js.map +1 -1
- package/models/models/browser-router/browser-router-model.d.ts +80 -1
- package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
- package/models/models/browser-router/types/index.d.ts +25 -1
- package/models/models/config-bean/config-bean-model-builder.d.ts +4 -2
- package/models/models/config-bean/config-bean-model-builder.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model.d.ts +117 -13
- package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-types.d.ts +6 -3
- package/models/models/config-bean/config-bean-types.d.ts.map +1 -1
- package/models/models/config-bean/types/index.d.ts +33 -0
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts +112 -1
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
- package/models/models/config-bean-prop/types/index.d.ts +293 -17
- package/models/models/device/device-model.d.ts +219 -9
- package/models/models/device/device-model.d.ts.map +1 -1
- package/models/models/device/device-registration.d.ts +61 -48
- package/models/models/device/device-registration.d.ts.map +1 -1
- package/models/models/device/types/index.d.ts +41 -0
- package/models/models/future/future-aware.d.ts +82 -0
- package/models/models/future/future-aware.d.ts.map +1 -1
- package/models/models/future/future-model.d.ts +34 -5
- package/models/models/future/future-model.d.ts.map +1 -1
- package/models/models/future/future-types.d.ts +186 -7
- package/models/models/future/future-types.d.ts.map +1 -1
- package/models/models/future-container/future-container-model.d.ts +2 -2
- package/models/models/index.d.ts +1 -0
- package/models/models/index.d.ts.map +1 -1
- package/models/models/key-value/index.d.ts +4 -0
- package/models/models/key-value/index.d.ts.map +1 -1
- package/models/models/key-value/key-value-model.d.ts +111 -0
- package/models/models/key-value/key-value-model.d.ts.map +1 -1
- package/models/models/key-value/services/key-value-services.d.ts +124 -2
- package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/key-value/types/index.d.ts +56 -0
- package/models/models/kos-expression-evaluator/index.d.ts +4 -0
- package/models/models/kos-expression-evaluator/index.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +209 -0
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/services/index.d.ts +6 -0
- package/models/models/kos-expression-evaluator/services/index.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts +15 -0
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/types/index.d.ts +1 -0
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts +61 -14
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
- package/models/models/kos-log-manager/types/index.d.ts +187 -0
- package/models/models/kos-time/kos-time-model.d.ts +64 -0
- package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
- package/models/models/kos-time/types/index.d.ts +80 -0
- package/models/models/log-block/log-block-container-model.d.ts +132 -0
- package/models/models/log-block/log-block-container-model.d.ts.map +1 -1
- package/models/models/log-block/log-block-model.d.ts +185 -0
- package/models/models/log-block/log-block-model.d.ts.map +1 -1
- package/models/models/log-block/types/index.d.ts +129 -0
- package/models/models/log-stream/index.d.ts +6 -2
- package/models/models/log-stream/index.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-container-model.d.ts +62 -0
- package/models/models/log-stream/log-stream-container-model.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-model.d.ts +55 -0
- package/models/models/log-stream/log-stream-model.d.ts.map +1 -1
- package/models/models/log-stream/services/log-stream-services.d.ts +2 -1
- package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
- package/models/models/log-stream/types/index.d.ts +77 -0
- package/models/models/network-interface/index.d.ts +6 -2
- package/models/models/network-interface/index.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-container-model.d.ts +62 -0
- package/models/models/network-interface/network-interface-container-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-container-registration.d.ts +2 -1
- package/models/models/network-interface/network-interface-container-registration.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-model.d.ts +77 -0
- package/models/models/network-interface/network-interface-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-registration.d.ts +2 -1
- package/models/models/network-interface/network-interface-registration.d.ts.map +1 -1
- package/models/models/network-interface/services/network-interface-services.d.ts +54 -0
- package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
- package/models/models/network-interface/types/index.d.ts +21 -0
- package/models/models/ota/ota-model.d.ts +82 -3
- package/models/models/ota/ota-model.d.ts.map +1 -1
- package/models/models/ota/types/index.d.ts +146 -0
- package/models/models/region-info/region-info-model.d.ts +7 -3
- package/models/models/region-info/region-info-model.d.ts.map +1 -1
- package/models/models/region-info/services/region-info-services.d.ts.map +1 -1
- package/models/models/region-info/types/index.d.ts +141 -13
- package/models/models/region-info/types/index.d.ts.map +1 -1
- package/models/models/software-info/software-info-model.d.ts +74 -2
- package/models/models/software-info/software-info-model.d.ts.map +1 -1
- package/models/models/software-info/types/index.d.ts +48 -16
- package/models/models/state-bean/state-bean-model.d.ts +86 -9
- package/models/models/state-bean/state-bean-model.d.ts.map +1 -1
- package/models/models/state-bean/types/index.d.ts +114 -6
- package/models/models/state-prop/state-prop-model.d.ts +78 -1
- package/models/models/state-prop/state-prop-model.d.ts.map +1 -1
- package/models/models/state-prop/types/index.d.ts +55 -7
- package/models/models/storage-device/storage-device-container-model.d.ts +289 -2
- package/models/models/storage-device/storage-device-container-model.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-model.d.ts +84 -2
- package/models/models/storage-device/storage-device-model.d.ts.map +1 -1
- package/models/models/storage-device/types/index.d.ts +112 -0
- package/models/models/studio-properties/studio-properties-model.d.ts +75 -0
- package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
- package/models/models/studio-properties/types/index.d.ts +29 -0
- package/models/models/translation/services/translation-services.d.ts +128 -2
- package/models/models/translation/services/translation-services.d.ts.map +1 -1
- package/models/models/translation/translation-container-model.d.ts +100 -10
- package/models/models/translation/translation-container-model.d.ts.map +1 -1
- package/models/models/translation/translation-container-registration.d.ts +2 -1
- package/models/models/translation/translation-container-registration.d.ts.map +1 -1
- package/models/models/translation/translation-context.d.ts +1 -16
- package/models/models/translation/translation-context.d.ts.map +1 -1
- package/models/models/translation/translation-model.d.ts +113 -1
- package/models/models/translation/translation-model.d.ts.map +1 -1
- package/models/models/translation/types/index.d.ts +340 -0
- package/models/models/trouble/services/trouble-services.d.ts +3 -3
- package/models/models/trouble/services/trouble-services.d.ts.map +1 -1
- package/models/models/trouble/trouble-model.d.ts +2 -1
- package/models/models/trouble/trouble-model.d.ts.map +1 -1
- package/models/models/trouble/types/index.d.ts +22 -93
- package/models/models/trouble/utils/is-trouble-aware.d.ts +2 -2
- package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -1
- package/models/models/trouble-container/index.d.ts +4 -3
- package/models/models/trouble-container/index.d.ts.map +1 -1
- package/models/models/trouble-container/trouble-container-model.d.ts +9 -5
- package/models/models/trouble-container/trouble-container-model.d.ts.map +1 -1
- package/models/models/trouble-container/types/index.d.ts +2 -15
- package/models/utils/client.d.ts +8 -8
- package/models/utils/core-registration-manager.d.ts +1 -1
- package/models/utils/core-registration-manager.d.ts.map +1 -1
- package/models/utils/index.d.ts +0 -2
- package/models/utils/index.d.ts.map +1 -1
- package/models/utils/service.d.ts +9 -9
- package/package.json +2 -2
- package/ui/contexts/state-bean/state-bean-provider.d.ts.map +1 -1
- package/ui/hooks/state-bean/use-state-bean.d.ts +2 -2
- package/ui/hooks/state-bean/use-state-bean.d.ts.map +1 -1
- package/ui/hooks/state-bean/with-state-bean.d.ts.map +1 -1
- package/ui/hooks/translation-container/use-translation-container.d.ts +4 -33
- package/ui/hooks/translation-container/use-translation-container.d.ts.map +1 -1
- package/models/models/trouble-container/trouble-container-registration.d.ts +0 -5
- package/models/models/trouble-container/trouble-container-registration.d.ts.map +0 -1
- package/models/utils/kosmodel-compatible-future-mixin.d.ts +0 -142
- package/models/utils/kosmodel-compatible-future-mixin.d.ts.map +0 -1
- package/models/utils/kosmodel-interface-companion-mixin.d.ts +0 -83
- package/models/utils/kosmodel-interface-companion-mixin.d.ts.map +0 -1
|
@@ -3,87 +3,100 @@ import { DeviceModel } from './device-model';
|
|
|
3
3
|
import { SingletonKosModelRegistrationFactory } from '../../../core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* # Device
|
|
6
|
+
* # Device Model Registration Factory
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* **KOS Device Identity and Node Configuration Management**
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently
|
|
13
|
-
* used when declaring dependencies on models.
|
|
10
|
+
* The Device registration factory provides convenient methods for creating and working with DeviceModel instances.
|
|
11
|
+
* Device models handle device identity, hardware serial numbers, and node configuration within KOS deployments.
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* ## Core Registration Properties
|
|
14
|
+
*
|
|
15
|
+
* ### type
|
|
16
|
+
*
|
|
17
|
+
* Model type identifier used for dependency injection and type narrowing.
|
|
18
|
+
* Essential for declaring model dependencies in other components.
|
|
17
19
|
*
|
|
20
|
+
* @example Model Dependency Declaration
|
|
21
|
+
* ```typescript
|
|
18
22
|
* @kosDependency({modelType: Device.type, id: "deviceId"})
|
|
19
23
|
* private deviceModel: DeviceModel;
|
|
20
24
|
* ```
|
|
21
25
|
*
|
|
26
|
+
* ### factory
|
|
22
27
|
*
|
|
23
|
-
*
|
|
28
|
+
* Creates DeviceModel instances with singleton behavior. Multiple calls return the same instance,
|
|
29
|
+
* ensuring system-wide device identity consistency.
|
|
24
30
|
*
|
|
25
|
-
*
|
|
31
|
+
* **Singleton Behavior**: Subsequent factory calls return existing instance; options ignored after first creation.
|
|
26
32
|
*
|
|
27
|
-
|
|
28
|
-
*
|
|
33
|
+
* @example Device Creation and Identity Access
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const device = Device.factory({
|
|
36
|
+
* serialNumber: 'KOS-DEVICE-001',
|
|
37
|
+
* name: 'Production Dispenser Alpha',
|
|
38
|
+
* nodeId: 'primary-controller'
|
|
39
|
+
* });
|
|
29
40
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
41
|
+
* // Access device identity
|
|
42
|
+
* console.log(`Device: ${device.name} (${device.serialNumber})`);
|
|
43
|
+
* console.log(`Node: ${device.nodeType}-${device.nodeName}`);
|
|
44
|
+
* ```
|
|
32
45
|
*
|
|
33
|
-
* @example
|
|
46
|
+
* @example Multi-node System Coordination
|
|
34
47
|
* ```typescript
|
|
35
|
-
* const
|
|
36
|
-
*
|
|
37
|
-
*
|
|
48
|
+
* const primaryDevice = Device.factory({ nodeId: 'primary-main' });
|
|
49
|
+
* const backupDevice = Device.factory({ nodeId: 'secondary-backup' });
|
|
50
|
+
*
|
|
51
|
+
* // Coordinate based on node roles
|
|
52
|
+
* if (primaryDevice.nodeType === 'primary') {
|
|
53
|
+
* // Handle primary node responsibilities
|
|
54
|
+
* }
|
|
38
55
|
* ```
|
|
39
|
-
|
|
40
|
-
|
|
41
56
|
*
|
|
42
|
-
*
|
|
57
|
+
* ### predicate
|
|
43
58
|
*
|
|
44
|
-
* [
|
|
59
|
+
* [TypeScript type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
|
|
60
|
+
* for identifying and narrowing models to DeviceModel instances.
|
|
45
61
|
*
|
|
46
|
-
* @example
|
|
62
|
+
* @example Type Narrowing for Device Operations
|
|
47
63
|
* ```typescript
|
|
48
|
-
*
|
|
49
|
-
* const model: IKosDataModel = ...; // some model
|
|
64
|
+
* const model: IKosDataModel = getModel(); // some model
|
|
50
65
|
*
|
|
51
66
|
* if (Device.predicate(model)) {
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
67
|
+
* // Compiler now knows model is DeviceModel
|
|
68
|
+
* console.log(`Device Serial: ${model.serialNumber}`);
|
|
69
|
+
* model.updateModel({ name: 'Updated Name' });
|
|
55
70
|
* }
|
|
56
71
|
* ```
|
|
57
72
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object
|
|
61
|
-
* can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.
|
|
73
|
+
* ### registration
|
|
62
74
|
*
|
|
75
|
+
* Registration object for model registry integration. Provides all required information
|
|
76
|
+
* for registering the DeviceModelImpl implementation with the model registry.
|
|
63
77
|
*
|
|
64
|
-
* @example
|
|
65
|
-
*
|
|
66
|
-
* In an application registration file you can declare the model registration as follows:
|
|
67
|
-
*
|
|
68
|
-
* **registration.ts**
|
|
78
|
+
* @example Model Registry Configuration
|
|
69
79
|
* ```typescript
|
|
80
|
+
* // registration.ts
|
|
70
81
|
* import { Device } from "@kos-ui/project-models";
|
|
71
82
|
* import { KosModelRegistry } from "@kosdev-code/kos-dispense-sdk";
|
|
72
83
|
*
|
|
73
|
-
* import { initKosProvider } from "@kosdev-code/kos-ui-sdk";
|
|
74
|
-
*
|
|
75
84
|
* KosModelRegistry.dispense
|
|
76
|
-
*
|
|
77
|
-
*
|
|
85
|
+
* .models()
|
|
86
|
+
* .model(Device);
|
|
78
87
|
* ```
|
|
79
88
|
*
|
|
80
|
-
* ##
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
*
|
|
89
|
+
* ## Singleton Architecture
|
|
90
|
+
*
|
|
91
|
+
* **Device models use singleton pattern** ensuring system-wide consistency:
|
|
92
|
+
* - Each device type has exactly one instance
|
|
93
|
+
* - Subsequent factory calls return existing instance
|
|
94
|
+
* - Options are ignored after initial creation
|
|
95
|
+
* - Uses model type as unique identifier
|
|
96
|
+
* - Guarantees device identity consistency across system
|
|
84
97
|
*
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
* @group KOS Model
|
|
99
|
+
* @category Device Data
|
|
100
|
+
*/
|
|
88
101
|
export declare const Device: SingletonKosModelRegistrationFactory<DeviceModel, DeviceOptions>;
|
|
89
102
|
//# sourceMappingURL=device-registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-registration.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/device/device-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"device-registration.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/device/device-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FG;AACH,eAAO,MAAM,MAAM,kEAMjB,CAAC"}
|
|
@@ -1,5 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for Device model instances.
|
|
3
|
+
*
|
|
4
|
+
* Defines device identity and node-specific parameters for KOS device modeling.
|
|
5
|
+
* Device models represent the physical device identity and node configuration
|
|
6
|
+
* within a KOS system deployment.
|
|
7
|
+
*
|
|
8
|
+
* @example Basic Device Configuration
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const deviceOptions: DeviceOptions = {
|
|
11
|
+
* serialNumber: 'KOS-DEVICE-12345',
|
|
12
|
+
* name: 'Main Beverage Dispenser',
|
|
13
|
+
* nodeId: 'primary-node-01'
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* const device = Device.factory(deviceOptions);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @group KOS Model
|
|
20
|
+
* @category Service Integration
|
|
21
|
+
*/
|
|
1
22
|
export interface DeviceOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Unique device serial number from hardware.
|
|
25
|
+
*
|
|
26
|
+
* Retrieved from the device's hardware identification system.
|
|
27
|
+
* Used for warranty tracking, support, and device-specific configuration.
|
|
28
|
+
*/
|
|
2
29
|
serialNumber?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Human-readable device name for identification.
|
|
33
|
+
*
|
|
34
|
+
* Typically configured during device setup and used in administrative
|
|
35
|
+
* interfaces for device identification and management.
|
|
36
|
+
*/
|
|
3
37
|
name?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Node identifier within the KOS deployment.
|
|
41
|
+
*
|
|
42
|
+
* Identifies the specific node role and instance within a multi-node
|
|
43
|
+
* KOS deployment. Format typically follows 'type-instance' pattern.
|
|
44
|
+
*/
|
|
4
45
|
nodeId?: string;
|
|
5
46
|
}
|
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
import { FutureAwareContainer, FutureContainer, IFutureModel, MultiFutureAware } from './future-types';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Future handler for managing multiple concurrent long-running operations.
|
|
5
|
+
*
|
|
6
|
+
* Provides comprehensive lifecycle management for models that coordinate multiple
|
|
7
|
+
* device operations simultaneously. Each Future is tracked with its own alias
|
|
8
|
+
* and receives automatic progress updates and cleanup when operations complete.
|
|
9
|
+
*
|
|
10
|
+
* @example Managing Multiple Operations
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @kosModel("device-maintenance-model")
|
|
13
|
+
* export class DeviceMaintenanceModel implements FutureContainer {
|
|
14
|
+
* futureHandler: MultipleFutureHandler;
|
|
15
|
+
*
|
|
16
|
+
* constructor(modelId: string, options: any, context: KosCreationContext) {
|
|
17
|
+
* this.id = modelId;
|
|
18
|
+
* this.futureHandler = new MultipleFutureHandler(this);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* async startCalibration(deviceId: string): Promise<CalibrationResult> {
|
|
22
|
+
* const future = await this.createFuture('/device/calibrate', { deviceId });
|
|
23
|
+
* this.futureHandler.addFuture(future, `calibration-${deviceId}`);
|
|
24
|
+
* return future;
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* async startCleaning(deviceId: string): Promise<CleaningResult> {
|
|
28
|
+
* const future = await this.createFuture('/device/clean', { deviceId });
|
|
29
|
+
* this.futureHandler.addFuture(future, `cleaning-${deviceId}`);
|
|
30
|
+
* return future;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* onFutureUpdate(future: IFutureModel): void {
|
|
34
|
+
* // Handle progress updates from any managed Future
|
|
35
|
+
* console.log(`${future.id}: ${future.progress}% complete`);
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @group KOS Model
|
|
41
|
+
* @category Asynchronous Operations
|
|
42
|
+
*/
|
|
3
43
|
export declare class MultipleFutureHandler<T extends {} = Record<string, unknown>> implements FutureAwareContainer<T>, MultiFutureAware<T> {
|
|
4
44
|
private futures;
|
|
5
45
|
private defaultContext;
|
|
@@ -14,6 +54,48 @@ export declare class MultipleFutureHandler<T extends {} = Record<string, unknown
|
|
|
14
54
|
getFuture(alias?: string): IFutureModel<T> | undefined;
|
|
15
55
|
get futureMap(): Map<string, IFutureModel<T>>;
|
|
16
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Future handler for managing single long-running operations with simplified API.
|
|
59
|
+
*
|
|
60
|
+
* Provides streamlined lifecycle management for models that typically handle
|
|
61
|
+
* one operation at a time. Automatically tracks progress and provides reactive
|
|
62
|
+
* status information for UI integration.
|
|
63
|
+
*
|
|
64
|
+
* @example Single Operation Management
|
|
65
|
+
* ```typescript
|
|
66
|
+
* @kosModel("brewing-system-model")
|
|
67
|
+
* export class BrewingSystemModel implements FutureContainer {
|
|
68
|
+
* futureHandler: FutureHandler;
|
|
69
|
+
*
|
|
70
|
+
* constructor(modelId: string, options: any, context: KosCreationContext) {
|
|
71
|
+
* this.id = modelId;
|
|
72
|
+
* this.futureHandler = new FutureHandler(this);
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* async startBrewingCycle(recipe: Recipe): Promise<BrewingResult> {
|
|
76
|
+
* const future = await this.createFuture('/brewing/start', { recipe });
|
|
77
|
+
* this.futureHandler.addFuture(future);
|
|
78
|
+
* return future;
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* get isOperationActive(): boolean {
|
|
82
|
+
* return this.futureHandler.status !== 'NOT_RESOLVED';
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* get operationProgress(): number {
|
|
86
|
+
* return this.futureHandler.progress;
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* onFutureUpdate(future: IFutureModel): void {
|
|
90
|
+
* // Handle progress updates from the active Future
|
|
91
|
+
* console.log(`Brewing: ${future.progress}% complete`);
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @group KOS Model
|
|
97
|
+
* @category Asynchronous Operations
|
|
98
|
+
*/
|
|
17
99
|
export declare class FutureHandler<T extends object = Record<string, unknown>> implements FutureAwareContainer<T> {
|
|
18
100
|
private disposer?;
|
|
19
101
|
private _future?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"future-aware.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/future/future-aware.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAExB,qBAAa,qBAAqB,CAAC,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACvE,YAAW,oBAAoB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,SAAS,CAAC,CAAqB;gBAC3B,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM;IAQnE,IAAI,UAAU,sBAEb;IAED,IAAI,MAAM,gCAET;IACD,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM;IAWjD,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM;IAM3B,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM;IAKxB,IAAI,SAAS,iCAEZ;CACF;AAED,qBAAa,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACnE,YAAW,oBAAoB,CAAC,CAAC,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,CAAa;IAE9B,OAAO,CAAC,OAAO,CAAC,CAAkB;IAClC,OAAO,CAAC,SAAS,CAAC,CAAqB;gBAC3B,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;IAK1C,YAAY;IAMZ,IAAI,MAAM,gCAET;IACD,SAAS,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS;IAIxC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAWjC,cAAc,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEjE,IAAI,UAAU,sBAEb;IACD,IAAI,aAAa,WAEhB;IAED,IAAI,MAAM,WAET;IAED,IAAI,QAAQ,WAEX;IAEK,MAAM;CAUb"}
|
|
1
|
+
{"version":3,"file":"future-aware.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/future/future-aware.ts"],"names":[],"mappings":"AA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AAG,SAAS;IAIxC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAWjC,cAAc,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEjE,IAAI,UAAU,sBAEb;IACD,IAAI,aAAa,WAEhB;IAED,IAAI,MAAM,WAET;IAED,IAAI,QAAQ,WAEX;IAEK,MAAM;CAUb"}
|
|
@@ -27,7 +27,7 @@ declare class FutureModel implements IFutureModel {
|
|
|
27
27
|
*/
|
|
28
28
|
constructor(modelId: string, options: IFutureModelOptions, context: KosCreationContext);
|
|
29
29
|
/**
|
|
30
|
-
* @
|
|
30
|
+
* @internal
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
33
|
* No action is taken as part of the load lifecycle method.
|
|
@@ -35,6 +35,9 @@ declare class FutureModel implements IFutureModel {
|
|
|
35
35
|
* In future additional information about the workspace could be loaded
|
|
36
36
|
*/
|
|
37
37
|
load(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
38
41
|
unload(): void;
|
|
39
42
|
/**
|
|
40
43
|
* @category Action
|
|
@@ -48,16 +51,42 @@ declare class FutureModel implements IFutureModel {
|
|
|
48
51
|
* @see cancelFutureService
|
|
49
52
|
*/
|
|
50
53
|
cancelFuture(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current status of the future operation.
|
|
56
|
+
*
|
|
57
|
+
* @returns Status string: "NOT_ACTIVE", "IN_PROGRESS", "Success", or "Fail"
|
|
58
|
+
*
|
|
59
|
+
* @example Monitor Status
|
|
60
|
+
* ```typescript
|
|
61
|
+
* if (future.status === "IN_PROGRESS") {
|
|
62
|
+
* console.log(`Operation running: ${future.progress}% complete`);
|
|
63
|
+
* } else if (future.status === "Success") {
|
|
64
|
+
* console.log("Operation completed successfully!");
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
51
68
|
get status(): FutureEndState | "IN_PROGRESS" | "NOT_ACTIVE";
|
|
69
|
+
/**
|
|
70
|
+
* Gets human-readable time remaining for the operation.
|
|
71
|
+
*
|
|
72
|
+
* @returns Formatted time string (e.g., "5 minutes", "30 seconds") or empty string if unknown
|
|
73
|
+
*
|
|
74
|
+
* @example Display Time Remaining
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const timeLeft = future.timeRemaining;
|
|
77
|
+
* if (timeLeft) {
|
|
78
|
+
* console.log(`${timeLeft} remaining`);
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
52
82
|
get timeRemaining(): string;
|
|
53
83
|
/**
|
|
84
|
+
* @internal
|
|
54
85
|
* @category Subscription
|
|
55
|
-
* Updates the Future model when a `kos.future/ID` event
|
|
86
|
+
* Updates the Future model when a `kos.future/{ID}` event
|
|
56
87
|
* is received from the server.
|
|
57
88
|
*
|
|
58
|
-
*
|
|
59
|
-
* @param data - the raw callback
|
|
60
|
-
* @param data.body - the Future that was updated.
|
|
89
|
+
* @param future - the Future that was updated.
|
|
61
90
|
* @see FutureResponse
|
|
62
91
|
*/
|
|
63
92
|
handleFutureUpdated(future: FutureResponse): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"future-model.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/future/future-model.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EAGd,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOxE,UAAU,WAAY,SAAQ,YAAY;CAAG;AAI7C;;;;;;;GAOG;AACH,cACM,WAAY,YAAW,YAAY;IACvC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAGuB;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,kBAAkB;IAwB7B;;;;;;;OAOG;IACG,IAAI;IAIV,MAAM;IAMN;;;;;;;;;;OAUG;IACG,YAAY;IASlB,IAAI,MAAM,kDAMT;IAED,IAAI,aAAa,WAoChB;IAID
|
|
1
|
+
{"version":3,"file":"future-model.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/future/future-model.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EAGd,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOxE,UAAU,WAAY,SAAQ,YAAY;CAAG;AAI7C;;;;;;;GAOG;AACH,cACM,WAAY,YAAW,YAAY;IACvC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAGuB;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,kBAAkB;IAwB7B;;;;;;;OAOG;IACG,IAAI;IAIV;;OAEG;IACH,MAAM;IAMN;;;;;;;;;;OAUG;IACG,YAAY;IASlB;;;;;;;;;;;;;OAaG;IACH,IAAI,MAAM,kDAMT;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,aAAa,WAoChB;IAID;;;;;;;;OAQG;IAIH,mBAAmB,CAAC,MAAM,EAAE,cAAc;CAM3C;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,16 +1,80 @@
|
|
|
1
1
|
import { FutureEndState } from '../../services/future';
|
|
2
2
|
import { IKosDataModel } from '../../../core';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Basic Future delegation interface for models that hold a single Future reference.
|
|
6
|
+
*
|
|
7
|
+
* @group KOS Model
|
|
8
|
+
* @category Asynchronous Operations
|
|
9
|
+
*/
|
|
4
10
|
export interface FutureDelegate<T extends {} = Record<string, unknown>> {
|
|
5
11
|
future?: IFutureModel<T>;
|
|
6
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Container pattern for managing multiple Future operations in KOS models.
|
|
15
|
+
*
|
|
16
|
+
* Provides comprehensive Future management capabilities for models that handle
|
|
17
|
+
* multiple concurrent long-running operations with centralized lifecycle management.
|
|
18
|
+
*
|
|
19
|
+
* @example Basic Future Container
|
|
20
|
+
* ```typescript
|
|
21
|
+
* @kosModel("device-operations-model")
|
|
22
|
+
* export class DeviceOperationsModel implements FutureContainer {
|
|
23
|
+
* futureHandler: FutureAwareContainer;
|
|
24
|
+
*
|
|
25
|
+
* constructor(modelId: string, options: any, context: KosCreationContext) {
|
|
26
|
+
* this.id = modelId;
|
|
27
|
+
* this.futureHandler = new FutureHandler(this);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* onFutureUpdate(future: IFutureModel): void {
|
|
31
|
+
* // Handle progress updates from any managed Future
|
|
32
|
+
* console.log(`Operation ${future.id}: ${future.progress}%`);
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @group KOS Model
|
|
38
|
+
* @category Asynchronous Operations
|
|
39
|
+
*/
|
|
7
40
|
export interface FutureContainer<T extends {} = Record<string, unknown>> {
|
|
8
41
|
futureHandler: FutureAwareContainer<T>;
|
|
9
42
|
onFutureUpdate?: (future: IFutureModel<T>) => void;
|
|
10
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Advanced pattern for models managing multiple named Future operations.
|
|
46
|
+
*
|
|
47
|
+
* @group KOS Model
|
|
48
|
+
* @category Asynchronous Operations
|
|
49
|
+
*/
|
|
11
50
|
export interface MultiFutureAware<T extends {} = Record<string, unknown>> {
|
|
12
51
|
futureMap: Map<string, IFutureModel<T>>;
|
|
13
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Container interface providing comprehensive Future lifecycle management.
|
|
55
|
+
*
|
|
56
|
+
* Handles multiple concurrent Futures with operations for adding, removing,
|
|
57
|
+
* and querying Future instances. Essential for complex models that coordinate
|
|
58
|
+
* multiple device operations simultaneously.
|
|
59
|
+
*
|
|
60
|
+
* @example Future Container Operations
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Add new Future with optional alias
|
|
63
|
+
* container.addFuture(calibrationFuture, 'pump-calibration');
|
|
64
|
+
*
|
|
65
|
+
* // Query specific Future
|
|
66
|
+
* const future = container.getFuture('pump-calibration');
|
|
67
|
+
*
|
|
68
|
+
* // Remove completed Future
|
|
69
|
+
* container.removeFuture('pump-calibration');
|
|
70
|
+
*
|
|
71
|
+
* // Get all active Futures
|
|
72
|
+
* const activeFutures = container.allFutures;
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @group KOS Model
|
|
76
|
+
* @category Asynchronous Operations
|
|
77
|
+
*/
|
|
14
78
|
export interface FutureAwareContainer<T extends {} = Record<string, unknown>> extends FutureDelegate<T> {
|
|
15
79
|
removeFuture(alias?: string): void;
|
|
16
80
|
getFuture(alias?: string): IFutureModel<T> | undefined;
|
|
@@ -18,6 +82,32 @@ export interface FutureAwareContainer<T extends {} = Record<string, unknown>> ex
|
|
|
18
82
|
allFutures: IFutureModel<T>[];
|
|
19
83
|
onFutureUpdate?: (future: IFutureModel<T>) => void;
|
|
20
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Simplified interface for models that need basic Future awareness.
|
|
87
|
+
*
|
|
88
|
+
* Provides essential Future status information without full container complexity.
|
|
89
|
+
* Ideal for models that typically handle single operations or need simple
|
|
90
|
+
* Future integration.
|
|
91
|
+
*
|
|
92
|
+
* @example Basic Future Awareness
|
|
93
|
+
* ```typescript
|
|
94
|
+
* function OperationStatus({ model }: { model: FutureAware }) {
|
|
95
|
+
* return (
|
|
96
|
+
* <div>
|
|
97
|
+
* <p>Status: {model.status}</p>
|
|
98
|
+
* <progress value={model.progress} max={100} />
|
|
99
|
+
* <p>Time remaining: {model.timeRemaining}</p>
|
|
100
|
+
* {model.status === 'IN_PROGRESS' && (
|
|
101
|
+
* <button onClick={() => model.cancel()}>Cancel</button>
|
|
102
|
+
* )}
|
|
103
|
+
* </div>
|
|
104
|
+
* );
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @group KOS Model
|
|
109
|
+
* @category Asynchronous Operations
|
|
110
|
+
*/
|
|
21
111
|
export interface FutureAware {
|
|
22
112
|
readonly statusFuture?: IFutureModel;
|
|
23
113
|
status: string;
|
|
@@ -26,16 +116,33 @@ export interface FutureAware {
|
|
|
26
116
|
cancel: () => Promise<void>;
|
|
27
117
|
}
|
|
28
118
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
119
|
+
* Configuration options for Future model instances.
|
|
120
|
+
*
|
|
121
|
+
* Defines the initial state and parameters for Future operations including
|
|
122
|
+
* progress tracking, client data attachment, and namespace configuration.
|
|
31
123
|
*
|
|
32
124
|
* @remarks
|
|
33
125
|
* Used to identify additional data that can be set on the model during
|
|
34
|
-
* instantiation.
|
|
35
|
-
* in the constructor.
|
|
126
|
+
* instantiation. It is expected that implementers will set these properties
|
|
127
|
+
* in the constructor. The value <strong>might</strong> be overridden by
|
|
36
128
|
* subsequent lifecycle methods or updates.
|
|
37
129
|
*
|
|
38
|
-
* @
|
|
130
|
+
* @example Basic Future Options
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const futureOptions: IFutureModelOptions = {
|
|
133
|
+
* id: 'calibration-123',
|
|
134
|
+
* namespace: 'kos',
|
|
135
|
+
* progress: 0,
|
|
136
|
+
* clientData: { deviceId: 'pump-S4', targetRate: 1.2 }
|
|
137
|
+
* };
|
|
138
|
+
*
|
|
139
|
+
* const future = FutureFactory.instance('my-future')
|
|
140
|
+
* .options(futureOptions)
|
|
141
|
+
* .build();
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @group KOS Model
|
|
145
|
+
* @category Asynchronous Operations
|
|
39
146
|
*/
|
|
40
147
|
export interface IFutureModelOptions<T extends {} = Record<string, unknown>> {
|
|
41
148
|
id: string;
|
|
@@ -59,9 +166,81 @@ export interface IFutureModelOptions<T extends {} = Record<string, unknown>> {
|
|
|
59
166
|
note?: string;
|
|
60
167
|
}
|
|
61
168
|
/**
|
|
62
|
-
*
|
|
169
|
+
* Future - Reactive long-running operation management for KOS devices and applications.
|
|
170
|
+
*
|
|
171
|
+
* The Future model provides comprehensive tracking and management of asynchronous operations
|
|
172
|
+
* with real-time progress updates, cancellation support, and automatic lifecycle management.
|
|
173
|
+
* Essential for building responsive user interfaces that handle time-consuming operations.
|
|
174
|
+
*
|
|
175
|
+
* ## Key Features
|
|
176
|
+
* - **Real-Time Progress Tracking** - Live updates via WebSocket topics with percentage completion
|
|
177
|
+
* - **Cancellation Support** - Ability to cancel in-progress operations safely
|
|
178
|
+
* - **Automatic Cleanup** - Models self-destruct when operations complete or fail
|
|
179
|
+
* - **Status Management** - Clear status reporting (NOT_ACTIVE, IN_PROGRESS, Success, Fail)
|
|
180
|
+
* - **Time Estimation** - Remaining time calculations with localized formatting
|
|
181
|
+
* - **Client Data Attachment** - Associate custom data with future operations
|
|
182
|
+
* - **Namespace Support** - Separate futures for different services (kos, studio, etc.)
|
|
183
|
+
*
|
|
184
|
+
* ## Operation Lifecycle
|
|
185
|
+
* Futures progress through distinct states with automatic status management:
|
|
186
|
+
* - **NOT_ACTIVE** - Operation not yet started or queued
|
|
187
|
+
* - **IN_PROGRESS** - Operation actively executing with progress updates
|
|
188
|
+
* - **Success** - Operation completed successfully (triggers automatic cleanup)
|
|
189
|
+
* - **Fail** - Operation failed with error details (triggers automatic cleanup)
|
|
190
|
+
*
|
|
191
|
+
* ## Common Use Cases
|
|
192
|
+
* - **Device Operations** - Track pump calibration, system diagnostics, configuration updates
|
|
193
|
+
* - **File Transfers** - Monitor upload/download progress with cancellation support
|
|
194
|
+
* - **System Updates** - Track firmware updates, package installations, system maintenance
|
|
195
|
+
* - **Data Processing** - Monitor analysis operations, report generation, bulk operations
|
|
196
|
+
* - **VM Management** - Track VM creation, deployment, and lifecycle operations
|
|
197
|
+
*
|
|
198
|
+
* @example Basic Future Tracking
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const calibrationFuture = FutureFactory.instance('calibration-op')
|
|
201
|
+
* .options({
|
|
202
|
+
* id: 'pump-cal-123',
|
|
203
|
+
* namespace: 'kos',
|
|
204
|
+
* clientData: { pumpId: 'S4', targetRate: 0.9 }
|
|
205
|
+
* })
|
|
206
|
+
* .build();
|
|
207
|
+
*
|
|
208
|
+
* // Monitor progress
|
|
209
|
+
* console.log(`Status: ${calibrationFuture.status}`);
|
|
210
|
+
* console.log(`Progress: ${calibrationFuture.progress}%`);
|
|
211
|
+
* console.log(`Time remaining: ${calibrationFuture.timeRemaining}`);
|
|
212
|
+
*
|
|
213
|
+
* // Cancel if needed
|
|
214
|
+
* await calibrationFuture.cancelFuture();
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @example React Integration
|
|
218
|
+
* ```typescript
|
|
219
|
+
* function CalibrationProgress({ futureId }: { futureId: string }) {
|
|
220
|
+
* const future = useFuture(futureId);
|
|
221
|
+
*
|
|
222
|
+
* return (
|
|
223
|
+
* <div>
|
|
224
|
+
* <progress value={future.progress} max={100} />
|
|
225
|
+
* <p>{future.timeRemaining} remaining</p>
|
|
226
|
+
* {future.status === 'IN_PROGRESS' && (
|
|
227
|
+
* <button onClick={() => future.cancelFuture()}>
|
|
228
|
+
* Cancel Operation
|
|
229
|
+
* </button>
|
|
230
|
+
* )}
|
|
231
|
+
* </div>
|
|
232
|
+
* );
|
|
233
|
+
* }
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* @interface
|
|
237
|
+
* @group KOS Model
|
|
238
|
+
* @category Asynchronous Operations
|
|
239
|
+
* @useDeclaredType
|
|
63
240
|
*
|
|
64
|
-
* @
|
|
241
|
+
* @see {@link IFutureModelOptions} - Configuration options for Future instances
|
|
242
|
+
* @see {@link FutureAware} - Interface for models that integrate with Futures
|
|
243
|
+
* @see {@link FutureContainer} - Container pattern for managing multiple Futures
|
|
65
244
|
*/
|
|
66
245
|
export interface IFutureModel<T extends {} = Record<string, unknown>> extends IKosDataModel, Omit<IFutureModelOptions<T>, "modifyFuture"> {
|
|
67
246
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"future-types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/future/future-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"future-types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/future/future-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,EAAE,GAAG,M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M,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;IACR,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -70,7 +70,7 @@ declare class FutureContainerModel implements IFutureContainerModel {
|
|
|
70
70
|
* actions on elements in a collection without requiring the models to have
|
|
71
71
|
* explicit knowledge of the operation being performed.
|
|
72
72
|
*
|
|
73
|
-
* @
|
|
73
|
+
* @group KOS Model
|
|
74
74
|
* @internal
|
|
75
75
|
*/
|
|
76
76
|
/**
|
|
@@ -85,7 +85,7 @@ declare class FutureContainerModel implements IFutureContainerModel {
|
|
|
85
85
|
* relationship.
|
|
86
86
|
*
|
|
87
87
|
* @returns - the collection of Future models maintained by this model.
|
|
88
|
-
* @
|
|
88
|
+
* @group KOS Model
|
|
89
89
|
* @internal
|
|
90
90
|
*/
|
|
91
91
|
/**
|
package/models/models/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './config-bean-prop';
|
|
|
4
4
|
export * from './future';
|
|
5
5
|
export * from './future-container';
|
|
6
6
|
export * from './key-value';
|
|
7
|
+
export * from './kos-expression-evaluator';
|
|
7
8
|
export * from './kos-log-manager';
|
|
8
9
|
export * from './kos-time';
|
|
9
10
|
export * from './log-stream';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/models/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/models/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|