@kosdev-code/kos-ui-sdk 2.0.41 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/core/core/decorators/index.d.ts +4 -0
  2. package/core/core/decorators/index.d.ts.map +1 -1
  3. package/core/core/decorators/kos-companion.d.ts +125 -8
  4. package/core/core/decorators/kos-companion.d.ts.map +1 -1
  5. package/core/core/decorators/kos-container-aware.d.ts +465 -0
  6. package/core/core/decorators/kos-container-aware.d.ts.map +1 -0
  7. package/core/core/decorators/kos-future-aware.d.ts +150 -0
  8. package/core/core/decorators/kos-future-aware.d.ts.map +1 -0
  9. package/core/core/decorators/kos-logger-aware.d.ts +96 -0
  10. package/core/core/decorators/kos-logger-aware.d.ts.map +1 -0
  11. package/core/core/decorators/kos-trouble-aware.d.ts +71 -0
  12. package/core/core/decorators/kos-trouble-aware.d.ts.map +1 -0
  13. package/core/core/decorators/kosModel.d.ts +8 -2
  14. package/core/core/decorators/kosModel.d.ts.map +1 -1
  15. package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
  16. package/core/core/decorators/propKeys.d.ts +4 -0
  17. package/core/core/decorators/propKeys.d.ts.map +1 -1
  18. package/core/core/extension/extension-manager.d.ts +1 -1
  19. package/core/core/extension/extension-manager.d.ts.map +1 -1
  20. package/core/core/kosCore.d.ts.map +1 -1
  21. package/core/core/registration/index.d.ts +1 -0
  22. package/core/core/registration/index.d.ts.map +1 -1
  23. package/core/index.d.ts +1 -1
  24. package/core/index.d.ts.map +1 -1
  25. package/core/util/container-utils.d.ts +3 -2
  26. package/core/util/container-utils.d.ts.map +1 -1
  27. package/core/util/observable-proxy-map.d.ts.map +1 -1
  28. package/index.cjs +79 -76
  29. package/index.cjs.map +1 -1
  30. package/index.d.cts +1 -0
  31. package/index.d.ts +1 -0
  32. package/index.d.ts.map +1 -1
  33. package/index.js +9672 -7760
  34. package/index.js.map +1 -1
  35. package/models/models/browser-router/browser-router-model.d.ts +80 -1
  36. package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
  37. package/models/models/browser-router/types/index.d.ts +25 -1
  38. package/models/models/config-bean/config-bean-model-builder.d.ts +4 -2
  39. package/models/models/config-bean/config-bean-model-builder.d.ts.map +1 -1
  40. package/models/models/config-bean/config-bean-model.d.ts +117 -13
  41. package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
  42. package/models/models/config-bean/config-bean-types.d.ts +6 -3
  43. package/models/models/config-bean/config-bean-types.d.ts.map +1 -1
  44. package/models/models/config-bean/types/index.d.ts +33 -0
  45. package/models/models/config-bean-prop/config-bean-prop-model.d.ts +112 -1
  46. package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
  47. package/models/models/config-bean-prop/types/index.d.ts +293 -17
  48. package/models/models/device/device-model.d.ts +219 -9
  49. package/models/models/device/device-model.d.ts.map +1 -1
  50. package/models/models/device/device-registration.d.ts +61 -48
  51. package/models/models/device/device-registration.d.ts.map +1 -1
  52. package/models/models/device/types/index.d.ts +41 -0
  53. package/models/models/future/future-aware.d.ts +82 -0
  54. package/models/models/future/future-aware.d.ts.map +1 -1
  55. package/models/models/future/future-model.d.ts +34 -5
  56. package/models/models/future/future-model.d.ts.map +1 -1
  57. package/models/models/future/future-types.d.ts +186 -7
  58. package/models/models/future/future-types.d.ts.map +1 -1
  59. package/models/models/future-container/future-container-model.d.ts +2 -2
  60. package/models/models/index.d.ts +1 -0
  61. package/models/models/index.d.ts.map +1 -1
  62. package/models/models/key-value/index.d.ts +4 -0
  63. package/models/models/key-value/index.d.ts.map +1 -1
  64. package/models/models/key-value/key-value-model.d.ts +111 -0
  65. package/models/models/key-value/key-value-model.d.ts.map +1 -1
  66. package/models/models/key-value/services/key-value-services.d.ts +124 -2
  67. package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
  68. package/models/models/key-value/types/index.d.ts +56 -0
  69. package/models/models/kos-expression-evaluator/index.d.ts +4 -0
  70. package/models/models/kos-expression-evaluator/index.d.ts.map +1 -0
  71. package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +209 -0
  72. package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts.map +1 -0
  73. package/models/models/kos-expression-evaluator/services/index.d.ts +6 -0
  74. package/models/models/kos-expression-evaluator/services/index.d.ts.map +1 -0
  75. package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts +15 -0
  76. package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts.map +1 -0
  77. package/models/models/kos-expression-evaluator/types/index.d.ts +1 -0
  78. package/models/models/kos-log-manager/kos-log-manager-model.d.ts +61 -14
  79. package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
  80. package/models/models/kos-log-manager/types/index.d.ts +187 -0
  81. package/models/models/kos-time/kos-time-model.d.ts +64 -0
  82. package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
  83. package/models/models/kos-time/types/index.d.ts +80 -0
  84. package/models/models/log-block/log-block-container-model.d.ts +132 -0
  85. package/models/models/log-block/log-block-container-model.d.ts.map +1 -1
  86. package/models/models/log-block/log-block-model.d.ts +185 -0
  87. package/models/models/log-block/log-block-model.d.ts.map +1 -1
  88. package/models/models/log-block/types/index.d.ts +129 -0
  89. package/models/models/log-stream/index.d.ts +6 -2
  90. package/models/models/log-stream/index.d.ts.map +1 -1
  91. package/models/models/log-stream/log-stream-container-model.d.ts +62 -0
  92. package/models/models/log-stream/log-stream-container-model.d.ts.map +1 -1
  93. package/models/models/log-stream/log-stream-model.d.ts +55 -0
  94. package/models/models/log-stream/log-stream-model.d.ts.map +1 -1
  95. package/models/models/log-stream/services/log-stream-services.d.ts +2 -1
  96. package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
  97. package/models/models/log-stream/types/index.d.ts +77 -0
  98. package/models/models/network-interface/index.d.ts +6 -2
  99. package/models/models/network-interface/index.d.ts.map +1 -1
  100. package/models/models/network-interface/network-interface-container-model.d.ts +62 -0
  101. package/models/models/network-interface/network-interface-container-model.d.ts.map +1 -1
  102. package/models/models/network-interface/network-interface-container-registration.d.ts +2 -1
  103. package/models/models/network-interface/network-interface-container-registration.d.ts.map +1 -1
  104. package/models/models/network-interface/network-interface-model.d.ts +77 -0
  105. package/models/models/network-interface/network-interface-model.d.ts.map +1 -1
  106. package/models/models/network-interface/network-interface-registration.d.ts +2 -1
  107. package/models/models/network-interface/network-interface-registration.d.ts.map +1 -1
  108. package/models/models/network-interface/services/network-interface-services.d.ts +54 -0
  109. package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
  110. package/models/models/network-interface/types/index.d.ts +21 -0
  111. package/models/models/ota/ota-model.d.ts +82 -3
  112. package/models/models/ota/ota-model.d.ts.map +1 -1
  113. package/models/models/ota/types/index.d.ts +146 -0
  114. package/models/models/region-info/region-info-model.d.ts +7 -3
  115. package/models/models/region-info/region-info-model.d.ts.map +1 -1
  116. package/models/models/region-info/services/region-info-services.d.ts.map +1 -1
  117. package/models/models/region-info/types/index.d.ts +141 -13
  118. package/models/models/region-info/types/index.d.ts.map +1 -1
  119. package/models/models/software-info/software-info-model.d.ts +74 -2
  120. package/models/models/software-info/software-info-model.d.ts.map +1 -1
  121. package/models/models/software-info/types/index.d.ts +48 -16
  122. package/models/models/state-bean/state-bean-model.d.ts +86 -9
  123. package/models/models/state-bean/state-bean-model.d.ts.map +1 -1
  124. package/models/models/state-bean/types/index.d.ts +114 -6
  125. package/models/models/state-prop/state-prop-model.d.ts +78 -1
  126. package/models/models/state-prop/state-prop-model.d.ts.map +1 -1
  127. package/models/models/state-prop/types/index.d.ts +55 -7
  128. package/models/models/storage-device/storage-device-container-model.d.ts +289 -2
  129. package/models/models/storage-device/storage-device-container-model.d.ts.map +1 -1
  130. package/models/models/storage-device/storage-device-model.d.ts +84 -2
  131. package/models/models/storage-device/storage-device-model.d.ts.map +1 -1
  132. package/models/models/storage-device/types/index.d.ts +112 -0
  133. package/models/models/studio-properties/studio-properties-model.d.ts +75 -0
  134. package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
  135. package/models/models/studio-properties/types/index.d.ts +29 -0
  136. package/models/models/translation/services/translation-services.d.ts +128 -2
  137. package/models/models/translation/services/translation-services.d.ts.map +1 -1
  138. package/models/models/translation/translation-container-model.d.ts +100 -10
  139. package/models/models/translation/translation-container-model.d.ts.map +1 -1
  140. package/models/models/translation/translation-container-registration.d.ts +2 -1
  141. package/models/models/translation/translation-container-registration.d.ts.map +1 -1
  142. package/models/models/translation/translation-context.d.ts +1 -16
  143. package/models/models/translation/translation-context.d.ts.map +1 -1
  144. package/models/models/translation/translation-model.d.ts +113 -1
  145. package/models/models/translation/translation-model.d.ts.map +1 -1
  146. package/models/models/translation/types/index.d.ts +340 -0
  147. package/models/models/trouble/services/trouble-services.d.ts +3 -3
  148. package/models/models/trouble/services/trouble-services.d.ts.map +1 -1
  149. package/models/models/trouble/trouble-model.d.ts +2 -1
  150. package/models/models/trouble/trouble-model.d.ts.map +1 -1
  151. package/models/models/trouble/types/index.d.ts +22 -93
  152. package/models/models/trouble/utils/is-trouble-aware.d.ts +2 -2
  153. package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -1
  154. package/models/models/trouble-container/index.d.ts +4 -3
  155. package/models/models/trouble-container/index.d.ts.map +1 -1
  156. package/models/models/trouble-container/trouble-container-model.d.ts +9 -5
  157. package/models/models/trouble-container/trouble-container-model.d.ts.map +1 -1
  158. package/models/models/trouble-container/types/index.d.ts +2 -15
  159. package/models/utils/client.d.ts +8 -8
  160. package/models/utils/core-registration-manager.d.ts +1 -1
  161. package/models/utils/core-registration-manager.d.ts.map +1 -1
  162. package/models/utils/index.d.ts +0 -2
  163. package/models/utils/index.d.ts.map +1 -1
  164. package/models/utils/service.d.ts +9 -9
  165. package/package.json +2 -2
  166. package/ui/contexts/state-bean/state-bean-provider.d.ts.map +1 -1
  167. package/ui/hooks/state-bean/use-state-bean.d.ts +2 -2
  168. package/ui/hooks/state-bean/use-state-bean.d.ts.map +1 -1
  169. package/ui/hooks/state-bean/with-state-bean.d.ts.map +1 -1
  170. package/ui/hooks/translation-container/use-translation-container.d.ts +4 -33
  171. package/ui/hooks/translation-container/use-translation-container.d.ts.map +1 -1
  172. package/models/models/trouble-container/trouble-container-registration.d.ts +0 -5
  173. package/models/models/trouble-container/trouble-container-registration.d.ts.map +0 -1
  174. package/models/utils/kosmodel-compatible-future-mixin.d.ts +0 -142
  175. package/models/utils/kosmodel-compatible-future-mixin.d.ts.map +0 -1
  176. package/models/utils/kosmodel-interface-companion-mixin.d.ts +0 -83
  177. package/models/utils/kosmodel-interface-companion-mixin.d.ts.map +0 -1
