@kosdev-code/kos-ui-sdk 2.1.26 → 2.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/core/decorators/kos-container-aware.d.ts +137 -4
- package/core/core/decorators/kos-container-aware.d.ts.map +1 -1
- package/core/core/decorators/kosModel.d.ts.map +1 -1
- package/core/core/kos-container-model.d.ts +188 -0
- package/core/core/kos-container-model.d.ts.map +1 -1
- package/core/core/kos-data-container.d.ts +93 -1
- package/core/core/kos-data-container.d.ts.map +1 -1
- package/index.cjs +78 -78
- package/index.cjs.map +1 -1
- package/index.js +4928 -4508
- package/index.js.map +1 -1
- package/models/utils/openapi-index.d.ts +2 -2
- package/models/utils/services/kos/1.6.5/openapi.d.ts +3809 -0
- package/models/utils/services/kos/1.6.5/service.d.ts +120 -0
- package/models/utils/services/kos/1.6.5/service.d.ts.map +1 -0
- package/models/utils/services/kos/1.8.1/openapi.d.ts +4344 -0
- package/models/utils/services/kos/1.8.1/service.d.ts +120 -0
- package/models/utils/services/kos/1.8.1/service.d.ts.map +1 -0
- package/models/utils/services/vfs/1.6.5/openapi.d.ts +51 -0
- package/models/utils/services/vfs/1.6.5/service.d.ts +120 -0
- package/models/utils/services/vfs/1.6.5/service.d.ts.map +1 -0
- package/models/utils/services/vfs/1.8.1/openapi.d.ts +51 -0
- package/models/utils/services/vfs/1.8.1/service.d.ts +120 -0
- package/models/utils/services/vfs/1.8.1/service.d.ts.map +1 -0
- package/models/utils/services-index.d.ts +4 -0
- package/models/utils/services-index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -22,7 +22,8 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
22
22
|
*/
|
|
23
23
|
containerProperty?: string;
|
|
24
24
|
/**
|
|
25
|
-
* Whether to include convenience methods (getModel, addModel, removeModel
|
|
25
|
+
* Whether to include convenience methods (getModel, addModel, removeModel, addAll, removeAll,
|
|
26
|
+
* removeAndDestroy, removeAndDestroyAll).
|
|
26
27
|
*
|
|
27
28
|
* @default true
|
|
28
29
|
* @example
|
|
@@ -60,7 +61,9 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
60
61
|
* active: (device) => device.isOnline
|
|
61
62
|
* },
|
|
62
63
|
* parentId: "custom-parent", // Overrides automatic inference
|
|
63
|
-
* extensionId: "device-manager"
|
|
64
|
+
* extensionId: "device-manager",
|
|
65
|
+
* maxCapacity: 1000, // Safety net for unbounded growth
|
|
66
|
+
* evictionStrategy: "fifo"
|
|
64
67
|
* }
|
|
65
68
|
* })
|
|
66
69
|
* ```
|
|
@@ -92,6 +95,52 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
92
95
|
parentId?: string;
|
|
93
96
|
/** Extension identifier for the container */
|
|
94
97
|
extensionId?: string;
|
|
98
|
+
/**
|
|
99
|
+
* SAFETY NET: Maximum number of models this container can hold.
|
|
100
|
+
* When exceeded, models are automatically evicted and destroyed based on evictionStrategy.
|
|
101
|
+
*
|
|
102
|
+
* **Primary use case**: Prevent memory overflow when cleanup handlers are missing or
|
|
103
|
+
* data becomes inconsistent. Set higher than normal usage to catch edge cases.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* containerOptions: {
|
|
108
|
+
* maxCapacity: 10000, // Safety net: expect ~100-1000 normally
|
|
109
|
+
* evictionStrategy: 'fifo'
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
maxCapacity?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Strategy for selecting which models to evict when maxCapacity is exceeded.
|
|
116
|
+
*
|
|
117
|
+
* - **fifo** (default): Remove oldest models first - best for event streams, logs
|
|
118
|
+
* - **lru**: Remove least recently accessed models - best for caches
|
|
119
|
+
* - **custom**: Use customEvictionFilter to determine eviction candidates
|
|
120
|
+
*
|
|
121
|
+
* @default 'fifo'
|
|
122
|
+
*/
|
|
123
|
+
evictionStrategy?: "fifo" | "lru" | "custom";
|
|
124
|
+
/**
|
|
125
|
+
* Number of models to evict when maxCapacity is exceeded.
|
|
126
|
+
* @default Math.max(10, Math.ceil(maxCapacity * 0.1))
|
|
127
|
+
*/
|
|
128
|
+
evictionBatchSize?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Custom filter function for 'custom' eviction strategy.
|
|
131
|
+
* Should return models that are candidates for eviction.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* customEvictionFilter: (models) => {
|
|
136
|
+
* return models.filter(m =>
|
|
137
|
+
* m.status === 'resolved' &&
|
|
138
|
+
* Date.now() - m.resolvedAt > 3600000
|
|
139
|
+
* );
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
customEvictionFilter?: (models: T[]) => T[];
|
|
95
144
|
};
|
|
96
145
|
/**
|
|
97
146
|
* Custom name for the reactive models array getter.
|
|
@@ -156,7 +205,11 @@ export interface KosContainerAwareOptions<T extends IKosDataModel = IKosDataMode
|
|
|
156
205
|
* - **`container`**: Core KosModelContainer instance for direct access (or custom name via `containerProperty`)
|
|
157
206
|
* - **`getModel(id)`**: Retrieve a model by ID from the container
|
|
158
207
|
* - **`addModel(model)`**: Add a model to the container
|
|
159
|
-
* - **`removeModel(id)`**: Remove a model from the container by ID
|
|
208
|
+
* - **`removeModel(id)`**: Remove a model from the container by ID (does not destroy)
|
|
209
|
+
* - **`addAll(models)`**: Add multiple models to the container at once
|
|
210
|
+
* - **`removeAll(ids)`**: Remove multiple models from the container by IDs (does not destroy)
|
|
211
|
+
* - **`removeAndDestroy(id)`**: Remove a model from the container and destroy it
|
|
212
|
+
* - **`removeAndDestroyAll(ids)`**: Remove multiple models from the container and destroy them
|
|
160
213
|
* - **`models`**: Readonly KosModelContainer instance (compatible with IKosModelHolder)
|
|
161
214
|
* - **`data`**: Reactive array of all model instances (compatible with IKosModelHolder)
|
|
162
215
|
*
|
|
@@ -243,6 +296,28 @@ export interface KosContainerAware<T extends IKosDataModel = IKosDataModel> {
|
|
|
243
296
|
* @param id - The unique identifier of the model to remove
|
|
244
297
|
*/
|
|
245
298
|
removeModel(id: string): void;
|
|
299
|
+
/**
|
|
300
|
+
* Adds multiple models to the container at once.
|
|
301
|
+
* @param models - Array of model instances to add
|
|
302
|
+
*/
|
|
303
|
+
addAll(models: T[]): void;
|
|
304
|
+
/**
|
|
305
|
+
* Removes multiple models from the container by their IDs.
|
|
306
|
+
* @param ids - Array of unique identifiers of the models to remove
|
|
307
|
+
*/
|
|
308
|
+
removeAll(ids: string[]): void;
|
|
309
|
+
/**
|
|
310
|
+
* Removes a model from the container and destroys it.
|
|
311
|
+
* Convenience method that combines removeModel() and destroyKosModel().
|
|
312
|
+
* @param id - The unique identifier of the model to remove and destroy
|
|
313
|
+
*/
|
|
314
|
+
removeAndDestroy(id: string): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Removes multiple models from the container and destroys them.
|
|
317
|
+
* Convenience method that combines removeAll() and destroyKosModel().
|
|
318
|
+
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
319
|
+
*/
|
|
320
|
+
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
246
321
|
/**
|
|
247
322
|
* The container instance managing the models.
|
|
248
323
|
* Readonly property that provides access to the KosModelContainer.
|
|
@@ -280,6 +355,28 @@ export interface KosContainerAwareBase<T extends IKosDataModel = IKosDataModel>
|
|
|
280
355
|
* @param id - The unique identifier of the model to remove
|
|
281
356
|
*/
|
|
282
357
|
removeModel(id: string): void;
|
|
358
|
+
/**
|
|
359
|
+
* Adds multiple models to the container at once.
|
|
360
|
+
* @param models - Array of model instances to add
|
|
361
|
+
*/
|
|
362
|
+
addAll(models: T[]): void;
|
|
363
|
+
/**
|
|
364
|
+
* Removes multiple models from the container by their IDs.
|
|
365
|
+
* @param ids - Array of unique identifiers of the models to remove
|
|
366
|
+
*/
|
|
367
|
+
removeAll(ids: string[]): void;
|
|
368
|
+
/**
|
|
369
|
+
* Removes a model from the container and destroys it.
|
|
370
|
+
* Convenience method that combines removeModel() and destroyKosModel().
|
|
371
|
+
* @param id - The unique identifier of the model to remove and destroy
|
|
372
|
+
*/
|
|
373
|
+
removeAndDestroy(id: string): Promise<void>;
|
|
374
|
+
/**
|
|
375
|
+
* Removes multiple models from the container and destroys them.
|
|
376
|
+
* Convenience method that combines removeAll() and destroyKosModel().
|
|
377
|
+
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
378
|
+
*/
|
|
379
|
+
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
283
380
|
/**
|
|
284
381
|
* The container instance managing the models.
|
|
285
382
|
* Readonly property that provides access to the KosModelContainer.
|
|
@@ -356,7 +453,7 @@ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P
|
|
|
356
453
|
*
|
|
357
454
|
* This decorator eliminates the need for manual container setup by:
|
|
358
455
|
* - **Adding a container property** (default: `container`) for managing model collections
|
|
359
|
-
* - **Adding convenience methods** (`getModel`, `addModel`, `removeModel`) if `includeMethods` is true (default)
|
|
456
|
+
* - **Adding convenience methods** (`getModel`, `addModel`, `removeModel`, `addAll`, `removeAll`, `removeAndDestroy`, `removeAndDestroyAll`) if `includeMethods` is true (default)
|
|
360
457
|
* - **Adding reactive getters** (`models`, `data`) if `includeGetters` is true (default)
|
|
361
458
|
* - **Automatically inferring parentId** from the model's constructor `modelId` parameter
|
|
362
459
|
* - **Registering container as @kosChild** for proper lifecycle management and cleanup
|
|
@@ -383,6 +480,42 @@ export type KosContainerAwareWithProp<T extends IKosDataModel = IKosDataModel, P
|
|
|
383
480
|
* }
|
|
384
481
|
* ```
|
|
385
482
|
*
|
|
483
|
+
* ## Model Lifecycle: removeModel vs removeAndDestroy
|
|
484
|
+
*
|
|
485
|
+
* The decorator provides both removal and destruction methods with different purposes:
|
|
486
|
+
*
|
|
487
|
+
* **removeModel(id) / removeAll(ids)** - Removes from container WITHOUT destroying:
|
|
488
|
+
* - Use when moving models between containers
|
|
489
|
+
* - Use when temporarily hiding models that may be re-added
|
|
490
|
+
* - Use when model lifecycle is managed elsewhere
|
|
491
|
+
* - Container handles cleanup of observers and metadata
|
|
492
|
+
* - Model remains in memory and can be used elsewhere
|
|
493
|
+
*
|
|
494
|
+
* **removeAndDestroy(id) / removeAndDestroyAll(ids)** - Removes AND destroys:
|
|
495
|
+
* - Use when permanently removing models from the system
|
|
496
|
+
* - Use when models should be fully cleaned up and disposed
|
|
497
|
+
* - Calls destroyKosModel() automatically after removal
|
|
498
|
+
* - Ensures proper cleanup of all model resources
|
|
499
|
+
* - Model is removed from framework and memory
|
|
500
|
+
*
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // Example: Explicit lifecycle control
|
|
503
|
+
* @kosTopicHandler({ topic: "/device/sensor/removed" })
|
|
504
|
+
* handleSensorRemoved(id: string) {
|
|
505
|
+
* // Permanently remove - sensor is gone from system
|
|
506
|
+
* await this.removeAndDestroy(id);
|
|
507
|
+
* }
|
|
508
|
+
*
|
|
509
|
+
* // Example: Reorganization without destruction
|
|
510
|
+
* moveSensorToArchive(id: string) {
|
|
511
|
+
* const sensor = this.getModel(id);
|
|
512
|
+
* if (sensor) {
|
|
513
|
+
* this.removeModel(id); // Remove from active container
|
|
514
|
+
* this.archive.addModel(sensor); // Add to archive container
|
|
515
|
+
* }
|
|
516
|
+
* }
|
|
517
|
+
* ```
|
|
518
|
+
*
|
|
386
519
|
* ## Configuration Options
|
|
387
520
|
*
|
|
388
521
|
* ```typescript
|
|
@@ -1 +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":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACtC;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CACvC,CAAC,SAAS,aAAa,GAAG,aAAa;IAEvC;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B
|
|
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":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACtC;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CACvC,CAAC,SAAS,aAAa,GAAG,aAAa;IAEvC;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,gBAAgB,CAAC,EAAE;QACjB,yCAAyC;QACzC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;QAElB;;;;;;;;;;;;;WAaG;QACH,QAAQ,CAAC,EAAE,MAAM,CACf,MAAM,EACN,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CACtE,CAAC;QAEF;;;;;WAKG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB,6CAA6C;QAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgJG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EACvE,OAAO,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACpC,cAAc,CAuBhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kosModel.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kosModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kosModel.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kosModel.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA6lB5C,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CA0DjD"}
|
|
@@ -26,13 +26,96 @@ export interface IKosModelContainer<T extends IKosDataModel> extends IKosBaseCon
|
|
|
26
26
|
getModel: (id: string) => T | undefined;
|
|
27
27
|
getIndexByKey: (indexName: string, indexKey: string) => T[];
|
|
28
28
|
getIndexKeys: (indexName: string) => string[];
|
|
29
|
+
removeAndDestroy: (id: string) => Promise<void>;
|
|
30
|
+
removeAndDestroyAll: (ids: string[]) => Promise<void>;
|
|
29
31
|
toJSON?: () => object;
|
|
30
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Eviction strategy for container capacity management
|
|
35
|
+
*
|
|
36
|
+
* - **fifo**: First-In-First-Out - removes oldest models first (default for event streams)
|
|
37
|
+
* - **lru**: Least Recently Used - removes models not accessed recently (good for caches)
|
|
38
|
+
* - **custom**: Uses customEvictionFilter function to determine which models to evict
|
|
39
|
+
*
|
|
40
|
+
* @category Container Capacity Management
|
|
41
|
+
* @see {@link ContainerOptions.maxCapacity}
|
|
42
|
+
* @see {@link ContainerOptions.evictionStrategy}
|
|
43
|
+
*/
|
|
44
|
+
export type EvictionStrategy = "fifo" | "lru" | "custom";
|
|
31
45
|
interface ContainerOptions<T extends IKosDataModel> {
|
|
32
46
|
sortKey?: keyof T;
|
|
33
47
|
indexMap?: Record<string, keyof T | IndexMapper<T>>;
|
|
34
48
|
parentId?: string;
|
|
35
49
|
extensionId?: string;
|
|
50
|
+
/**
|
|
51
|
+
* SAFETY NET: Maximum number of models this container can hold.
|
|
52
|
+
* When exceeded, models are automatically evicted and destroyed based on evictionStrategy.
|
|
53
|
+
*
|
|
54
|
+
* **Primary use case**: Prevent memory overflow when cleanup handlers are missing or
|
|
55
|
+
* data becomes inconsistent. Set higher than normal usage to catch edge cases.
|
|
56
|
+
*
|
|
57
|
+
* **Eviction is logged**: All automatic evictions are logged at WARNING level
|
|
58
|
+
* to aid in debugging and identifying data inconsistencies.
|
|
59
|
+
*
|
|
60
|
+
* @category Capacity Management
|
|
61
|
+
* @see {@link EvictionStrategy}
|
|
62
|
+
* @see {@link evictionBatchSize}
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* containerOptions: {
|
|
67
|
+
* maxCapacity: 10000, // Safety net: expect ~100-1000 normally
|
|
68
|
+
* evictionStrategy: 'fifo'
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
maxCapacity?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Strategy for selecting which models to evict when maxCapacity is exceeded.
|
|
75
|
+
*
|
|
76
|
+
* - **fifo** (default): Remove oldest models first - best for event streams, logs
|
|
77
|
+
* - **lru**: Remove least recently accessed models - best for caches
|
|
78
|
+
* - **custom**: Use customEvictionFilter to determine eviction candidates
|
|
79
|
+
*
|
|
80
|
+
* @category Capacity Management
|
|
81
|
+
* @see {@link EvictionStrategy}
|
|
82
|
+
* @see {@link maxCapacity}
|
|
83
|
+
* @see {@link customEvictionFilter}
|
|
84
|
+
*
|
|
85
|
+
* @default 'fifo'
|
|
86
|
+
*/
|
|
87
|
+
evictionStrategy?: EvictionStrategy;
|
|
88
|
+
/**
|
|
89
|
+
* Number of models to evict when maxCapacity is exceeded.
|
|
90
|
+
* Removing in batches prevents thrashing at the capacity boundary.
|
|
91
|
+
*
|
|
92
|
+
* @category Capacity Management
|
|
93
|
+
* @see {@link maxCapacity}
|
|
94
|
+
*
|
|
95
|
+
* @default Math.max(10, Math.ceil(maxCapacity * 0.1))
|
|
96
|
+
*/
|
|
97
|
+
evictionBatchSize?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Custom filter function for 'custom' eviction strategy.
|
|
100
|
+
* Should return models that are candidates for eviction.
|
|
101
|
+
* The container will evict up to evictionBatchSize models from the returned array.
|
|
102
|
+
*
|
|
103
|
+
* @category Capacity Management
|
|
104
|
+
* @see {@link EvictionStrategy}
|
|
105
|
+
* @see {@link maxCapacity}
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* // Evict resolved troubles older than 1 hour
|
|
110
|
+
* customEvictionFilter: (models) => {
|
|
111
|
+
* return models.filter(m =>
|
|
112
|
+
* m.status === 'resolved' &&
|
|
113
|
+
* Date.now() - m.resolvedAt > 3600000
|
|
114
|
+
* );
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
customEvictionFilter?: (models: T[]) => T[];
|
|
36
119
|
}
|
|
37
120
|
export declare class KosModelContainer<T extends IKosDataModel> implements IKosModelContainer<T> {
|
|
38
121
|
_data: Map<string, T>;
|
|
@@ -43,6 +126,12 @@ export declare class KosModelContainer<T extends IKosDataModel> implements IKosM
|
|
|
43
126
|
private _disposerMap;
|
|
44
127
|
private _parentId?;
|
|
45
128
|
idx: KosData<Record<string, Record<string, T[]>>>;
|
|
129
|
+
private _maxCapacity?;
|
|
130
|
+
private _evictionStrategy;
|
|
131
|
+
private _evictionBatchSize;
|
|
132
|
+
private _insertionOrder;
|
|
133
|
+
private _accessTimes?;
|
|
134
|
+
private _customEvictionFilter?;
|
|
46
135
|
constructor(options?: ContainerOptions<T>);
|
|
47
136
|
init(): void;
|
|
48
137
|
[Symbol.iterator](): IterableIterator<T>;
|
|
@@ -54,12 +143,111 @@ export declare class KosModelContainer<T extends IKosDataModel> implements IKosM
|
|
|
54
143
|
increment(): void;
|
|
55
144
|
addAll(models: T[]): void;
|
|
56
145
|
removeAll(ids: string[]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Remove a model from the container and destroy it.
|
|
148
|
+
* This is a convenience method that combines removeModel() and destroyKosModel().
|
|
149
|
+
*
|
|
150
|
+
* Use this when:
|
|
151
|
+
* - The model is being permanently removed from the system
|
|
152
|
+
* - The model should be cleaned up and disposed
|
|
153
|
+
*
|
|
154
|
+
* Use removeModel() alone when:
|
|
155
|
+
* - Moving models between containers
|
|
156
|
+
* - Temporarily removing without destroying
|
|
157
|
+
* - Managing models that may be re-added later
|
|
158
|
+
*
|
|
159
|
+
* @param id - The unique identifier of the model to remove and destroy
|
|
160
|
+
*/
|
|
161
|
+
removeAndDestroy(id: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Remove multiple models from the container and destroy them.
|
|
164
|
+
* This is a convenience method that combines removeAll() and destroyKosModel().
|
|
165
|
+
*
|
|
166
|
+
* Operations are performed in parallel for efficiency, but each destruction
|
|
167
|
+
* is independent - failures in one won't prevent others from being destroyed.
|
|
168
|
+
*
|
|
169
|
+
* @param ids - Array of unique identifiers of the models to remove and destroy
|
|
170
|
+
* @returns Promise that resolves when all models have been removed and destroyed
|
|
171
|
+
*/
|
|
172
|
+
removeAndDestroyAll(ids: string[]): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Add a model to the container (Zone 2: Workflow orchestration)
|
|
175
|
+
*
|
|
176
|
+
* @param model - The model to add
|
|
177
|
+
* @param defer - If true, skip incrementing revision (for batch operations)
|
|
178
|
+
*/
|
|
57
179
|
addModel(model: T, defer?: boolean): void;
|
|
180
|
+
/**
|
|
181
|
+
* Persist model to container storage (Zone 3)
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
private _persistModel;
|
|
185
|
+
/**
|
|
186
|
+
* Track model metadata for capacity management (Zone 3)
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
private _trackModelMetadata;
|
|
190
|
+
/**
|
|
191
|
+
* Establish parent-child relationships (Zone 3)
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
private _establishModelRelationships;
|
|
195
|
+
/**
|
|
196
|
+
* Enforce capacity limits and trigger eviction if needed (Zone 3)
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
private _enforceCapacityLimits;
|
|
200
|
+
/**
|
|
201
|
+
* Configure MobX observers for model property changes (Zone 3)
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
private _configureModelMonitoring;
|
|
58
205
|
removeModel(id: string, defer?: boolean): void;
|
|
59
206
|
updateModel(model: T): void;
|
|
60
207
|
getModel(id: string): T | undefined;
|
|
61
208
|
getIndexKeys(indexName: string): string[];
|
|
62
209
|
getIndexByKey(indexName: string, indexKey: string): T[];
|
|
210
|
+
/**
|
|
211
|
+
* SAFETY NET: Evict models when capacity is exceeded (Zone 2: Workflow orchestration)
|
|
212
|
+
* Logs all evictions at WARNING level for debugging.
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
private _evictModels;
|
|
216
|
+
/**
|
|
217
|
+
* Log capacity exceeded warning (Zone 3)
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
private _logCapacityWarning;
|
|
221
|
+
/**
|
|
222
|
+
* Select models for eviction based on strategy (Zone 3)
|
|
223
|
+
* @private
|
|
224
|
+
*/
|
|
225
|
+
private _selectModelsForEviction;
|
|
226
|
+
/**
|
|
227
|
+
* Select oldest models for FIFO eviction (Zone 3)
|
|
228
|
+
* @private
|
|
229
|
+
*/
|
|
230
|
+
private _selectFifoModels;
|
|
231
|
+
/**
|
|
232
|
+
* Select least recently used models for LRU eviction (Zone 3)
|
|
233
|
+
* @private
|
|
234
|
+
*/
|
|
235
|
+
private _selectLruModels;
|
|
236
|
+
/**
|
|
237
|
+
* Select models using custom filter for eviction (Zone 3)
|
|
238
|
+
* @private
|
|
239
|
+
*/
|
|
240
|
+
private _selectCustomModels;
|
|
241
|
+
/**
|
|
242
|
+
* Remove and destroy evicted models (Zone 3)
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
private _removeEvictedModels;
|
|
246
|
+
/**
|
|
247
|
+
* Log eviction completion (Zone 3)
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
private _logEvictionComplete;
|
|
63
251
|
clear(): Promise<void>;
|
|
64
252
|
filter<S extends any>(predicate: (value: any, index: number, array: any[]) => value is S, thisArg?: any): T[];
|
|
65
253
|
sort(compareFn?: ((a: any, b: any) => number) | undefined): T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kos-container-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/core/kos-container-model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kos-container-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/core/kos-container-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,EAAE,GAAG;IAKf,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS;IAGzD,GAAG,CAAC,CAAC,EACH,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,EAC1D,OAAO,CAAC,EAAE,GAAG;IAKf,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,EAC7D,OAAO,CAAC,EAAE,GAAG;IAKf,MAAM;;;;;;;CAYP"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IKosIdentifiable } from './types/model';
|
|
2
|
-
import { IKosBaseContainer } from './kos-container-model';
|
|
2
|
+
import { IKosBaseContainer, EvictionStrategy } from './kos-container-model';
|
|
3
3
|
import { IKosContainerIndex, IndexMapper } from './kos-container-index';
|
|
4
4
|
import { KosData } from '../util/observable-proxy-map';
|
|
5
5
|
|
|
@@ -12,6 +12,14 @@ export interface IKosDataContainer<T extends IKosIdentifiable> extends IKosBaseC
|
|
|
12
12
|
interface ContainerOptions<T extends IKosIdentifiable> {
|
|
13
13
|
sortKey?: keyof T;
|
|
14
14
|
indexMap?: Record<string, keyof T | IndexMapper<T>>;
|
|
15
|
+
/** SAFETY NET: Maximum capacity before eviction */
|
|
16
|
+
maxCapacity?: number;
|
|
17
|
+
/** Eviction strategy when maxCapacity is exceeded */
|
|
18
|
+
evictionStrategy?: EvictionStrategy;
|
|
19
|
+
/** Number of items to evict when capacity exceeded */
|
|
20
|
+
evictionBatchSize?: number;
|
|
21
|
+
/** Custom eviction filter for 'custom' strategy */
|
|
22
|
+
customEvictionFilter?: (models: T[]) => T[];
|
|
15
23
|
}
|
|
16
24
|
export declare class KosDataContainer<T extends IKosIdentifiable> implements IKosDataContainer<T> {
|
|
17
25
|
_data: Map<string, T>;
|
|
@@ -21,6 +29,12 @@ export declare class KosDataContainer<T extends IKosIdentifiable> implements IKo
|
|
|
21
29
|
private _optionsMap;
|
|
22
30
|
private _disposerMap;
|
|
23
31
|
idx: KosData<Record<string, Record<string, T[]>>>;
|
|
32
|
+
private _maxCapacity?;
|
|
33
|
+
private _evictionStrategy;
|
|
34
|
+
private _evictionBatchSize;
|
|
35
|
+
private _insertionOrder;
|
|
36
|
+
private _accessTimes?;
|
|
37
|
+
private _customEvictionFilter?;
|
|
24
38
|
constructor(options?: ContainerOptions<T>);
|
|
25
39
|
init(): void;
|
|
26
40
|
[Symbol.iterator](): IterableIterator<T>;
|
|
@@ -32,12 +46,90 @@ export declare class KosDataContainer<T extends IKosIdentifiable> implements IKo
|
|
|
32
46
|
sortFn(a: any, b: any): number;
|
|
33
47
|
get data(): T[];
|
|
34
48
|
increment(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Add a data object to the container (Zone 2: Workflow orchestration)
|
|
51
|
+
*
|
|
52
|
+
* @param model - The data object to add
|
|
53
|
+
* @param defer - If true, skip incrementing revision (for batch operations)
|
|
54
|
+
*/
|
|
35
55
|
addModel(model: T, defer?: boolean): void;
|
|
56
|
+
/**
|
|
57
|
+
* Ensure data is observable (Zone 3)
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
private _ensureObservable;
|
|
61
|
+
/**
|
|
62
|
+
* Clean up existing disposer if present (Zone 3)
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
private _cleanupExistingDisposer;
|
|
66
|
+
/**
|
|
67
|
+
* Persist data to container storage (Zone 3)
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
private _persistData;
|
|
71
|
+
/**
|
|
72
|
+
* Track data metadata for capacity management (Zone 3)
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private _trackDataMetadata;
|
|
76
|
+
/**
|
|
77
|
+
* Enforce capacity limits and trigger eviction if needed (Zone 3)
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private _enforceCapacityLimits;
|
|
81
|
+
/**
|
|
82
|
+
* Configure MobX observers for data property changes (Zone 3)
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
private _configureDataMonitoring;
|
|
36
86
|
removeModel(id: string): void;
|
|
37
87
|
updateModel(model: T): void;
|
|
38
88
|
getModel(id: string): T | undefined;
|
|
39
89
|
getIndexKeys(indexName: string): string[];
|
|
40
90
|
getIndexByKey(indexName: string, indexKey: string): T[];
|
|
91
|
+
/**
|
|
92
|
+
* SAFETY NET: Evict data models when capacity is exceeded (Zone 2: Workflow orchestration)
|
|
93
|
+
* Logs all evictions at WARNING level for debugging.
|
|
94
|
+
* Note: Data models are not destroyed (no lifecycle), only removed from container.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
private _evictModels;
|
|
98
|
+
/**
|
|
99
|
+
* Log capacity exceeded warning for data container (Zone 3)
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
private _logDataCapacityWarning;
|
|
103
|
+
/**
|
|
104
|
+
* Select data for eviction based on strategy (Zone 3)
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
private _selectDataForEviction;
|
|
108
|
+
/**
|
|
109
|
+
* Select oldest data IDs for FIFO eviction (Zone 3)
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
private _selectFifoData;
|
|
113
|
+
/**
|
|
114
|
+
* Select least recently used data IDs for LRU eviction (Zone 3)
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private _selectLruData;
|
|
118
|
+
/**
|
|
119
|
+
* Select data using custom filter for eviction (Zone 3)
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
private _selectCustomData;
|
|
123
|
+
/**
|
|
124
|
+
* Remove evicted data items (Zone 3)
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
private _removeEvictedData;
|
|
128
|
+
/**
|
|
129
|
+
* Log eviction completion for data container (Zone 3)
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
private _logDataEvictionComplete;
|
|
41
133
|
clear(): Promise<void>;
|
|
42
134
|
filter<S extends any>(predicate: (value: any, index: number, array: any[]) => value is S, thisArg?: any): T[];
|
|
43
135
|
sort(compareFn?: ((a: any, b: any) => number) | undefined): T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kos-data-container.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/core/kos-data-container.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"kos-data-container.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/core/kos-data-container.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,CAC3D,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC5B,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC;IACxC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC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