@kosdev-code/kos-ui-sdk 3.0.25 → 3.0.27
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/.kos.json +3 -2
- package/common/events/async-event-bus.d.ts +8 -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/companion-instantiator.d.ts +5 -0
- package/core/core/companion-instantiator.d.ts.map +1 -1
- package/core/core/decorators/index.d.ts +1 -0
- package/core/core/decorators/index.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-reconcile.test-d.d.ts +2 -0
- package/core/core/decorators/kos-container-aware-reconcile.test-d.d.ts.map +1 -0
- package/core/core/decorators/kos-container-aware.d.ts +191 -420
- 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-mixin.d.ts +67 -0
- package/core/core/decorators/kos-mixin.d.ts.map +1 -0
- 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 +22 -131
- package/core/core/decorators/kos-multiple-future-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-reload-aware.d.ts +14 -14
- package/core/core/decorators/kos-reload-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-service-request-helpers.d.ts +3 -1
- package/core/core/decorators/kos-service-request-helpers.d.ts.map +1 -1
- package/core/core/decorators/kos-service-request.d.ts +85 -265
- package/core/core/decorators/kos-service-request.d.ts.map +1 -1
- package/core/core/decorators/kos-state-machine.d.ts +44 -273
- package/core/core/decorators/kos-state-machine.d.ts.map +1 -1
- package/core/core/decorators/kos-topic-handler-flow-control.d.ts +37 -29
- package/core/core/decorators/kos-topic-handler-flow-control.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/kosDependency.d.ts +4 -2
- package/core/core/decorators/kosDependency.d.ts.map +1 -1
- package/core/core/decorators/kosModel.d.ts.map +1 -1
- package/core/core/decorators/kosTopicHandler.d.ts +28 -98
- package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
- package/core/core/decorators/propKeys.d.ts +1 -0
- package/core/core/decorators/propKeys.d.ts.map +1 -1
- package/core/core/extension/extension-manager.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-index.d.ts +11 -0
- package/core/core/kos-container-index.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 +22 -4
- package/core/core/kosCore.d.ts.map +1 -1
- package/core/core/kosModel.d.ts +21 -8
- package/core/core/kosModel.d.ts.map +1 -1
- package/core/core/kosModelManager.d.ts +2 -3
- package/core/core/kosModelManager.d.ts.map +1 -1
- package/core/core/lifecycle/constants.d.ts +6 -2
- package/core/core/lifecycle/constants.d.ts.map +1 -1
- package/core/core/lifecycle/kosCoreLifecycle.d.ts +11 -1
- package/core/core/lifecycle/kosCoreLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/kosModelLifecycle.d.ts +6 -0
- package/core/core/lifecycle/kosModelLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/model-machine.d.ts +6 -0
- package/core/core/lifecycle/model-machine.d.ts.map +1 -1
- package/core/core/model/kos-fsm-manager.d.ts +6 -0
- package/core/core/model/kos-fsm-manager.d.ts.map +1 -1
- package/core/core/model/kos-model-component-factory.d.ts +1 -1
- package/core/core/model/kos-model-component-factory.d.ts.map +1 -1
- package/core/core/model/kos-offline-queue.d.ts +1 -1
- package/core/core/model/kos-service-request-manager.d.ts +7 -2
- package/core/core/model/kos-service-request-manager.d.ts.map +1 -1
- package/core/core/model/kos-subscription-manager.d.ts +2 -2
- package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
- package/core/core/model/service-response-store.d.ts +4 -16
- package/core/core/model/service-response-store.d.ts.map +1 -1
- package/core/core/reconnect/reconnect-fixture.d.ts +17 -0
- package/core/core/reconnect/reconnect-fixture.d.ts.map +1 -0
- package/core/core/registration/model-registration.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/core/transport/transport.d.ts +1 -1
- package/core/core/transport/transport.d.ts.map +1 -1
- package/core/core/transport/webSocketTransport.d.ts +10 -0
- package/core/core/transport/webSocketTransport.d.ts.map +1 -1
- package/core/types/kos-dependency.d.ts +13 -4
- package/core/types/kos-dependency.d.ts.map +1 -1
- 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 -15
- 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/model-type-guards.d.ts.map +1 -1
- package/core/util/model-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 +983 -11777
- package/index.cjs.map +1 -1
- package/index.js +1056 -11854
- 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 +23 -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/gpio-chip/gpio-chip-builders.d.ts +14 -0
- package/models/models/gpio-chip/gpio-chip-builders.d.ts.map +1 -0
- package/models/models/gpio-chip/gpio-chip-container-model.d.ts +2 -1
- package/models/models/gpio-chip/gpio-chip-container-model.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/expression-parse-cache.d.ts +29 -0
- package/models/models/kos-expression-evaluator/expression-parse-cache.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/index.d.ts +1 -0
- package/models/models/kos-expression-evaluator/index.d.ts.map +1 -1
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +73 -105
- 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/trouble-container/trouble-builders.d.ts +11 -0
- package/models/models/trouble-container/trouble-builders.d.ts.map +1 -0
- package/models/models/trouble-container/trouble-container-model.d.ts +2 -1
- package/models/models/trouble-container/trouble-container-model.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 +5 -5
- package/models/utils/services/kos/daily/service.d.ts.map +1 -1
- package/models/utils/services/vfs/daily/service.d.ts +5 -5
- package/models/utils/services/vfs/daily/service.d.ts.map +1 -1
- package/models/utils/timer-manager.d.ts.map +1 -1
- package/package.json +2 -2
- package/{index-CRb8ucfF.cjs → software-info-registration-Le3V0a6v.cjs} +12187 -986
- package/software-info-registration-Le3V0a6v.cjs.map +1 -0
- package/software-info-registration-kSGacOka.js +24809 -0
- package/software-info-registration-kSGacOka.js.map +1 -0
- package/testing/index.d.ts +32 -34
- package/testing/index.d.ts.map +1 -1
- package/testing.cjs +2 -1
- package/testing.cjs.map +1 -1
- package/testing.js +2 -1
- package/testing.js.map +1 -1
- package/ui/components/connection-dev-button/connection-dev-button-styles.d.ts +9 -0
- package/ui/components/connection-dev-button/connection-dev-button-styles.d.ts.map +1 -0
- package/ui/components/connection-dev-button/index.d.ts +36 -0
- package/ui/components/connection-dev-button/index.d.ts.map +1 -0
- package/ui/components/connection-dev-button/use-connection-dev-state.d.ts +29 -0
- package/ui/components/connection-dev-button/use-connection-dev-state.d.ts.map +1 -0
- package/ui/components/index.d.ts +1 -0
- package/ui/components/index.d.ts.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/index-CRb8ucfF.cjs.map +0 -1
- package/index-YzHb2lnB.js +0 -13607
- package/index-YzHb2lnB.js.map +0 -1
|
@@ -1,96 +1,111 @@
|
|
|
1
1
|
import { IKosModelContainer } from '../kos-container-model';
|
|
2
2
|
import { IKosDataModel } from '../kosModel';
|
|
3
3
|
type MaybePromise<T> = T | Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* How the injected `reconcile(list)` turns a full list of DTOs into the container's
|
|
6
|
+
* contents. Pass named functions from the model's builders module.
|
|
7
|
+
*
|
|
8
|
+
* @template T The type of models contained in the container
|
|
9
|
+
* @template D The incoming DTO type
|
|
10
|
+
* @template M The DTO type after `idMapper` (defaults to D)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createFolderModel, updateFolderModel } from "./folder-builders";
|
|
15
|
+
*
|
|
16
|
+
* @kosContainerAware<FolderModel>({
|
|
17
|
+
* reconcile: { create: createFolderModel, update: updateFolderModel },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @kosService core.container-aware
|
|
22
|
+
* @kosApiLevel 25
|
|
23
|
+
*/
|
|
24
|
+
export interface KosContainerReconcileOptions<T extends IKosDataModel = IKosDataModel, D extends {
|
|
25
|
+
id: string;
|
|
26
|
+
} = any, M extends {
|
|
27
|
+
id: string;
|
|
28
|
+
} = D> {
|
|
29
|
+
/**
|
|
30
|
+
* Builds a model for a DTO whose id is not in the container.
|
|
31
|
+
*/
|
|
32
|
+
create: (dto: M) => T;
|
|
33
|
+
/**
|
|
34
|
+
* Updates the existing model for a DTO whose id is already in the container, in
|
|
35
|
+
* place, so the model keeps its identity. Without it an existing id is passed to
|
|
36
|
+
* `create` and the new model replaces the old one.
|
|
37
|
+
*/
|
|
38
|
+
update?: (dto: M, model: T) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Maps each DTO before reconciling, typically to build a compound model id.
|
|
41
|
+
* `create`, `update` and `afterCreate` receive the mapped DTO.
|
|
42
|
+
*/
|
|
43
|
+
idMapper?: (dto: D) => M;
|
|
44
|
+
/**
|
|
45
|
+
* Keeps only the DTOs it returns true for. Applied before the delta, so the ids
|
|
46
|
+
* it drops are removed from the container.
|
|
47
|
+
*/
|
|
48
|
+
filter?: (dto: D) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Runs after `create` and before the new model is added to the container.
|
|
51
|
+
*/
|
|
52
|
+
afterCreate?: (model: T, dto: M) => void;
|
|
53
|
+
}
|
|
4
54
|
/**
|
|
5
55
|
* Configuration options for the @kosContainerAware decorator.
|
|
6
56
|
*
|
|
7
57
|
* @template T The type of models contained in the container (must extend IKosDataModel)
|
|
58
|
+
* @template D The DTO type `reconcile` receives
|
|
59
|
+
* @template M The DTO type after `reconcile.idMapper` (defaults to D)
|
|
8
60
|
*
|
|
9
61
|
* @kosService core.container-aware
|
|
10
62
|
* @kosApiLevel 13
|
|
11
63
|
*/
|
|
12
|
-
export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataModel
|
|
64
|
+
export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataModel, D extends {
|
|
65
|
+
id: string;
|
|
66
|
+
} = any, M extends {
|
|
67
|
+
id: string;
|
|
68
|
+
} = D> {
|
|
13
69
|
/**
|
|
14
|
-
*
|
|
70
|
+
* Name of the model property that holds the container.
|
|
15
71
|
*
|
|
16
72
|
* @default "container"
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* @kosContainerAware({ containerProperty: "devices" })
|
|
20
|
-
* class DeviceContainer {
|
|
21
|
-
* // Access via: this.devices.addModel(...)
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
73
|
*/
|
|
25
74
|
containerProperty?: string;
|
|
26
75
|
/**
|
|
27
|
-
* Whether to
|
|
28
|
-
* removeAndDestroy, removeAndDestroyAll).
|
|
76
|
+
* Whether to inject the convenience methods (getModel, addModel, removeModel, addAll,
|
|
77
|
+
* removeAll, removeAndDestroy, removeAndDestroyAll) onto the model.
|
|
29
78
|
*
|
|
30
79
|
* @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
80
|
*/
|
|
39
81
|
includeMethods?: boolean;
|
|
40
82
|
/**
|
|
41
|
-
* Whether to
|
|
83
|
+
* Whether to inject the reactive `models` and `data` getters onto the model.
|
|
42
84
|
*
|
|
43
85
|
* @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
86
|
*/
|
|
52
87
|
includeGetters?: boolean;
|
|
53
88
|
/**
|
|
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
|
-
* ```
|
|
89
|
+
* Options passed to the KosModelContainer constructor.
|
|
72
90
|
*/
|
|
73
91
|
containerOptions?: {
|
|
74
92
|
/** Default property to sort models by */
|
|
75
93
|
sortKey?: keyof T;
|
|
76
94
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* - Functions that return index keys for complex logic
|
|
95
|
+
* Indexes maintained by the container, keyed by index name. Each value is either a
|
|
96
|
+
* model property name or a function returning the index key(s) for a model.
|
|
80
97
|
*
|
|
81
98
|
* @example
|
|
82
99
|
* ```typescript
|
|
83
100
|
* indexMap: {
|
|
84
|
-
* byStatus: "connectionStatus",
|
|
85
|
-
* byType: (device) => device.type.toLowerCase(),
|
|
86
|
-
* needsUpdate: (device) => device.version < "2.0" // Boolean logic
|
|
101
|
+
* byStatus: "connectionStatus",
|
|
102
|
+
* byType: (device) => device.type.toLowerCase(),
|
|
87
103
|
* }
|
|
88
104
|
* ```
|
|
89
105
|
*/
|
|
90
106
|
indexMap?: Record<string, keyof T | ((model: T) => MaybePromise<string | string[] | undefined>)>;
|
|
91
107
|
/**
|
|
92
|
-
* Parent model ID for the container.
|
|
93
|
-
* the modelId parameter from the model's constructor.
|
|
108
|
+
* Parent model ID for the container. Defaults to the owning model's ID.
|
|
94
109
|
*
|
|
95
110
|
* @default Inferred from constructor modelId parameter
|
|
96
111
|
*/
|
|
@@ -98,27 +113,19 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
98
113
|
/** Extension identifier for the container */
|
|
99
114
|
extensionId?: string;
|
|
100
115
|
/**
|
|
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.
|
|
116
|
+
* Maximum number of models the container holds before it evicts and destroys
|
|
117
|
+
* models according to `evictionStrategy`.
|
|
106
118
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* containerOptions: {
|
|
110
|
-
* maxCapacity: 10000, // Safety net: expect ~100-1000 normally
|
|
111
|
-
* evictionStrategy: 'fifo'
|
|
112
|
-
* }
|
|
113
|
-
* ```
|
|
119
|
+
* This is a safety net against unbounded growth when cleanup handlers are missing,
|
|
120
|
+
* so set it well above normal usage.
|
|
114
121
|
*/
|
|
115
122
|
maxCapacity?: number;
|
|
116
123
|
/**
|
|
117
124
|
* Strategy for selecting which models to evict when maxCapacity is exceeded.
|
|
118
125
|
*
|
|
119
|
-
* - **fifo** (default):
|
|
120
|
-
* - **lru**:
|
|
121
|
-
* - **custom**:
|
|
126
|
+
* - **fifo** (default): oldest models first; suits event streams and logs
|
|
127
|
+
* - **lru**: least recently accessed models first; suits caches
|
|
128
|
+
* - **custom**: models returned by `customEvictionFilter`
|
|
122
129
|
*
|
|
123
130
|
* @default 'fifo'
|
|
124
131
|
*/
|
|
@@ -129,221 +136,55 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
129
136
|
*/
|
|
130
137
|
evictionBatchSize?: number;
|
|
131
138
|
/**
|
|
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
|
-
* ```
|
|
139
|
+
* Filter for the 'custom' eviction strategy. Returns the models that are
|
|
140
|
+
* candidates for eviction.
|
|
144
141
|
*/
|
|
145
142
|
customEvictionFilter?: (models: T[]) => T[];
|
|
146
143
|
};
|
|
147
144
|
/**
|
|
148
|
-
*
|
|
145
|
+
* Name of the getter that returns the container.
|
|
149
146
|
*
|
|
150
147
|
* @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
148
|
*/
|
|
159
149
|
modelsProperty?: string;
|
|
160
150
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
151
|
+
* Uses '_models' as the container property name, for code written before
|
|
152
|
+
* `containerProperty` existed.
|
|
163
153
|
*
|
|
164
154
|
* @default false
|
|
165
155
|
* @deprecated Use containerProperty instead for new code
|
|
166
156
|
*/
|
|
167
157
|
legacy?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Injects `reconcile(list)`, which makes the container match a full list of DTOs:
|
|
160
|
+
* ids missing from the list are removed, existing ids are updated in place and new
|
|
161
|
+
* ids are created and added, in one batch. Call it from `load()` and from topic
|
|
162
|
+
* handlers that receive the full list.
|
|
163
|
+
*
|
|
164
|
+
* @kosApiLevel 25
|
|
165
|
+
*/
|
|
166
|
+
reconcile?: KosContainerReconcileOptions<T, D, M>;
|
|
168
167
|
}
|
|
169
168
|
/**
|
|
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.
|
|
174
|
-
*
|
|
175
|
-
* ## Interface Merging Pattern
|
|
176
|
-
*
|
|
177
|
-
* ```typescript
|
|
178
|
-
* // 1. Declare interface merging BEFORE the class
|
|
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.
|
|
219
|
-
*
|
|
220
|
-
* @template T The type of models contained in the container (must extend IKosDataModel)
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```typescript
|
|
224
|
-
* // Basic usage with minimal configuration
|
|
225
|
-
* interface DeviceContainerModelImpl extends KosContainerAware<DeviceModel> {}
|
|
226
|
-
*
|
|
227
|
-
* @kosModel("device-container-model")
|
|
228
|
-
* @kosContainerAware<DeviceModel>()
|
|
229
|
-
* 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
|
-
* get deviceCount(): number {
|
|
242
|
-
* return this.data.length; // Reactive array getter injected by decorator
|
|
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);
|
|
267
|
-
* }
|
|
169
|
+
* The `reconcile` member @kosContainerAware injects when the decorator declares the
|
|
170
|
+
* `reconcile` option.
|
|
268
171
|
*
|
|
269
|
-
*
|
|
270
|
-
* return this.container.getIndexByKey("byRole", role);
|
|
271
|
-
* }
|
|
272
|
-
* }
|
|
273
|
-
* ```
|
|
274
|
-
*
|
|
275
|
-
* @see {@link kosContainerAware} - The decorator function
|
|
276
|
-
* @see {@link KosContainerAwareOptions} - Configuration options
|
|
172
|
+
* @template D The DTO type the list holds
|
|
277
173
|
*
|
|
278
174
|
* @kosService core.container-aware
|
|
279
|
-
* @kosApiLevel
|
|
175
|
+
* @kosApiLevel 25
|
|
280
176
|
*/
|
|
281
|
-
export interface
|
|
282
|
-
/**
|
|
283
|
-
* Core container that manages the collection of models.
|
|
284
|
-
* Provides methods to add, remove, and query model instances.
|
|
285
|
-
* Automatically injected by @kosContainerAware decorator.
|
|
286
|
-
*/
|
|
287
|
-
container: IKosModelContainer<T>;
|
|
288
|
-
/**
|
|
289
|
-
* Retrieves a model from the container by its ID.
|
|
290
|
-
* @param id - The unique identifier of the model to retrieve
|
|
291
|
-
* @returns The model instance if found, undefined otherwise
|
|
292
|
-
*/
|
|
293
|
-
getModel(id: string): T | undefined;
|
|
294
|
-
/**
|
|
295
|
-
* Adds a model to the container.
|
|
296
|
-
* @param model - The model instance to add
|
|
297
|
-
*/
|
|
298
|
-
addModel(model: T): void;
|
|
177
|
+
export interface KosContainerReconcile<D> {
|
|
299
178
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
|
|
303
|
-
removeModel(id: string): void;
|
|
304
|
-
/**
|
|
305
|
-
* Adds multiple models to the container at once.
|
|
306
|
-
* @param models - Array of model instances to add
|
|
307
|
-
* @kosApiLevel 19
|
|
308
|
-
*/
|
|
309
|
-
addAll(models: T[]): void;
|
|
310
|
-
/**
|
|
311
|
-
* Removes multiple models from the container by their IDs.
|
|
312
|
-
* @param ids - Array of unique identifiers of the models to remove
|
|
313
|
-
* @kosApiLevel 19
|
|
314
|
-
*/
|
|
315
|
-
removeAll(ids: string[]): void;
|
|
316
|
-
/**
|
|
317
|
-
* Removes a model from the container and destroys it.
|
|
318
|
-
* Convenience method that combines removeModel() and destroyKosModel().
|
|
319
|
-
* @param id - The unique identifier of the model to remove and destroy
|
|
320
|
-
* @kosApiLevel 19
|
|
321
|
-
*/
|
|
322
|
-
removeAndDestroy(id: string): Promise<void>;
|
|
323
|
-
/**
|
|
324
|
-
* Removes multiple models from the container and destroys them.
|
|
325
|
-
* Convenience method that combines removeAll() and destroyKosModel().
|
|
326
|
-
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
327
|
-
* @kosApiLevel 19
|
|
328
|
-
*/
|
|
329
|
-
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
330
|
-
/**
|
|
331
|
-
* The container instance managing the models.
|
|
332
|
-
* Readonly property that provides access to the KosModelContainer.
|
|
333
|
-
* Compatible with IKosModelHolder interface.
|
|
334
|
-
* Updates automatically when models are added or removed.
|
|
335
|
-
*/
|
|
336
|
-
readonly models: IKosModelContainer<T>;
|
|
337
|
-
/**
|
|
338
|
-
* Reactive array of all model instances in the container.
|
|
339
|
-
* This is the actual array of models, compatible with IKosModelHolder interface.
|
|
340
|
-
* Updates automatically when models are added or removed.
|
|
179
|
+
* Makes the container match `list`: removes models whose id is missing, updates
|
|
180
|
+
* existing models in place and adds new ones.
|
|
181
|
+
* @param list - The full list of DTOs
|
|
341
182
|
*/
|
|
342
|
-
|
|
183
|
+
reconcile(list: D[]): void;
|
|
343
184
|
}
|
|
185
|
+
type KosContainerReconcileFor<D> = [D] extends [never] ? unknown : KosContainerReconcile<D>;
|
|
344
186
|
/**
|
|
345
|
-
*
|
|
346
|
-
* Used internally by both KosContainerAware and KosContainerAwareWithProp.
|
|
187
|
+
* Container-aware members shared by KosContainerAware and KosContainerAwareWithProp.
|
|
347
188
|
*
|
|
348
189
|
* @template T The type of models contained in the container
|
|
349
190
|
*
|
|
@@ -363,7 +204,7 @@ export interface KosContainerAwareBase<T extends IKosDataModel = IKosDataModel>
|
|
|
363
204
|
*/
|
|
364
205
|
addModel(model: T): void;
|
|
365
206
|
/**
|
|
366
|
-
* Removes a model from the container by its ID.
|
|
207
|
+
* Removes a model from the container by its ID without destroying it.
|
|
367
208
|
* @param id - The unique identifier of the model to remove
|
|
368
209
|
*/
|
|
369
210
|
removeModel(id: string): void;
|
|
@@ -374,187 +215,145 @@ export interface KosContainerAwareBase<T extends IKosDataModel = IKosDataModel>
|
|
|
374
215
|
*/
|
|
375
216
|
addAll(models: T[]): void;
|
|
376
217
|
/**
|
|
377
|
-
* Removes multiple models from the container by their IDs.
|
|
218
|
+
* Removes multiple models from the container by their IDs without destroying them.
|
|
378
219
|
* @param ids - Array of unique identifiers of the models to remove
|
|
379
220
|
* @kosApiLevel 19
|
|
380
221
|
*/
|
|
381
222
|
removeAll(ids: string[]): void;
|
|
382
223
|
/**
|
|
383
224
|
* Removes a model from the container and destroys it.
|
|
384
|
-
* Convenience method that combines removeModel() and destroyKosModel().
|
|
385
225
|
* @param id - The unique identifier of the model to remove and destroy
|
|
386
226
|
* @kosApiLevel 19
|
|
387
227
|
*/
|
|
388
228
|
removeAndDestroy(id: string): Promise<void>;
|
|
389
229
|
/**
|
|
390
230
|
* Removes multiple models from the container and destroys them.
|
|
391
|
-
* Convenience method that combines removeAll() and destroyKosModel().
|
|
392
231
|
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
393
232
|
* @kosApiLevel 19
|
|
394
233
|
*/
|
|
395
234
|
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
396
235
|
/**
|
|
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.
|
|
236
|
+
* The container instance, compatible with IKosModelHolder.
|
|
401
237
|
*/
|
|
402
238
|
readonly models: IKosModelContainer<T>;
|
|
403
239
|
/**
|
|
404
|
-
* Reactive array of all model instances in the container
|
|
405
|
-
*
|
|
406
|
-
* Updates automatically when models are added or removed.
|
|
240
|
+
* Reactive array of all model instances in the container, compatible with
|
|
241
|
+
* IKosModelHolder.
|
|
407
242
|
*/
|
|
408
243
|
data: T[];
|
|
409
244
|
}
|
|
410
245
|
/**
|
|
411
|
-
*
|
|
246
|
+
* Members that @kosContainerAware injects into a model.
|
|
412
247
|
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
248
|
+
* Declare an interface with the same name as the class that extends this type so the
|
|
249
|
+
* injected members are typed (TypeScript interface merging). When the decorator uses a
|
|
250
|
+
* custom `containerProperty`, extend {@link KosContainerAwareWithProp} instead.
|
|
415
251
|
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
252
|
+
* The `models` and `data` getters are reactive, so a `kosComponent` reading them
|
|
253
|
+
* re-renders when the container contents change.
|
|
254
|
+
*
|
|
255
|
+
* Pass the DTO type as `D` when the decorator declares the `reconcile` option, so
|
|
256
|
+
* `this.reconcile(list)` is typed.
|
|
257
|
+
*
|
|
258
|
+
* @template T The type of models contained in the container (must extend IKosDataModel)
|
|
259
|
+
* @template D The DTO type `reconcile` receives; omit it when `reconcile` is not declared
|
|
418
260
|
*
|
|
419
261
|
* @example
|
|
420
262
|
* ```typescript
|
|
421
|
-
*
|
|
422
|
-
* interface DeviceManagerImpl extends KosContainerAwareWithProp<DeviceModel, "devices"> {}
|
|
423
|
-
*
|
|
424
|
-
* @kosModel("device-manager")
|
|
425
|
-
* @kosContainerAware<DeviceModel>({ containerProperty: "devices" })
|
|
426
|
-
* class DeviceManagerImpl implements IKosDataModel {
|
|
427
|
-
* constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
|
|
428
|
-
* this.id = modelId;
|
|
429
|
-
* }
|
|
263
|
+
* interface DeviceContainerModelImpl extends KosContainerAware<DeviceModel> {}
|
|
430
264
|
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
265
|
+
* @kosModel("device-container-model")
|
|
266
|
+
* @kosContainerAware<DeviceModel>({
|
|
267
|
+
* containerOptions: { indexMap: { byType: "deviceType" } },
|
|
268
|
+
* })
|
|
269
|
+
* class DeviceContainerModelImpl implements IKosDataModel {
|
|
270
|
+
* get deviceCount(): number {
|
|
271
|
+
* return this.data.length;
|
|
434
272
|
* }
|
|
435
273
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* return this.data.length;
|
|
274
|
+
* devicesOfType(type: string): DeviceModel[] {
|
|
275
|
+
* return this.container.getIndexByKey("byType", type);
|
|
439
276
|
* }
|
|
440
277
|
* }
|
|
441
278
|
* ```
|
|
442
279
|
*
|
|
443
280
|
* @example
|
|
444
281
|
* ```typescript
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
* byRole: "role"
|
|
453
|
-
* }
|
|
454
|
-
* }
|
|
282
|
+
* import { createFolderModel, updateFolderModel, type FolderDto } from "./folder-builders";
|
|
283
|
+
*
|
|
284
|
+
* interface FolderContainerModelImpl extends KosContainerAware<FolderModel, FolderDto> {}
|
|
285
|
+
*
|
|
286
|
+
* @kosModel("folder-container-model")
|
|
287
|
+
* @kosContainerAware<FolderModel>({
|
|
288
|
+
* reconcile: { create: createFolderModel, update: updateFolderModel },
|
|
455
289
|
* })
|
|
456
|
-
* class
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
290
|
+
* class FolderContainerModelImpl implements IKosDataModel {
|
|
291
|
+
* async load(): Promise<void> {
|
|
292
|
+
* const [error, folders] = await this.fetchFolders();
|
|
293
|
+
* if (!error) this.reconcile(folders);
|
|
460
294
|
* }
|
|
461
295
|
* }
|
|
462
296
|
* ```
|
|
463
297
|
*
|
|
298
|
+
* @see {@link kosContainerAware} - The decorator function
|
|
299
|
+
* @see {@link KosContainerAwareOptions} - Configuration options
|
|
300
|
+
*
|
|
464
301
|
* @kosService core.container-aware
|
|
302
|
+
* @kosApiLevel 13
|
|
465
303
|
*/
|
|
466
|
-
export type
|
|
467
|
-
|
|
468
|
-
|
|
304
|
+
export type KosContainerAware<T extends IKosDataModel = IKosDataModel, D = never> = KosContainerAwareBase<T> & {
|
|
305
|
+
/**
|
|
306
|
+
* Container that manages the collection of models.
|
|
307
|
+
*/
|
|
308
|
+
container: IKosModelContainer<T>;
|
|
309
|
+
} & KosContainerReconcileFor<D>;
|
|
469
310
|
/**
|
|
470
|
-
*
|
|
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
|
|
311
|
+
* Members that @kosContainerAware injects into a model whose decorator sets a custom
|
|
312
|
+
* `containerProperty`. `P` must match that property name.
|
|
487
313
|
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
314
|
+
* @template T The type of models contained in the container
|
|
315
|
+
* @template P The custom property name for the container (string literal type)
|
|
316
|
+
* @template D The DTO type `reconcile` receives; omit it when `reconcile` is not declared
|
|
491
317
|
*
|
|
318
|
+
* @example
|
|
492
319
|
* ```typescript
|
|
493
|
-
* interface
|
|
320
|
+
* interface DeviceManagerImpl extends KosContainerAwareWithProp<DeviceModel, "devices"> {}
|
|
494
321
|
*
|
|
495
|
-
* @
|
|
496
|
-
*
|
|
497
|
-
*
|
|
322
|
+
* @kosModel("device-manager")
|
|
323
|
+
* @kosContainerAware<DeviceModel>({ containerProperty: "devices" })
|
|
324
|
+
* class DeviceManagerImpl implements IKosDataModel {
|
|
325
|
+
* addDevice(device: DeviceModel): void {
|
|
326
|
+
* this.devices.addModel(device);
|
|
327
|
+
* }
|
|
498
328
|
* }
|
|
499
329
|
* ```
|
|
500
330
|
*
|
|
501
|
-
*
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
*
|
|
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
|
|
331
|
+
* @kosService core.container-aware
|
|
332
|
+
*/
|
|
333
|
+
export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P extends string = "container", D = never> = KosContainerAwareBase<T> & {
|
|
334
|
+
[K in P]: IKosModelContainer<T>;
|
|
335
|
+
} & KosContainerReconcileFor<D>;
|
|
336
|
+
/**
|
|
337
|
+
* Class decorator that gives a KOS model a container of child models.
|
|
511
338
|
*
|
|
512
|
-
*
|
|
513
|
-
* -
|
|
514
|
-
*
|
|
515
|
-
* -
|
|
516
|
-
*
|
|
517
|
-
*
|
|
339
|
+
* At instantiation the model gets:
|
|
340
|
+
* - a KosModelContainer on `container` (or `containerProperty`), with `parentId`
|
|
341
|
+
* defaulting to the model's ID
|
|
342
|
+
* - the convenience methods (`getModel`, `addModel`, `removeModel`, `addAll`,
|
|
343
|
+
* `removeAll`, `removeAndDestroy`, `removeAndDestroyAll`) unless `includeMethods`
|
|
344
|
+
* is false
|
|
345
|
+
* - the reactive `models` and `data` getters unless `includeGetters` is false
|
|
346
|
+
* - `reconcile(list)` when the `reconcile` option is declared
|
|
518
347
|
*
|
|
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
|
-
* }
|
|
348
|
+
* The container is registered as a child model, so it follows the owner's lifecycle
|
|
349
|
+
* and is cleaned up when the owner is destroyed.
|
|
526
350
|
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
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
|
|
351
|
+
* `removeModel`/`removeAll` only take models out of the container; use them when the
|
|
352
|
+
* model lives on elsewhere (for example, moving it to another container).
|
|
353
|
+
* `removeAndDestroy`/`removeAndDestroyAll` also destroy the removed models.
|
|
538
354
|
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
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
|
-
* ```
|
|
355
|
+
* Pair the decorator with an interface that extends {@link KosContainerAware} (see
|
|
356
|
+
* that type for an example) so the injected members are typed.
|
|
558
357
|
*
|
|
559
358
|
* @param options Configuration options for the decorator
|
|
560
359
|
* @returns A class decorator that modifies the target class prototype
|
|
@@ -564,48 +363,16 @@ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P
|
|
|
564
363
|
*
|
|
565
364
|
* @example
|
|
566
365
|
* ```typescript
|
|
567
|
-
* // Minimal configuration - parentId automatically inferred
|
|
568
366
|
* interface ItemContainerModelImpl extends KosContainerAware<ItemModel> {}
|
|
569
367
|
*
|
|
368
|
+
* @kosModel("item-container-model")
|
|
570
369
|
* @kosContainerAware<ItemModel>()
|
|
571
370
|
* class ItemContainerModelImpl implements IKosDataModel {
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
* this.id = modelId;
|
|
576
|
-
* // Container automatically created with parentId: modelId
|
|
371
|
+
* @kosTopicHandler({ topic: "/items/removed", websocket: true })
|
|
372
|
+
* async handleItemRemoved(id: string) {
|
|
373
|
+
* await this.removeAndDestroy(id);
|
|
577
374
|
* }
|
|
578
375
|
* }
|
|
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"
|
|
604
|
-
* }
|
|
605
|
-
* })
|
|
606
|
-
* class LegacyContainerModelImpl implements IKosDataModel {
|
|
607
|
-
* // Container available as this._models for backward compatibility
|
|
608
|
-
* }
|
|
609
376
|
* ```
|
|
610
377
|
*
|
|
611
378
|
* @category KOS Model Decorator
|
|
@@ -613,6 +380,10 @@ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P
|
|
|
613
380
|
* @kosService core.container-aware
|
|
614
381
|
* @kosApiLevel 13
|
|
615
382
|
*/
|
|
616
|
-
export declare function kosContainerAware<T extends IKosDataModel = IKosDataModel
|
|
383
|
+
export declare function kosContainerAware<T extends IKosDataModel = IKosDataModel, D extends {
|
|
384
|
+
id: string;
|
|
385
|
+
} = any, M extends {
|
|
386
|
+
id: string;
|
|
387
|
+
} = D>(options?: KosContainerAwareOptions<T, D, M>): ClassDecorator;
|
|
617
388
|
export {};
|
|
618
389
|
//# sourceMappingURL=kos-container-aware.d.ts.map
|