@kosdev-code/kos-ui-sdk 0.1.0-next.943 → 0.1.0-next.948
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/common/events/async-event-bus.d.ts +2 -11
- package/common/events/async-event-bus.d.ts.map +1 -1
- package/common/events/eventBus.d.ts +1 -18
- package/common/events/eventBus.d.ts.map +1 -1
- package/core/core/decorators/kos-child.d.ts +2 -3
- package/core/core/decorators/kos-child.d.ts.map +1 -1
- package/core/core/decorators/kos-companion.d.ts +25 -87
- package/core/core/decorators/kos-companion.d.ts.map +1 -1
- package/core/core/decorators/kos-container-aware.d.ts +67 -358
- package/core/core/decorators/kos-container-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-execute-service-request.d.ts +7 -11
- package/core/core/decorators/kos-execute-service-request.d.ts.map +1 -1
- package/core/core/decorators/kos-execution-context.d.ts +14 -31
- package/core/core/decorators/kos-execution-context.d.ts.map +1 -1
- package/core/core/decorators/kos-future-aware.d.ts +21 -74
- package/core/core/decorators/kos-future-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-http-decorators.d.ts +18 -62
- package/core/core/decorators/kos-http-decorators.d.ts.map +1 -1
- package/core/core/decorators/kos-logger-aware.d.ts +10 -60
- package/core/core/decorators/kos-logger-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-model-effect.d.ts +10 -9
- package/core/core/decorators/kos-model-effect.d.ts.map +1 -1
- package/core/core/decorators/kos-multiple-future-aware.d.ts +21 -94
- package/core/core/decorators/kos-multiple-future-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-reload-aware.d.ts +12 -16
- package/core/core/decorators/kos-reload-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-service-request.d.ts +80 -238
- package/core/core/decorators/kos-service-request.d.ts.map +1 -1
- package/core/core/decorators/kos-state-machine.d.ts +35 -275
- package/core/core/decorators/kos-state-machine.d.ts.map +1 -1
- package/core/core/decorators/kos-trouble-aware.d.ts +9 -43
- package/core/core/decorators/kos-trouble-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-view-model.d.ts +20 -100
- package/core/core/decorators/kos-view-model.d.ts.map +1 -1
- package/core/core/decorators/kosTopicHandler.d.ts +28 -89
- package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
- package/core/core/indexing/index.d.ts +2 -4
- package/core/core/indexing/index.d.ts.map +1 -1
- package/core/core/indexing/kos-container-index-aware.d.ts +17 -48
- package/core/core/indexing/kos-container-index-aware.d.ts.map +1 -1
- package/core/core/indexing/kos-index-aware.d.ts +11 -37
- package/core/core/indexing/kos-index-aware.d.ts.map +1 -1
- package/core/core/kos-container-model.d.ts +11 -32
- package/core/core/kos-container-model.d.ts.map +1 -1
- package/core/core/kos-data-container.d.ts +6 -6
- package/core/core/kos-data-container.d.ts.map +1 -1
- package/core/core/kosCore.d.ts +3 -3
- package/core/core/kosModelManager.d.ts +2 -3
- package/core/core/kosModelManager.d.ts.map +1 -1
- package/core/core/model/kos-offline-queue.d.ts +1 -1
- package/core/core/model/service-response-store.d.ts +2 -15
- package/core/core/model/service-response-store.d.ts.map +1 -1
- package/core/core/services/app-startup-service.d.ts +5 -13
- package/core/core/services/app-startup-service.d.ts.map +1 -1
- package/core/core/services/intent-service.d.ts +3 -12
- package/core/core/services/intent-service.d.ts.map +1 -1
- package/core/core/transport/mock/mock-frames.d.ts +3 -3
- package/core/types/model.d.ts +4 -8
- package/core/types/model.d.ts.map +1 -1
- package/core/types/service-response-store.d.ts +3 -11
- package/core/types/service-response-store.d.ts.map +1 -1
- package/core/types/utils/kos-fetch.d.ts +25 -37
- package/core/types/utils/kos-fetch.d.ts.map +1 -1
- package/core/util/abortable-when.d.ts +5 -6
- package/core/util/abortable-when.d.ts.map +1 -1
- package/core/util/ancestor-path-visitor.d.ts +14 -20
- package/core/util/ancestor-path-visitor.d.ts.map +1 -1
- package/core/util/container-utils.d.ts +26 -159
- package/core/util/container-utils.d.ts.map +1 -1
- package/core/util/date-utils.d.ts +9 -58
- package/core/util/date-utils.d.ts.map +1 -1
- package/core/util/debounce.d.ts +1 -8
- package/core/util/debounce.d.ts.map +1 -1
- package/core/util/kos-fetch.d.ts +1 -1
- package/core/util/kos-fetch.d.ts.map +1 -1
- package/core/util/kos-model-utils.d.ts +10 -11
- package/core/util/kos-model-utils.d.ts.map +1 -1
- package/core/util/model-attribute-utils.d.ts +5 -22
- package/core/util/model-attribute-utils.d.ts.map +1 -1
- package/core/util/promise-utils.d.ts +1 -26
- package/core/util/promise-utils.d.ts.map +1 -1
- package/core/util/service-factory.d.ts +5 -23
- package/core/util/service-factory.d.ts.map +1 -1
- package/core/util/service-request-error.d.ts +3 -5
- package/core/util/service-request-error.d.ts.map +1 -1
- package/core/util/service-response.d.ts +12 -67
- package/core/util/service-response.d.ts.map +1 -1
- package/core/util/transport-not-ready-error.d.ts +11 -13
- package/core/util/transport-not-ready-error.d.ts.map +1 -1
- package/core/util/when-ready.d.ts +1 -8
- package/core/util/when-ready.d.ts.map +1 -1
- package/index.cjs +12 -21
- package/index.cjs.map +1 -1
- package/index.js +13 -22
- package/index.js.map +1 -1
- package/models/decorators/future-service.d.ts +7 -7
- package/models/models/browser-router/browser-router-model.d.ts +10 -39
- package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
- package/models/models/browser-router/browser-router-registration.d.ts +5 -77
- package/models/models/browser-router/browser-router-registration.d.ts.map +1 -1
- package/models/models/browser-router/types/index.d.ts +2 -16
- package/models/models/canvas-dispatcher/canvas-dispatcher-registration.d.ts +5 -77
- package/models/models/canvas-dispatcher/canvas-dispatcher-registration.d.ts.map +1 -1
- package/models/models/canvas-renderer/canvas-renderer-registration.d.ts +5 -75
- package/models/models/canvas-renderer/canvas-renderer-registration.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model-builder.d.ts +4 -11
- package/models/models/config-bean/config-bean-model-builder.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model.d.ts +14 -66
- package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts +15 -62
- 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 +34 -215
- package/models/models/device/device-model.d.ts +20 -199
- package/models/models/device/device-model.d.ts.map +1 -1
- package/models/models/device/device-registration.d.ts +7 -87
- package/models/models/device/device-registration.d.ts.map +1 -1
- package/models/models/device/types/index.d.ts +5 -34
- package/models/models/future/future-aware.d.ts +7 -71
- package/models/models/future/future-aware.d.ts.map +1 -1
- package/models/models/future/future-model-builder.d.ts +2 -2
- package/models/models/future/future-model.d.ts +3 -23
- package/models/models/future/future-model.d.ts.map +1 -1
- package/models/models/future/future-types.d.ts +28 -145
- package/models/models/future/future-types.d.ts.map +1 -1
- package/models/models/key-value/key-value-model.d.ts +12 -72
- package/models/models/key-value/key-value-model.d.ts.map +1 -1
- package/models/models/key-value/key-value-registration.d.ts +5 -77
- package/models/models/key-value/key-value-registration.d.ts.map +1 -1
- package/models/models/key-value/services/key-value-services.d.ts +13 -72
- package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/key-value/types/index.d.ts +3 -46
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +32 -99
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts.map +1 -1
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts +2 -12
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts.map +1 -1
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts +7 -46
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
- package/models/models/kos-log-manager/kos-log-manager-registration.d.ts +5 -80
- package/models/models/kos-log-manager/kos-log-manager-registration.d.ts.map +1 -1
- package/models/models/kos-log-manager/types/index.d.ts +13 -156
- package/models/models/kos-time/kos-time-model.d.ts +8 -39
- package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
- package/models/models/kos-time/kos-time-registration.d.ts +6 -73
- package/models/models/kos-time/kos-time-registration.d.ts.map +1 -1
- package/models/models/kos-time/types/index.d.ts +3 -58
- package/models/models/log-block/log-block-container-model.d.ts +2 -118
- package/models/models/log-block/log-block-container-model.d.ts.map +1 -1
- package/models/models/log-block/log-block-container-registration.d.ts +5 -75
- package/models/models/log-block/log-block-container-registration.d.ts.map +1 -1
- package/models/models/log-block/log-block-model.d.ts +5 -168
- package/models/models/log-block/log-block-model.d.ts.map +1 -1
- package/models/models/log-block/log-block-registration.d.ts +5 -75
- package/models/models/log-block/log-block-registration.d.ts.map +1 -1
- package/models/models/log-block/types/index.d.ts +14 -81
- package/models/models/log-stream/log-stream-container-model.d.ts +8 -35
- package/models/models/log-stream/log-stream-container-model.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-container-registration.d.ts +5 -75
- package/models/models/log-stream/log-stream-container-registration.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-model.d.ts +8 -29
- package/models/models/log-stream/log-stream-model.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-registration.d.ts +5 -75
- package/models/models/log-stream/log-stream-registration.d.ts.map +1 -1
- package/models/models/log-stream/types/index.d.ts +5 -60
- package/models/models/network-interface/network-interface-container-model.d.ts +6 -35
- 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 +5 -73
- package/models/models/network-interface/network-interface-container-registration.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-model.d.ts +5 -43
- package/models/models/network-interface/network-interface-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-registration.d.ts +5 -73
- package/models/models/network-interface/network-interface-registration.d.ts.map +1 -1
- package/models/models/network-interface/types/index.d.ts +2 -16
- package/models/models/ota/ota-model.d.ts +11 -39
- package/models/models/ota/ota-model.d.ts.map +1 -1
- package/models/models/ota/ota-registration.d.ts +5 -77
- package/models/models/ota/ota-registration.d.ts.map +1 -1
- package/models/models/ota/types/index.d.ts +2 -141
- package/models/models/region-info/types/index.d.ts +19 -99
- package/models/models/region-info/types/index.d.ts.map +1 -1
- package/models/models/software-info/services/software-info-services.d.ts +2 -14
- package/models/models/software-info/services/software-info-services.d.ts.map +1 -1
- package/models/models/software-info/software-info-model.d.ts +3 -39
- package/models/models/software-info/software-info-model.d.ts.map +1 -1
- package/models/models/software-info/software-info-registration.d.ts +6 -73
- package/models/models/software-info/software-info-registration.d.ts.map +1 -1
- package/models/models/software-info/types/index.d.ts +6 -20
- package/models/models/state-bean/state-bean-model.d.ts +10 -41
- package/models/models/state-bean/state-bean-model.d.ts.map +1 -1
- package/models/models/state-bean/state-bean-registration.d.ts +6 -73
- package/models/models/state-bean/state-bean-registration.d.ts.map +1 -1
- package/models/models/state-bean/types/index.d.ts +4 -84
- package/models/models/state-prop/state-prop-model.d.ts +6 -40
- package/models/models/state-prop/state-prop-model.d.ts.map +1 -1
- package/models/models/state-prop/state-prop-registration.d.ts +6 -73
- package/models/models/state-prop/state-prop-registration.d.ts.map +1 -1
- package/models/models/state-prop/types/index.d.ts +5 -37
- package/models/models/storage-device/storage-device-container-model.d.ts +7 -273
- package/models/models/storage-device/storage-device-container-model.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-container-registration.d.ts +5 -75
- package/models/models/storage-device/storage-device-container-registration.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-model.d.ts +3 -49
- package/models/models/storage-device/storage-device-model.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-registration.d.ts +5 -75
- package/models/models/storage-device/storage-device-registration.d.ts.map +1 -1
- package/models/models/storage-device/types/index.d.ts +13 -82
- package/models/models/studio-properties/studio-properties-model.d.ts +13 -36
- package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
- package/models/models/studio-properties/studio-properties-registration.d.ts +5 -75
- package/models/models/studio-properties/studio-properties-registration.d.ts.map +1 -1
- package/models/models/studio-properties/types/index.d.ts +2 -24
- package/models/models/translation/descriptor-merge.d.ts +13 -17
- package/models/models/translation/descriptor-merge.d.ts.map +1 -1
- package/models/models/translation/services/translation-services.d.ts +19 -77
- package/models/models/translation/services/translation-services.d.ts.map +1 -1
- package/models/models/translation/test-harness.d.ts +6 -8
- package/models/models/translation/test-harness.d.ts.map +1 -1
- package/models/models/translation/translation-container-model.d.ts +7 -59
- package/models/models/translation/translation-container-model.d.ts.map +1 -1
- package/models/models/translation/translation-container-registration.d.ts +6 -73
- package/models/models/translation/translation-container-registration.d.ts.map +1 -1
- package/models/models/translation/translation-model.d.ts +17 -50
- package/models/models/translation/translation-model.d.ts.map +1 -1
- package/models/models/translation/translation-registration.d.ts +6 -73
- package/models/models/translation/translation-registration.d.ts.map +1 -1
- package/models/models/translation/types/index.d.ts +51 -276
- package/models/models/trouble/trouble-registration.d.ts +6 -73
- package/models/models/trouble/trouble-registration.d.ts.map +1 -1
- package/models/models/trouble/types/index.d.ts +17 -188
- package/models/models/trouble/utils/is-trouble-aware.d.ts +4 -85
- package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -1
- package/models/models/usb-update/usb-update-container-registration.d.ts +5 -75
- package/models/models/usb-update/usb-update-container-registration.d.ts.map +1 -1
- package/models/models/usb-update/usb-update-registration.d.ts +5 -75
- package/models/models/usb-update/usb-update-registration.d.ts.map +1 -1
- package/models/types/cancellable-promise.d.ts +6 -9
- package/models/types/cancellable-promise.d.ts.map +1 -1
- package/models/utils/await-future-call.d.ts +9 -21
- package/models/utils/await-future-call.d.ts.map +1 -1
- package/models/utils/cancellable-future-call.d.ts +8 -19
- package/models/utils/cancellable-future-call.d.ts.map +1 -1
- package/models/utils/cancellable-service.d.ts +14 -23
- package/models/utils/cancellable-service.d.ts.map +1 -1
- package/models/utils/conversion-utils.d.ts +8 -48
- package/models/utils/conversion-utils.d.ts.map +1 -1
- package/models/utils/persistence-store.d.ts +1 -1
- package/models/utils/service.d.ts +14 -48
- package/models/utils/service.d.ts.map +1 -1
- package/models/utils/services/kos/daily/service.d.ts +4 -4
- package/models/utils/services/vfs/daily/service.d.ts +4 -4
- package/models/utils/timer-manager.d.ts.map +1 -1
- package/package.json +3 -3
- package/{software-info-registration-GUbTY4KD.cjs → software-info-registration-CY_E6Rw7.cjs} +85 -368
- package/software-info-registration-CY_E6Rw7.cjs.map +1 -0
- package/{software-info-registration-CKlTQPet.js → software-info-registration-CuuEsH8v.js} +85 -368
- package/software-info-registration-CuuEsH8v.js.map +1 -0
- package/testing/index.d.ts +28 -33
- package/testing/index.d.ts.map +1 -1
- package/testing.cjs +1 -1
- package/testing.cjs.map +1 -1
- package/testing.js +1 -1
- package/testing.js.map +1 -1
- package/ui/features/canvas/hooks/use-image-renderer.d.ts +5 -4
- package/ui/features/canvas/hooks/use-image-renderer.d.ts.map +1 -1
- package/ui/hooks/use-function-warmup.d.ts +4 -14
- package/ui/hooks/use-function-warmup.d.ts.map +1 -1
- package/ui/hooks/use-kos-date-formats.d.ts +15 -29
- package/ui/hooks/use-kos-date-formats.d.ts.map +1 -1
- package/ui/hooks/use-kos-region-timezones.d.ts +4 -55
- package/ui/hooks/use-kos-region-timezones.d.ts.map +1 -1
- package/ui/hooks/use-kos-regions.d.ts +11 -23
- package/ui/hooks/use-kos-regions.d.ts.map +1 -1
- package/ui/hooks/use-kos-time-formats.d.ts +16 -31
- package/ui/hooks/use-kos-time-formats.d.ts.map +1 -1
- package/ui/hooks/use-kos-unit-systems.d.ts +13 -27
- package/ui/hooks/use-kos-unit-systems.d.ts.map +1 -1
- package/ui/hooks/view-model/use-view-model.d.ts +6 -31
- package/ui/hooks/view-model/use-view-model.d.ts.map +1 -1
- package/ui/policies/reload-on-disconnect-policy.d.ts +5 -6
- package/ui/policies/reload-on-disconnect-policy.d.ts.map +1 -1
- package/software-info-registration-CKlTQPet.js.map +0 -1
- package/software-info-registration-GUbTY4KD.cjs.map +0 -1
|
@@ -11,86 +11,45 @@ type MaybePromise<T> = T | Promise<T>;
|
|
|
11
11
|
*/
|
|
12
12
|
export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataModel> {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Name of the model property that holds the container.
|
|
15
15
|
*
|
|
16
16
|
* @default "container"
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* @kosContainerAware({ containerProperty: "devices" })
|
|
20
|
-
* class DeviceContainer {
|
|
21
|
-
* // Access via: this.devices.addModel(...)
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
17
|
*/
|
|
25
18
|
containerProperty?: string;
|
|
26
19
|
/**
|
|
27
|
-
* Whether to
|
|
28
|
-
* removeAndDestroy, removeAndDestroyAll).
|
|
20
|
+
* Whether to inject the convenience methods (getModel, addModel, removeModel, addAll,
|
|
21
|
+
* removeAll, removeAndDestroy, removeAndDestroyAll) onto the model.
|
|
29
22
|
*
|
|
30
23
|
* @default true
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* @kosContainerAware({ includeMethods: false })
|
|
34
|
-
* class Container {
|
|
35
|
-
* // Only this.container property available, no convenience methods
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
24
|
*/
|
|
39
25
|
includeMethods?: boolean;
|
|
40
26
|
/**
|
|
41
|
-
* Whether to
|
|
27
|
+
* Whether to inject the reactive `models` and `data` getters onto the model.
|
|
42
28
|
*
|
|
43
29
|
* @default true
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* @kosContainerAware({ includeGetters: false })
|
|
47
|
-
* class Container {
|
|
48
|
-
* // No this.models or this.data getters, use this.container.data directly
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
30
|
*/
|
|
52
31
|
includeGetters?: boolean;
|
|
53
32
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* @kosContainerAware({
|
|
59
|
-
* containerOptions: {
|
|
60
|
-
* sortKey: "name",
|
|
61
|
-
* indexMap: {
|
|
62
|
-
* byType: "deviceType",
|
|
63
|
-
* active: (device) => device.isOnline
|
|
64
|
-
* },
|
|
65
|
-
* parentId: "custom-parent", // Overrides automatic inference
|
|
66
|
-
* extensionId: "device-manager",
|
|
67
|
-
* maxCapacity: 1000, // Safety net for unbounded growth
|
|
68
|
-
* evictionStrategy: "fifo"
|
|
69
|
-
* }
|
|
70
|
-
* })
|
|
71
|
-
* ```
|
|
33
|
+
* Options passed to the KosModelContainer constructor.
|
|
72
34
|
*/
|
|
73
35
|
containerOptions?: {
|
|
74
36
|
/** Default property to sort models by */
|
|
75
37
|
sortKey?: keyof T;
|
|
76
38
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* - Functions that return index keys for complex logic
|
|
39
|
+
* Indexes maintained by the container, keyed by index name. Each value is either a
|
|
40
|
+
* model property name or a function returning the index key(s) for a model.
|
|
80
41
|
*
|
|
81
42
|
* @example
|
|
82
43
|
* ```typescript
|
|
83
44
|
* indexMap: {
|
|
84
|
-
* byStatus: "connectionStatus",
|
|
85
|
-
* byType: (device) => device.type.toLowerCase(),
|
|
86
|
-
* needsUpdate: (device) => device.version < "2.0" // Boolean logic
|
|
45
|
+
* byStatus: "connectionStatus",
|
|
46
|
+
* byType: (device) => device.type.toLowerCase(),
|
|
87
47
|
* }
|
|
88
48
|
* ```
|
|
89
49
|
*/
|
|
90
50
|
indexMap?: Record<string, keyof T | ((model: T) => MaybePromise<string | string[] | undefined>)>;
|
|
91
51
|
/**
|
|
92
|
-
* Parent model ID for the container.
|
|
93
|
-
* the modelId parameter from the model's constructor.
|
|
52
|
+
* Parent model ID for the container. Defaults to the owning model's ID.
|
|
94
53
|
*
|
|
95
54
|
* @default Inferred from constructor modelId parameter
|
|
96
55
|
*/
|
|
@@ -98,27 +57,19 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
98
57
|
/** Extension identifier for the container */
|
|
99
58
|
extensionId?: string;
|
|
100
59
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* **Primary use case**: Prevent memory overflow when cleanup handlers are missing or
|
|
105
|
-
* data becomes inconsistent. Set higher than normal usage to catch edge cases.
|
|
60
|
+
* Maximum number of models the container holds before it evicts and destroys
|
|
61
|
+
* models according to `evictionStrategy`.
|
|
106
62
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* containerOptions: {
|
|
110
|
-
* maxCapacity: 10000, // Safety net: expect ~100-1000 normally
|
|
111
|
-
* evictionStrategy: 'fifo'
|
|
112
|
-
* }
|
|
113
|
-
* ```
|
|
63
|
+
* This is a safety net against unbounded growth when cleanup handlers are missing,
|
|
64
|
+
* so set it well above normal usage.
|
|
114
65
|
*/
|
|
115
66
|
maxCapacity?: number;
|
|
116
67
|
/**
|
|
117
68
|
* Strategy for selecting which models to evict when maxCapacity is exceeded.
|
|
118
69
|
*
|
|
119
|
-
* - **fifo** (default):
|
|
120
|
-
* - **lru**:
|
|
121
|
-
* - **custom**:
|
|
70
|
+
* - **fifo** (default): oldest models first; suits event streams and logs
|
|
71
|
+
* - **lru**: least recently accessed models first; suits caches
|
|
72
|
+
* - **custom**: models returned by `customEvictionFilter`
|
|
122
73
|
*
|
|
123
74
|
* @default 'fifo'
|
|
124
75
|
*/
|
|
@@ -129,37 +80,20 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
129
80
|
*/
|
|
130
81
|
evictionBatchSize?: number;
|
|
131
82
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```typescript
|
|
137
|
-
* customEvictionFilter: (models) => {
|
|
138
|
-
* return models.filter(m =>
|
|
139
|
-
* m.status === 'resolved' &&
|
|
140
|
-
* Date.now() - m.resolvedAt > 3600000
|
|
141
|
-
* );
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
83
|
+
* Filter for the 'custom' eviction strategy. Returns the models that are
|
|
84
|
+
* candidates for eviction.
|
|
144
85
|
*/
|
|
145
86
|
customEvictionFilter?: (models: T[]) => T[];
|
|
146
87
|
};
|
|
147
88
|
/**
|
|
148
|
-
*
|
|
89
|
+
* Name of the getter that returns the container.
|
|
149
90
|
*
|
|
150
91
|
* @default "models"
|
|
151
|
-
* @example
|
|
152
|
-
* ```typescript
|
|
153
|
-
* @kosContainerAware({ modelsProperty: "items" })
|
|
154
|
-
* class Container {
|
|
155
|
-
* get items() { return this.container.data; } // Instead of 'models'
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
92
|
*/
|
|
159
93
|
modelsProperty?: string;
|
|
160
94
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
95
|
+
* Uses '_models' as the container property name, for code written before
|
|
96
|
+
* `containerProperty` existed.
|
|
163
97
|
*
|
|
164
98
|
* @default false
|
|
165
99
|
* @deprecated Use containerProperty instead for new code
|
|
@@ -167,107 +101,32 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
167
101
|
legacy?: boolean;
|
|
168
102
|
}
|
|
169
103
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* **IMPORTANT**: Use TypeScript interface merging to add container management properties to your model class.
|
|
173
|
-
* This provides full type safety and IntelliSense support for all injected container functionality.
|
|
104
|
+
* Members that @kosContainerAware injects into a model.
|
|
174
105
|
*
|
|
175
|
-
*
|
|
106
|
+
* Declare an interface with the same name as the class that extends this type so the
|
|
107
|
+
* injected members are typed (TypeScript interface merging). When the decorator uses a
|
|
108
|
+
* custom `containerProperty`, extend {@link KosContainerAwareWithProp} instead.
|
|
176
109
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* interface MyContainerModelImpl extends KosContainerAware<ItemModel> {}
|
|
180
|
-
*
|
|
181
|
-
* // 2. Apply decorator and implement the class
|
|
182
|
-
* @kosModel("my-container-model")
|
|
183
|
-
* @kosContainerAware<ItemModel>()
|
|
184
|
-
* export class MyContainerModelImpl implements IKosDataModel {
|
|
185
|
-
* // All container properties are now available with full type safety
|
|
186
|
-
* }
|
|
187
|
-
* ```
|
|
188
|
-
*
|
|
189
|
-
* ## Custom Container Property Name
|
|
190
|
-
*
|
|
191
|
-
* When using a custom `containerProperty` name, use `KosContainerAwareWithProp`:
|
|
192
|
-
*
|
|
193
|
-
* ```typescript
|
|
194
|
-
* // For custom container property name
|
|
195
|
-
* interface DeviceManagerImpl extends KosContainerAwareWithProp<DeviceModel, "devices"> {}
|
|
196
|
-
*
|
|
197
|
-
* @kosContainerAware<DeviceModel>({ containerProperty: "devices" })
|
|
198
|
-
* class DeviceManagerImpl implements IKosDataModel {
|
|
199
|
-
* // Access via: this.devices instead of this.container
|
|
200
|
-
* }
|
|
201
|
-
* ```
|
|
202
|
-
*
|
|
203
|
-
* ## Injected Properties and Methods
|
|
204
|
-
*
|
|
205
|
-
* The decorator automatically injects the following members (configurable via options):
|
|
206
|
-
*
|
|
207
|
-
* - **`container`**: Core KosModelContainer instance for direct access (or custom name via `containerProperty`)
|
|
208
|
-
* - **`getModel(id)`**: Retrieve a model by ID from the container
|
|
209
|
-
* - **`addModel(model)`**: Add a model to the container
|
|
210
|
-
* - **`removeModel(id)`**: Remove a model from the container by ID (does not destroy)
|
|
211
|
-
* - **`addAll(models)`**: Add multiple models to the container at once
|
|
212
|
-
* - **`removeAll(ids)`**: Remove multiple models from the container by IDs (does not destroy)
|
|
213
|
-
* - **`removeAndDestroy(id)`**: Remove a model from the container and destroy it
|
|
214
|
-
* - **`removeAndDestroyAll(ids)`**: Remove multiple models from the container and destroy them
|
|
215
|
-
* - **`models`**: Readonly KosModelContainer instance (compatible with IKosModelHolder)
|
|
216
|
-
* - **`data`**: Reactive array of all model instances (compatible with IKosModelHolder)
|
|
217
|
-
*
|
|
218
|
-
* All injected getters are reactive and will automatically update UI components when container contents change.
|
|
110
|
+
* The `models` and `data` getters are reactive, so a `kosComponent` reading them
|
|
111
|
+
* re-renders when the container contents change.
|
|
219
112
|
*
|
|
220
113
|
* @template T The type of models contained in the container (must extend IKosDataModel)
|
|
221
114
|
*
|
|
222
115
|
* @example
|
|
223
116
|
* ```typescript
|
|
224
|
-
* // Basic usage with minimal configuration
|
|
225
117
|
* interface DeviceContainerModelImpl extends KosContainerAware<DeviceModel> {}
|
|
226
118
|
*
|
|
227
119
|
* @kosModel("device-container-model")
|
|
228
|
-
* @kosContainerAware<DeviceModel>(
|
|
120
|
+
* @kosContainerAware<DeviceModel>({
|
|
121
|
+
* containerOptions: { indexMap: { byType: "deviceType" } },
|
|
122
|
+
* })
|
|
229
123
|
* class DeviceContainerModelImpl implements IKosDataModel {
|
|
230
|
-
* constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
|
|
231
|
-
* this.id = modelId;
|
|
232
|
-
* // Container automatically injected with parentId: modelId
|
|
233
|
-
* }
|
|
234
|
-
*
|
|
235
|
-
* // Use injected methods
|
|
236
|
-
* addDevice(device: DeviceModel): void {
|
|
237
|
-
* this.addModel(device); // Method injected by decorator
|
|
238
|
-
* }
|
|
239
|
-
*
|
|
240
|
-
* // Use injected reactive getters
|
|
241
124
|
* get deviceCount(): number {
|
|
242
|
-
* return this.data.length;
|
|
243
|
-
* }
|
|
244
|
-
* }
|
|
245
|
-
* ```
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* // Advanced usage with indexing and custom configuration
|
|
250
|
-
* interface UserContainerModelImpl extends KosContainerAware<UserModel> {}
|
|
251
|
-
*
|
|
252
|
-
* @kosModel("user-container-model")
|
|
253
|
-
* @kosContainerAware<UserModel>({
|
|
254
|
-
* containerOptions: {
|
|
255
|
-
* indexMap: {
|
|
256
|
-
* byRole: "role",
|
|
257
|
-
* byDepartment: "department",
|
|
258
|
-
* active: (user) => user.status === "active"
|
|
259
|
-
* },
|
|
260
|
-
* sortKey: "lastName"
|
|
261
|
-
* }
|
|
262
|
-
* })
|
|
263
|
-
* class UserContainerModelImpl implements IKosDataModel {
|
|
264
|
-
* // Access indexed data via injected container
|
|
265
|
-
* getActiveUsers(): UserModel[] {
|
|
266
|
-
* return this.container.getIndexByKey("active", true);
|
|
125
|
+
* return this.data.length;
|
|
267
126
|
* }
|
|
268
127
|
*
|
|
269
|
-
*
|
|
270
|
-
* return this.container.getIndexByKey("
|
|
128
|
+
* devicesOfType(type: string): DeviceModel[] {
|
|
129
|
+
* return this.container.getIndexByKey("byType", type);
|
|
271
130
|
* }
|
|
272
131
|
* }
|
|
273
132
|
* ```
|
|
@@ -280,9 +139,7 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
280
139
|
*/
|
|
281
140
|
export interface KosContainerAware<T extends IKosDataModel = IKosDataModel> {
|
|
282
141
|
/**
|
|
283
|
-
*
|
|
284
|
-
* Provides methods to add, remove, and query model instances.
|
|
285
|
-
* Automatically injected by @kosContainerAware decorator.
|
|
142
|
+
* Container that manages the collection of models.
|
|
286
143
|
*/
|
|
287
144
|
container: IKosModelContainer<T>;
|
|
288
145
|
/**
|
|
@@ -297,7 +154,7 @@ export interface KosContainerAware<T extends IKosDataModel = IKosDataModel> {
|
|
|
297
154
|
*/
|
|
298
155
|
addModel(model: T): void;
|
|
299
156
|
/**
|
|
300
|
-
* Removes a model from the container by its ID.
|
|
157
|
+
* Removes a model from the container by its ID without destroying it.
|
|
301
158
|
* @param id - The unique identifier of the model to remove
|
|
302
159
|
*/
|
|
303
160
|
removeModel(id: string): void;
|
|
@@ -308,42 +165,35 @@ export interface KosContainerAware<T extends IKosDataModel = IKosDataModel> {
|
|
|
308
165
|
*/
|
|
309
166
|
addAll(models: T[]): void;
|
|
310
167
|
/**
|
|
311
|
-
* Removes multiple models from the container by their IDs.
|
|
168
|
+
* Removes multiple models from the container by their IDs without destroying them.
|
|
312
169
|
* @param ids - Array of unique identifiers of the models to remove
|
|
313
170
|
* @kosApiLevel 19
|
|
314
171
|
*/
|
|
315
172
|
removeAll(ids: string[]): void;
|
|
316
173
|
/**
|
|
317
174
|
* Removes a model from the container and destroys it.
|
|
318
|
-
* Convenience method that combines removeModel() and destroyKosModel().
|
|
319
175
|
* @param id - The unique identifier of the model to remove and destroy
|
|
320
176
|
* @kosApiLevel 19
|
|
321
177
|
*/
|
|
322
178
|
removeAndDestroy(id: string): Promise<void>;
|
|
323
179
|
/**
|
|
324
180
|
* Removes multiple models from the container and destroys them.
|
|
325
|
-
* Convenience method that combines removeAll() and destroyKosModel().
|
|
326
181
|
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
327
182
|
* @kosApiLevel 19
|
|
328
183
|
*/
|
|
329
184
|
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
330
185
|
/**
|
|
331
|
-
* The container instance
|
|
332
|
-
* Readonly property that provides access to the KosModelContainer.
|
|
333
|
-
* Compatible with IKosModelHolder interface.
|
|
334
|
-
* Updates automatically when models are added or removed.
|
|
186
|
+
* The container instance, compatible with IKosModelHolder.
|
|
335
187
|
*/
|
|
336
188
|
readonly models: IKosModelContainer<T>;
|
|
337
189
|
/**
|
|
338
|
-
* Reactive array of all model instances in the container
|
|
339
|
-
*
|
|
340
|
-
* Updates automatically when models are added or removed.
|
|
190
|
+
* Reactive array of all model instances in the container, compatible with
|
|
191
|
+
* IKosModelHolder.
|
|
341
192
|
*/
|
|
342
193
|
data: T[];
|
|
343
194
|
}
|
|
344
195
|
/**
|
|
345
|
-
*
|
|
346
|
-
* Used internally by both KosContainerAware and KosContainerAwareWithProp.
|
|
196
|
+
* Container-aware members shared by KosContainerAware and KosContainerAwareWithProp.
|
|
347
197
|
*
|
|
348
198
|
* @template T The type of models contained in the container
|
|
349
199
|
*
|
|
@@ -363,7 +213,7 @@ export interface KosContainerAwareBase<T extends IKosDataModel = IKosDataModel>
|
|
|
363
213
|
*/
|
|
364
214
|
addModel(model: T): void;
|
|
365
215
|
/**
|
|
366
|
-
* Removes a model from the container by its ID.
|
|
216
|
+
* Removes a model from the container by its ID without destroying it.
|
|
367
217
|
* @param id - The unique identifier of the model to remove
|
|
368
218
|
*/
|
|
369
219
|
removeModel(id: string): void;
|
|
@@ -374,90 +224,50 @@ export interface KosContainerAwareBase<T extends IKosDataModel = IKosDataModel>
|
|
|
374
224
|
*/
|
|
375
225
|
addAll(models: T[]): void;
|
|
376
226
|
/**
|
|
377
|
-
* Removes multiple models from the container by their IDs.
|
|
227
|
+
* Removes multiple models from the container by their IDs without destroying them.
|
|
378
228
|
* @param ids - Array of unique identifiers of the models to remove
|
|
379
229
|
* @kosApiLevel 19
|
|
380
230
|
*/
|
|
381
231
|
removeAll(ids: string[]): void;
|
|
382
232
|
/**
|
|
383
233
|
* Removes a model from the container and destroys it.
|
|
384
|
-
* Convenience method that combines removeModel() and destroyKosModel().
|
|
385
234
|
* @param id - The unique identifier of the model to remove and destroy
|
|
386
235
|
* @kosApiLevel 19
|
|
387
236
|
*/
|
|
388
237
|
removeAndDestroy(id: string): Promise<void>;
|
|
389
238
|
/**
|
|
390
239
|
* Removes multiple models from the container and destroys them.
|
|
391
|
-
* Convenience method that combines removeAll() and destroyKosModel().
|
|
392
240
|
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
393
241
|
* @kosApiLevel 19
|
|
394
242
|
*/
|
|
395
243
|
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
396
244
|
/**
|
|
397
|
-
* The container instance
|
|
398
|
-
* Readonly property that provides access to the KosModelContainer.
|
|
399
|
-
* Compatible with IKosModelHolder interface.
|
|
400
|
-
* Updates automatically when models are added or removed.
|
|
245
|
+
* The container instance, compatible with IKosModelHolder.
|
|
401
246
|
*/
|
|
402
247
|
readonly models: IKosModelContainer<T>;
|
|
403
248
|
/**
|
|
404
|
-
* Reactive array of all model instances in the container
|
|
405
|
-
*
|
|
406
|
-
* Updates automatically when models are added or removed.
|
|
249
|
+
* Reactive array of all model instances in the container, compatible with
|
|
250
|
+
* IKosModelHolder.
|
|
407
251
|
*/
|
|
408
252
|
data: T[];
|
|
409
253
|
}
|
|
410
254
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* Use this interface when you specify a custom `containerProperty` in the decorator options
|
|
414
|
-
* to get proper type safety for the custom property name.
|
|
255
|
+
* Members that @kosContainerAware injects into a model whose decorator sets a custom
|
|
256
|
+
* `containerProperty`. `P` must match that property name.
|
|
415
257
|
*
|
|
416
258
|
* @template T The type of models contained in the container
|
|
417
259
|
* @template P The custom property name for the container (string literal type)
|
|
418
260
|
*
|
|
419
261
|
* @example
|
|
420
262
|
* ```typescript
|
|
421
|
-
* // Specify the custom property name "devices" in both the interface and decorator
|
|
422
263
|
* interface DeviceManagerImpl extends KosContainerAwareWithProp<DeviceModel, "devices"> {}
|
|
423
264
|
*
|
|
424
265
|
* @kosModel("device-manager")
|
|
425
266
|
* @kosContainerAware<DeviceModel>({ containerProperty: "devices" })
|
|
426
267
|
* class DeviceManagerImpl implements IKosDataModel {
|
|
427
|
-
* constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
|
|
428
|
-
* this.id = modelId;
|
|
429
|
-
* }
|
|
430
|
-
*
|
|
431
268
|
* addDevice(device: DeviceModel): void {
|
|
432
|
-
* // Access container via custom property name
|
|
433
269
|
* this.devices.addModel(device);
|
|
434
270
|
* }
|
|
435
|
-
*
|
|
436
|
-
* getDeviceCount(): number {
|
|
437
|
-
* // The 'data' property is still available
|
|
438
|
-
* return this.data.length;
|
|
439
|
-
* }
|
|
440
|
-
* }
|
|
441
|
-
* ```
|
|
442
|
-
*
|
|
443
|
-
* @example
|
|
444
|
-
* ```typescript
|
|
445
|
-
* // Custom property for user management
|
|
446
|
-
* interface UserManagerImpl extends KosContainerAwareWithProp<UserModel, "users"> {}
|
|
447
|
-
*
|
|
448
|
-
* @kosContainerAware<UserModel>({
|
|
449
|
-
* containerProperty: "users",
|
|
450
|
-
* containerOptions: {
|
|
451
|
-
* indexMap: {
|
|
452
|
-
* byRole: "role"
|
|
453
|
-
* }
|
|
454
|
-
* }
|
|
455
|
-
* })
|
|
456
|
-
* class UserManagerImpl implements IKosDataModel {
|
|
457
|
-
* getUsersByRole(role: string): UserModel[] {
|
|
458
|
-
* // Access via this.users instead of this.container
|
|
459
|
-
* return this.users.getIndexByKey("byRole", role);
|
|
460
|
-
* }
|
|
461
271
|
* }
|
|
462
272
|
* ```
|
|
463
273
|
*
|
|
@@ -467,94 +277,25 @@ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P
|
|
|
467
277
|
[K in P]: IKosModelContainer<T>;
|
|
468
278
|
};
|
|
469
279
|
/**
|
|
470
|
-
* Class decorator that
|
|
471
|
-
*
|
|
472
|
-
* This decorator eliminates the need for manual container setup by:
|
|
473
|
-
* - **Adding a container property** (default: `container`) for managing model collections
|
|
474
|
-
* - **Adding convenience methods** (`getModel`, `addModel`, `removeModel`, `addAll`, `removeAll`, `removeAndDestroy`, `removeAndDestroyAll`) if `includeMethods` is true (default)
|
|
475
|
-
* - **Adding reactive getters** (`models`, `data`) if `includeGetters` is true (default)
|
|
476
|
-
* - **Automatically inferring parentId** from the model's constructor `modelId` parameter
|
|
477
|
-
* - **Registering container as @kosChild** for proper lifecycle management and cleanup
|
|
478
|
-
* - **Supporting custom indexing** via `containerOptions.indexMap` for efficient queries
|
|
479
|
-
*
|
|
480
|
-
* ## Automatic Hierarchy Integration
|
|
481
|
-
*
|
|
482
|
-
* The decorator automatically registers the container as a `@kosChild`, ensuring:
|
|
483
|
-
* - Proper lifecycle management (init, load, destroy)
|
|
484
|
-
* - Automatic cleanup when parent model is destroyed
|
|
485
|
-
* - Participation in the KOS reactive system
|
|
486
|
-
* - Memory management and observer disposal
|
|
487
|
-
*
|
|
488
|
-
* ## TypeScript Usage
|
|
489
|
-
*
|
|
490
|
-
* **IMPORTANT**: Use TypeScript interface merging to get proper type information:
|
|
491
|
-
*
|
|
492
|
-
* ```typescript
|
|
493
|
-
* interface MyContainerModelImpl extends KosContainerAware<MyItemModel> {}
|
|
494
|
-
*
|
|
495
|
-
* @kosContainerAware<MyItemModel>()
|
|
496
|
-
* class MyContainerModelImpl implements IKosDataModel {
|
|
497
|
-
* // All container properties are now available with full type safety
|
|
498
|
-
* }
|
|
499
|
-
* ```
|
|
500
|
-
*
|
|
501
|
-
* ## Model Lifecycle: removeModel vs removeAndDestroy
|
|
280
|
+
* Class decorator that gives a KOS model a container of child models.
|
|
502
281
|
*
|
|
503
|
-
*
|
|
282
|
+
* At instantiation the model gets:
|
|
283
|
+
* - a KosModelContainer on `container` (or `containerProperty`), with `parentId`
|
|
284
|
+
* defaulting to the model's ID
|
|
285
|
+
* - the convenience methods (`getModel`, `addModel`, `removeModel`, `addAll`,
|
|
286
|
+
* `removeAll`, `removeAndDestroy`, `removeAndDestroyAll`) unless `includeMethods`
|
|
287
|
+
* is false
|
|
288
|
+
* - the reactive `models` and `data` getters unless `includeGetters` is false
|
|
504
289
|
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
* - Use when temporarily hiding models that may be re-added
|
|
508
|
-
* - Use when model lifecycle is managed elsewhere
|
|
509
|
-
* - Container handles cleanup of observers and metadata
|
|
510
|
-
* - Model remains in memory and can be used elsewhere
|
|
290
|
+
* The container is registered as a child model, so it follows the owner's lifecycle
|
|
291
|
+
* and is cleaned up when the owner is destroyed.
|
|
511
292
|
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
* - Calls destroyKosModel() automatically after removal
|
|
516
|
-
* - Ensures proper cleanup of all model resources
|
|
517
|
-
* - Model is removed from framework and memory
|
|
293
|
+
* `removeModel`/`removeAll` only take models out of the container; use them when the
|
|
294
|
+
* model lives on elsewhere (for example, moving it to another container).
|
|
295
|
+
* `removeAndDestroy`/`removeAndDestroyAll` also destroy the removed models.
|
|
518
296
|
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* @kosTopicHandler({ topic: "/device/sensor/removed" })
|
|
522
|
-
* handleSensorRemoved(id: string) {
|
|
523
|
-
* // Permanently remove - sensor is gone from system
|
|
524
|
-
* await this.removeAndDestroy(id);
|
|
525
|
-
* }
|
|
526
|
-
*
|
|
527
|
-
* // Example: Reorganization without destruction
|
|
528
|
-
* moveSensorToArchive(id: string) {
|
|
529
|
-
* const sensor = this.getModel(id);
|
|
530
|
-
* if (sensor) {
|
|
531
|
-
* this.removeModel(id); // Remove from active container
|
|
532
|
-
* this.archive.addModel(sensor); // Add to archive container
|
|
533
|
-
* }
|
|
534
|
-
* }
|
|
535
|
-
* ```
|
|
536
|
-
*
|
|
537
|
-
* ## Configuration Options
|
|
538
|
-
*
|
|
539
|
-
* ```typescript
|
|
540
|
-
* @kosContainerAware<UserModel>({
|
|
541
|
-
* containerProperty: "users", // Custom property name (default: "container")
|
|
542
|
-
* includeMethods: true, // Include convenience methods (default: true)
|
|
543
|
-
* includeGetters: true, // Include reactive getters (default: true)
|
|
544
|
-
* modelsProperty: "userList", // Custom models getter name (default: "models")
|
|
545
|
-
* legacy: false, // Use "_models" property name (default: false)
|
|
546
|
-
* containerOptions: {
|
|
547
|
-
* parentId: "custom-parent", // Override automatic parentId inference
|
|
548
|
-
* sortKey: "name", // Default sorting key
|
|
549
|
-
* extensionId: "my-extension", // Extension identifier
|
|
550
|
-
* indexMap: { // Automatic indexing for efficient queries
|
|
551
|
-
* byRole: "role", // Property-based index
|
|
552
|
-
* byStatus: (user) => user.active ? "active" : "inactive", // Function-based index
|
|
553
|
-
* admins: (user) => user.role === "admin" // Boolean index
|
|
554
|
-
* }
|
|
555
|
-
* }
|
|
556
|
-
* })
|
|
557
|
-
* ```
|
|
297
|
+
* Pair the decorator with an interface that extends {@link KosContainerAware} (see
|
|
298
|
+
* that type for an example) so the injected members are typed.
|
|
558
299
|
*
|
|
559
300
|
* @param options Configuration options for the decorator
|
|
560
301
|
* @returns A class decorator that modifies the target class prototype
|
|
@@ -564,47 +305,15 @@ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P
|
|
|
564
305
|
*
|
|
565
306
|
* @example
|
|
566
307
|
* ```typescript
|
|
567
|
-
* // Minimal configuration - parentId automatically inferred
|
|
568
308
|
* interface ItemContainerModelImpl extends KosContainerAware<ItemModel> {}
|
|
569
309
|
*
|
|
310
|
+
* @kosModel("item-container-model")
|
|
570
311
|
* @kosContainerAware<ItemModel>()
|
|
571
312
|
* class ItemContainerModelImpl implements IKosDataModel {
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
* this.id = modelId;
|
|
576
|
-
* // Container automatically created with parentId: modelId
|
|
577
|
-
* }
|
|
578
|
-
* }
|
|
579
|
-
*
|
|
580
|
-
* // With index configuration
|
|
581
|
-
* interface UserContainerModelImpl extends KosContainerAware<UserModel> {}
|
|
582
|
-
*
|
|
583
|
-
* @kosContainerAware<UserModel>({
|
|
584
|
-
* containerOptions: {
|
|
585
|
-
* indexMap: {
|
|
586
|
-
* byRole: "role",
|
|
587
|
-
* byStatus: (user) => user.status
|
|
588
|
-
* }
|
|
589
|
-
* }
|
|
590
|
-
* })
|
|
591
|
-
* class UserContainerModelImpl implements IKosDataModel {
|
|
592
|
-
* constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
|
|
593
|
-
* this.id = modelId;
|
|
594
|
-
* }
|
|
595
|
-
* }
|
|
596
|
-
*
|
|
597
|
-
* // Legacy mode for backward compatibility
|
|
598
|
-
* interface LegacyContainerModelImpl extends KosContainerAware<LegacyModel> {}
|
|
599
|
-
*
|
|
600
|
-
* @kosContainerAware<LegacyModel>({
|
|
601
|
-
* legacy: true, // Uses '_models' as property name
|
|
602
|
-
* containerOptions: {
|
|
603
|
-
* sortKey: "name"
|
|
313
|
+
* @kosTopicHandler({ topic: "/items/removed", websocket: true })
|
|
314
|
+
* async handleItemRemoved(id: string) {
|
|
315
|
+
* await this.removeAndDestroy(id);
|
|
604
316
|
* }
|
|
605
|
-
* })
|
|
606
|
-
* class LegacyContainerModelImpl implements IKosDataModel {
|
|
607
|
-
* // Container available as this._models for backward compatibility
|
|
608
317
|
* }
|
|
609
318
|
* ```
|
|
610
319
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kos-container-aware.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/core/core/decorators/kos-container-aware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACtC;;;;;;;GAOG;AACH,MAAM,WAAW,wBAAwB,CACvC,CAAC,SAAS,aAAa,GAAG,aAAa;IAEvC
|
|
1
|
+
{"version":3,"file":"kos-container-aware.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/core/core/decorators/kos-container-aware.ts"],"names":[],"mappings":"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"}
|