@@ -1,11 +1,15 @@
1
1
  export * from './kos-child';
2
2
  export * from './kos-companion';
3
+ export * from './kos-container-aware';
3
4
  export * from './kos-context';
5
+ export * from './kos-future-aware';
4
6
  export * from './kos-http-decorators';
5
7
  export * from './kos-log';
8
+ export * from './kos-logger-aware';
6
9
  export * from './kos-model-effect';
7
10
  export * from './kos-parent';
8
11
  export * from './kos-reference';
12
+ export * from './kos-trouble-aware';
9
13
  export * from './kosDependency';
10
14
  export * from './kosModel';
11
15
  export * from './kosSubscribe';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -1,11 +1,128 @@
1
1
  import { IKosDataModel } from '../kosModel';
2
2
 
3
- interface DecoratedKosModel<T extends IKosDataModel = IKosDataModel> {
4
- new (...args: any[]): T;
5
- }
6
- type KosCompantionOptions = {
7
- modelType: string;
8
- };
9
- export declare const kosCompanion: <T extends IKosDataModel>({ modelType }: KosCompantionOptions) => (constructor: DecoratedKosModel<T>) => any;
10
- export {};
3
+ export interface KosCompanionOptions {
4
+ /**
5
+ * Pattern mode:
6
+ * - 'decorator': Proxy all parent properties transparently (default)
7
+ * - 'composition': Only provide getCompanionParent() method
8
+ */
9
+ mode?: "decorator" | "composition";
10
+ /** Properties to exclude from proxying (only applies in decorator mode). Default: [] */
11
+ excludeProperties?: string[];
12
+ /** Custom parent property name. Default: 'companionParent' */
13
+ parentProperty?: string;
14
+ }
15
+ /**
16
+ * Base interface for all companion models.
17
+ * Provides the getCompanionParent() method available in both decorator and composition modes.
18
+ */
19
+ export interface KosCompanionAware<TParent extends IKosDataModel = IKosDataModel> {
20
+ /**
21
+ * Gets the companion's parent model instance.
22
+ * Available in both decorator and composition modes.
23
+ * Provides access to the model this companion extends.
24
+ *
25
+ * @returns The parent model instance that this companion enhances
26
+ */
27
+ getCompanionParent(): TParent;
28
+ }
29
+ /**
30
+ * Interface for models using @kosCompanion in composition mode.
31
+ * Use TypeScript interface merging to add companion capabilities to your model class.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * interface ServiceCompanionModelImpl extends KosCompanionComposition<ServiceModel> {}
36
+ *
37
+ * @kosCompanion({ mode: 'composition' })
38
+ * class ServiceCompanionModelImpl implements IKosDataModel {
39
+ * // Only getCompanionParent() is available
40
+ * get serviceInfo() {
41
+ * const parent = this.getCompanionParent();
42
+ * return `Service: ${parent.serviceName}`;
43
+ * }
44
+ * }
45
+ * ```
46
+ */
47
+ export interface KosCompanionComposition<TParent extends IKosDataModel = IKosDataModel> extends KosCompanionAware<TParent> {
48
+ }
49
+ /**
50
+ * Interface for models using @kosCompanion in decorator mode (default).
51
+ * Use TypeScript interface merging to add full parent transparency to your model class.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * interface BrandCompanionModelImpl extends KosCompanionDecorator<AvailabilityModel> {}
56
+ *
57
+ * @kosCompanion() // defaults to decorator mode
58
+ * class BrandCompanionModelImpl implements IKosDataModel {
59
+ * // All parent properties are available directly
60
+ * get brandSpecificProperty() {
61
+ * return this.name; // 'name' from parent AvailabilityModel
62
+ * }
63
+ * }
64
+ * ```
65
+ */
66
+ export interface KosCompanionDecorator<TParent extends IKosDataModel = IKosDataModel> extends KosCompanionAware<TParent> {
67
+ }
68
+ /**
69
+ * Class decorator that adds companion model capabilities to a KOS model.
70
+ *
71
+ * Supports two patterns:
72
+ * 1. **Decorator Pattern** (default): Transparently proxies all parent properties,
73
+ * making the companion a drop-in replacement for the parent
74
+ * 2. **Composition Pattern**: Only provides getCompanionParent() method,
75
+ * keeping parent encapsulated
76
+ *
77
+ * **Important**: Use TypeScript interface merging to get proper type information:
78
+ *
79
+ * ```typescript
80
+ * // Decorator pattern - full transparency
81
+ * interface BrandCompanionModelImpl extends KosCompanionAware<AvailabilityModel> {}
82
+ *
83
+ * @kosModel("brand-companion")
84
+ * @kosCompanion() // defaults to decorator mode
85
+ * class BrandCompanionModelImpl implements IKosDataModel {
86
+ * // All parent properties are available
87
+ * get brandSpecificProperty() {
88
+ * return this.name; // 'name' from parent AvailabilityModel
89
+ * }
90
+ * }
91
+ *
92
+ * // Composition pattern - encapsulated parent
93
+ * interface ServiceCompanionModelImpl extends KosCompanionAware<ServiceModel> {}
94
+ *
95
+ * @kosModel("service-companion")
96
+ * @kosCompanion({ mode: 'composition' })
97
+ * class ServiceCompanionModelImpl implements IKosDataModel {
98
+ * // Parent is only accessible via getCompanionParent()
99
+ * get serviceInfo() {
100
+ * const parent = this.getCompanionParent();
101
+ * return `Service: ${parent.serviceName}`;
102
+ * }
103
+ * }
104
+ * ```
105
+ *
106
+ * @param options Configuration options for the companion decorator
107
+ * @returns A class decorator
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Decorator mode - all parent properties proxied
112
+ * @kosCompanion()
113
+ * class MyCompanion { }
114
+ *
115
+ * // Composition mode - only getCompanionParent() available
116
+ * @kosCompanion({ mode: 'composition' })
117
+ * class MyCompanion { }
118
+ *
119
+ * // Decorator mode with exclusions
120
+ * @kosCompanion({ mode: 'decorator', excludeProperties: ['internalState'] })
121
+ * class MyCompanion { }
122
+ * ```
123
+ *
124
+ * @category KOS Model Decorator
125
+ * @since 2.1.0
126
+ */
127
+ export declare function kosCompanion(options?: KosCompanionOptions): ClassDecorator;
11
128
  //# sourceMappingURL=kos-companion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kos-companion.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kos-companion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,UAAU,iBAAiB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IACjE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACzB;AAED,KAAK,oBAAoB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAClD,eAAO,MAAM,YAAY,2CACkB,oBAAoB,mBAC/C,kBAAkB,CAAC,CAAC,KAAG,GAGpC,CAAC"}
1
+ {"version":3,"file":"kos-companion.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kos-companion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;IACnC,wFAAwF;IACxF,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAChC,OAAO,SAAS,aAAa,GAAG,aAAa;IAE7C;;;;;;OAMG;IACH,kBAAkB,IAAI,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,uBAAuB,CACtC,OAAO,SAAS,aAAa,GAAG,aAAa,CAC7C,SAAQ,iBAAiB,CAAC,OAAO,CAAC;CAAG;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,qBAAqB,CACpC,OAAO,SAAS,aAAa,GAAG,aAAa,CAC7C,SAAQ,iBAAiB,CAAC,OAAO,CAAC;CAGnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAmB1E"}
@@ -0,0 +1,465 @@
1
+ import { IKosDataModel } from '../kosModel';
2
+ import { IKosModelContainer } from '../kos-container-model';
3
+
4
+ type MaybePromise<T> = T | Promise<T>;
5
+ /**
6
+ * Configuration options for the @kosContainerAware decorator.
7
+ *
8
+ * @template T The type of models contained in the container (must extend IKosDataModel)
9
+ */
10
+ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataModel> {
11
+ /**
12
+ * Container property name on the model instance.
13
+ *
14
+ * @default "container"
15
+ * @example
16
+ * ```typescript
17
+ * @kosContainerAware({ containerProperty: "devices" })
18
+ * class DeviceContainer {
19
+ * // Access via: this.devices.addModel(...)
20
+ * }
21
+ * ```
22
+ */
23
+ containerProperty?: string;
24
+ /**
25
+ * Whether to include convenience methods (getModel, addModel, removeModel).
26
+ *
27
+ * @default true
28
+ * @example
29
+ * ```typescript
30
+ * @kosContainerAware({ includeMethods: false })
31
+ * class Container {
32
+ * // Only this.container property available, no convenience methods
33
+ * }
34
+ * ```
35
+ */
36
+ includeMethods?: boolean;
37
+ /**
38
+ * Whether to include reactive getters (models, data).
39
+ *
40
+ * @default true
41
+ * @example
42
+ * ```typescript
43
+ * @kosContainerAware({ includeGetters: false })
44
+ * class Container {
45
+ * // No this.models or this.data getters, use this.container.data directly
46
+ * }
47
+ * ```
48
+ */
49
+ includeGetters?: boolean;
50
+ /**
51
+ * Container-specific configuration options passed to KosModelContainer constructor.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * @kosContainerAware({
56
+ * containerOptions: {
57
+ * sortKey: "name",
58
+ * indexMap: {
59
+ * byType: "deviceType",
60
+ * active: (device) => device.isOnline
61
+ * },
62
+ * parentId: "custom-parent", // Overrides automatic inference
63
+ * extensionId: "device-manager"
64
+ * }
65
+ * })
66
+ * ```
67
+ */
68
+ containerOptions?: {
69
+ /** Default property to sort models by */
70
+ sortKey?: keyof T;
71
+ /**
72
+ * Index mapping for efficient queries. Keys are index names, values are either:
73
+ * - Property names (string keys) for simple property-based indexing
74
+ * - Functions that return index keys for complex logic
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * indexMap: {
79
+ * byStatus: "connectionStatus", // Property-based
80
+ * byType: (device) => device.type.toLowerCase(), // Function-based
81
+ * needsUpdate: (device) => device.version < "2.0" // Boolean logic
82
+ * }
83
+ * ```
84
+ */
85
+ indexMap?: Record<string, keyof T | ((model: T) => MaybePromise<string | string[] | undefined>)>;
86
+ /**
87
+ * Parent model ID for the container. If not provided, automatically uses
88
+ * the modelId parameter from the model's constructor.
89
+ *
90
+ * @default Inferred from constructor modelId parameter
91
+ */
92
+ parentId?: string;
93
+ /** Extension identifier for the container */
94
+ extensionId?: string;
95
+ };
96
+ /**
97
+ * Custom name for the reactive models array getter.
98
+ *
99
+ * @default "models"
100
+ * @example
101
+ * ```typescript
102
+ * @kosContainerAware({ modelsProperty: "items" })
103
+ * class Container {
104
+ * get items() { return this.container.data; } // Instead of 'models'
105
+ * }
106
+ * ```
107
+ */
108
+ modelsProperty?: string;
109
+ /**
110
+ * Legacy compatibility mode. Uses '_models' as the container property name
111
+ * instead of 'container' for backward compatibility with existing code.
112
+ *
113
+ * @default false
114
+ * @deprecated Use containerProperty instead for new code
115
+ */
116
+ legacy?: boolean;
117
+ }
118
+ /**
119
+ * Interface for models using @kosContainerAware decorator.
120
+ *
121
+ * **IMPORTANT**: Use TypeScript interface merging to add container management properties to your model class.
122
+ * This provides full type safety and IntelliSense support for all injected container functionality.
123
+ *
124
+ * ## Interface Merging Pattern
125
+ *
126
+ * ```typescript
127
+ * // 1. Declare interface merging BEFORE the class
128
+ * interface MyContainerModelImpl extends KosContainerAware<ItemModel> {}
129
+ *
130
+ * // 2. Apply decorator and implement the class
131
+ * @kosModel("my-container-model")
132
+ * @kosContainerAware<ItemModel>()
133
+ * export class MyContainerModelImpl implements IKosDataModel {
134
+ * // All container properties are now available with full type safety
135
+ * }
136
+ * ```
137
+ *
138
+ * ## Custom Container Property Name
139
+ *
140
+ * When using a custom `containerProperty` name, use `KosContainerAwareWithProp`:
141
+ *
142
+ * ```typescript
143
+ * // For custom container property name
144
+ * interface DeviceManagerImpl extends KosContainerAwareWithProp<DeviceModel, "devices"> {}
145
+ *
146
+ * @kosContainerAware<DeviceModel>({ containerProperty: "devices" })
147
+ * class DeviceManagerImpl implements IKosDataModel {
148
+ * // Access via: this.devices instead of this.container
149
+ * }
150
+ * ```
151
+ *
152
+ * ## Injected Properties and Methods
153
+ *
154
+ * The decorator automatically injects the following members (configurable via options):
155
+ *
156
+ * - **`container`**: Core KosModelContainer instance for direct access (or custom name via `containerProperty`)
157
+ * - **`getModel(id)`**: Retrieve a model by ID from the container
158
+ * - **`addModel(model)`**: Add a model to the container
159
+ * - **`removeModel(id)`**: Remove a model from the container by ID
160
+ * - **`models`**: Readonly KosModelContainer instance (compatible with IKosModelHolder)
161
+ * - **`data`**: Reactive array of all model instances (compatible with IKosModelHolder)
162
+ *
163
+ * All injected getters are reactive and will automatically update UI components when container contents change.
164
+ *
165
+ * @template T The type of models contained in the container (must extend IKosDataModel)
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * // Basic usage with minimal configuration
170
+ * interface DeviceContainerModelImpl extends KosContainerAware<DeviceModel> {}
171
+ *
172
+ * @kosModel("device-container-model")
173
+ * @kosContainerAware<DeviceModel>()
174
+ * class DeviceContainerModelImpl implements IKosDataModel {
175
+ * constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
176
+ * this.id = modelId;
177
+ * // Container automatically injected with parentId: modelId
178
+ * }
179
+ *
180
+ * // Use injected methods
181
+ * addDevice(device: DeviceModel): void {
182
+ * this.addModel(device); // Method injected by decorator
183
+ * }
184
+ *
185
+ * // Use injected reactive getters
186
+ * get deviceCount(): number {
187
+ * return this.data.length; // Reactive array getter injected by decorator
188
+ * }
189
+ * }
190
+ * ```
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // Advanced usage with indexing and custom configuration
195
+ * interface UserContainerModelImpl extends KosContainerAware<UserModel> {}
196
+ *
197
+ * @kosModel("user-container-model")
198
+ * @kosContainerAware<UserModel>({
199
+ * containerOptions: {
200
+ * indexMap: {
201
+ * byRole: "role",
202
+ * byDepartment: "department",
203
+ * active: (user) => user.status === "active"
204
+ * },
205
+ * sortKey: "lastName"
206
+ * }
207
+ * })
208
+ * class UserContainerModelImpl implements IKosDataModel {
209
+ * // Access indexed data via injected container
210
+ * getActiveUsers(): UserModel[] {
211
+ * return this.container.getIndexByKey("active", true);
212
+ * }
213
+ *
214
+ * getUsersByRole(role: string): UserModel[] {
215
+ * return this.container.getIndexByKey("byRole", role);
216
+ * }
217
+ * }
218
+ * ```
219
+ *
220
+ * @see {@link kosContainerAware} - The decorator function
221
+ * @see {@link KosContainerAwareOptions} - Configuration options
222
+ */
223
+ export interface KosContainerAware<T extends IKosDataModel = IKosDataModel> {
224
+ /**
225
+ * Core container that manages the collection of models.
226
+ * Provides methods to add, remove, and query model instances.
227
+ * Automatically injected by @kosContainerAware decorator.
228
+ */
229
+ container: IKosModelContainer<T>;
230
+ /**
231
+ * Retrieves a model from the container by its ID.
232
+ * @param id - The unique identifier of the model to retrieve
233
+ * @returns The model instance if found, undefined otherwise
234
+ */
235
+ getModel(id: string): T | undefined;
236
+ /**
237
+ * Adds a model to the container.
238
+ * @param model - The model instance to add
239
+ */
240
+ addModel(model: T): void;
241
+ /**
242
+ * Removes a model from the container by its ID.
243
+ * @param id - The unique identifier of the model to remove
244
+ */
245
+ removeModel(id: string): void;
246
+ /**
247
+ * The container instance managing the models.
248
+ * Readonly property that provides access to the KosModelContainer.
249
+ * Compatible with IKosModelHolder interface.
250
+ * Updates automatically when models are added or removed.
251
+ */
252
+ readonly models: IKosModelContainer<T>;
253
+ /**
254
+ * Reactive array of all model instances in the container.
255
+ * This is the actual array of models, compatible with IKosModelHolder interface.
256
+ * Updates automatically when models are added or removed.
257
+ */
258
+ data: T[];
259
+ }
260
+ /**
261
+ * Base interface providing common container-aware methods and properties.
262
+ * Used internally by both KosContainerAware and KosContainerAwareWithProp.
263
+ *
264
+ * @template T The type of models contained in the container
265
+ */
266
+ export interface KosContainerAwareBase<T extends IKosDataModel = IKosDataModel> {
267
+ /**
268
+ * Retrieves a model from the container by its ID.
269
+ * @param id - The unique identifier of the model to retrieve
270
+ * @returns The model instance if found, undefined otherwise
271
+ */
272
+ getModel(id: string): T | undefined;
273
+ /**
274
+ * Adds a model to the container.
275
+ * @param model - The model instance to add
276
+ */
277
+ addModel(model: T): void;
278
+ /**
279
+ * Removes a model from the container by its ID.
280
+ * @param id - The unique identifier of the model to remove
281
+ */
282
+ removeModel(id: string): void;
283
+ /**
284
+ * The container instance managing the models.
285
+ * Readonly property that provides access to the KosModelContainer.
286
+ * Compatible with IKosModelHolder interface.
287
+ * Updates automatically when models are added or removed.
288
+ */
289
+ readonly models: IKosModelContainer<T>;
290
+ /**
291
+ * Reactive array of all model instances in the container.
292
+ * This is the actual array of models, compatible with IKosModelHolder interface.
293
+ * Updates automatically when models are added or removed.
294
+ */
295
+ data: T[];
296
+ }
297
+ /**
298
+ * Interface for models using @kosContainerAware decorator with a custom container property name.
299
+ *
300
+ * Use this interface when you specify a custom `containerProperty` in the decorator options
301
+ * to get proper type safety for the custom property name.
302
+ *
303
+ * @template T The type of models contained in the container
304
+ * @template P The custom property name for the container (string literal type)
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * // Specify the custom property name "devices" in both the interface and decorator
309
+ * interface DeviceManagerImpl extends KosContainerAwareWithProp<DeviceModel, "devices"> {}
310
+ *
311
+ * @kosModel("device-manager")
312
+ * @kosContainerAware<DeviceModel>({ containerProperty: "devices" })
313
+ * class DeviceManagerImpl implements IKosDataModel {
314
+ * constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
315
+ * this.id = modelId;
316
+ * }
317
+ *
318
+ * addDevice(device: DeviceModel): void {
319
+ * // Access container via custom property name
320
+ * this.devices.addModel(device);
321
+ * }
322
+ *
323
+ * getDeviceCount(): number {
324
+ * // The 'data' property is still available
325
+ * return this.data.length;
326
+ * }
327
+ * }
328
+ * ```
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * // Custom property for user management
333
+ * interface UserManagerImpl extends KosContainerAwareWithProp<UserModel, "users"> {}
334
+ *
335
+ * @kosContainerAware<UserModel>({
336
+ * containerProperty: "users",
337
+ * containerOptions: {
338
+ * indexMap: {
339
+ * byRole: "role"
340
+ * }
341
+ * }
342
+ * })
343
+ * class UserManagerImpl implements IKosDataModel {
344
+ * getUsersByRole(role: string): UserModel[] {
345
+ * // Access via this.users instead of this.container
346
+ * return this.users.getIndexByKey("byRole", role);
347
+ * }
348
+ * }
349
+ * ```
350
+ */
351
+ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P extends string = "container"> = KosContainerAwareBase<T> & {
352
+ [K in P]: IKosModelContainer<T>;
353
+ };
354
+ /**
355
+ * Class decorator that automatically adds container management capabilities to a KOS model.
356
+ *
357
+ * This decorator eliminates the need for manual container setup by:
358
+ * - **Adding a container property** (default: `container`) for managing model collections
359
+ * - **Adding convenience methods** (`getModel`, `addModel`, `removeModel`) if `includeMethods` is true (default)
360
+ * - **Adding reactive getters** (`models`, `data`) if `includeGetters` is true (default)
361
+ * - **Automatically inferring parentId** from the model's constructor `modelId` parameter
362
+ * - **Registering container as @kosChild** for proper lifecycle management and cleanup
363
+ * - **Supporting custom indexing** via `containerOptions.indexMap` for efficient queries
364
+ *
365
+ * ## Automatic Hierarchy Integration
366
+ *
367
+ * The decorator automatically registers the container as a `@kosChild`, ensuring:
368
+ * - Proper lifecycle management (init, load, destroy)
369
+ * - Automatic cleanup when parent model is destroyed
370
+ * - Participation in the KOS reactive system
371
+ * - Memory management and observer disposal
372
+ *
373
+ * ## TypeScript Usage
374
+ *
375
+ * **IMPORTANT**: Use TypeScript interface merging to get proper type information:
376
+ *
377
+ * ```typescript
378
+ * interface MyContainerModelImpl extends KosContainerAware<MyItemModel> {}
379
+ *
380
+ * @kosContainerAware<MyItemModel>()
381
+ * class MyContainerModelImpl implements IKosDataModel {
382
+ * // All container properties are now available with full type safety
383
+ * }
384
+ * ```
385
+ *
386
+ * ## Configuration Options
387
+ *
388
+ * ```typescript
389
+ * @kosContainerAware<UserModel>({
390
+ * containerProperty: "users", // Custom property name (default: "container")
391
+ * includeMethods: true, // Include convenience methods (default: true)
392
+ * includeGetters: true, // Include reactive getters (default: true)
393
+ * modelsProperty: "userList", // Custom models getter name (default: "models")
394
+ * legacy: false, // Use "_models" property name (default: false)
395
+ * containerOptions: {
396
+ * parentId: "custom-parent", // Override automatic parentId inference
397
+ * sortKey: "name", // Default sorting key
398
+ * extensionId: "my-extension", // Extension identifier
399
+ * indexMap: { // Automatic indexing for efficient queries
400
+ * byRole: "role", // Property-based index
401
+ * byStatus: (user) => user.active ? "active" : "inactive", // Function-based index
402
+ * admins: (user) => user.role === "admin" // Boolean index
403
+ * }
404
+ * }
405
+ * })
406
+ * ```
407
+ *
408
+ * @param options Configuration options for the decorator
409
+ * @returns A class decorator that modifies the target class prototype
410
+ *
411
+ * @see {@link KosContainerAware} - Interface for TypeScript merging
412
+ * @see {@link KosContainerAwareOptions} - Configuration options interface
413
+ *
414
+ * @example
415
+ * ```typescript
416
+ * // Minimal configuration - parentId automatically inferred
417
+ * interface ItemContainerModelImpl extends KosContainerAware<ItemModel> {}
418
+ *
419
+ * @kosContainerAware<ItemModel>()
420
+ * class ItemContainerModelImpl implements IKosDataModel {
421
+ * id: string;
422
+ *
423
+ * constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
424
+ * this.id = modelId;
425
+ * // Container automatically created with parentId: modelId
426
+ * }
427
+ * }
428
+ *
429
+ * // With index configuration
430
+ * interface UserContainerModelImpl extends KosContainerAware<UserModel> {}
431
+ *
432
+ * @kosContainerAware<UserModel>({
433
+ * containerOptions: {
434
+ * indexMap: {
435
+ * byRole: "role",
436
+ * byStatus: (user) => user.status
437
+ * }
438
+ * }
439
+ * })
440
+ * class UserContainerModelImpl implements IKosDataModel {
441
+ * constructor(modelId: string, options: ContainerOptions, context: KosCreationContext) {
442
+ * this.id = modelId;
443
+ * }
444
+ * }
445
+ *
446
+ * // Legacy mode for backward compatibility
447
+ * interface LegacyContainerModelImpl extends KosContainerAware<LegacyModel> {}
448
+ *
449
+ * @kosContainerAware<LegacyModel>({
450
+ * legacy: true, // Uses '_models' as property name
451
+ * containerOptions: {
452
+ * sortKey: "name"
453
+ * }
454
+ * })
455
+ * class LegacyContainerModelImpl implements IKosDataModel {
456
+ * // Container available as this._models for backward compatibility
457
+ * }
458
+ * ```
459
+ *
460
+ * @category KOS Model Decorator
461
+ * @since 2.1.0
462
+ */
463
+ export declare function kosContainerAware<T extends IKosDataModel = IKosDataModel>(options?: KosContainerAwareOptions<T>): ClassDecorator;
464
+ export {};
465
+ //# sourceMappingURL=kos-container-aware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kos-container-aware.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kos-container-aware.ts"],"names":[],"mappings":"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"}