@oimdb/core 1.0.6 → 1.2.0

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/dist/index.d.cts CHANGED
@@ -61,10 +61,23 @@ interface TOIMIndexUpdatePayload<TKey> {
61
61
  * Returns true if the arrays are considered equal, false if they differ. */
62
62
  type TOIMIndexComparator<TPk extends TOIMPk> = (existingPks: readonly TPk[], newPks: readonly TPk[]) => boolean;
63
63
 
64
+ declare abstract class OIMIndexStore<TKey extends TOIMPk, TPk extends TOIMPk> {
65
+ abstract setOneByKey(key: TKey, pks: Set<TPk>): void;
66
+ abstract removeOneByKey(key: TKey): void;
67
+ abstract removeManyByKeys(keys: readonly TKey[]): void;
68
+ abstract getOneByKey(key: TKey): Set<TPk> | undefined;
69
+ abstract getManyByKeys(keys: readonly TKey[]): Map<TKey, Set<TPk>>;
70
+ abstract getAllKeys(): TKey[];
71
+ abstract getAll(): Map<TKey, Set<TPk>>;
72
+ abstract countAll(): number;
73
+ abstract clear(): void;
74
+ }
75
+
64
76
  /**
65
77
  * Configuration options for index instances */
66
- type TOIMIndexOptions<TPk extends TOIMPk> = {
78
+ type TOIMIndexOptions<TIndexKey extends TOIMPk, TPk extends TOIMPk> = {
67
79
  comparePks?: TOIMIndexComparator<TPk>;
80
+ store?: OIMIndexStore<TIndexKey, TPk>;
68
81
  };
69
82
 
70
83
  /**
@@ -72,12 +85,12 @@ type TOIMIndexOptions<TPk extends TOIMPk> = {
72
85
  * Provides common functionality and event system for key-to-PKs mappings.
73
86
  */
74
87
  declare abstract class OIMIndex<TKey extends TOIMPk, TPk extends TOIMPk> {
75
- protected readonly pks: Map<TKey, Set<TPk>>;
76
88
  protected readonly comparePks?: TOIMIndexComparator<TPk>;
89
+ protected readonly store: OIMIndexStore<TKey, TPk>;
77
90
  readonly emitter: OIMEventEmitter<{
78
91
  0: TOIMIndexUpdatePayload<TKey>;
79
92
  }>;
80
- constructor(options?: TOIMIndexOptions<TPk>);
93
+ constructor(options?: TOIMIndexOptions<TKey, TPk>);
81
94
  /**
82
95
  * Get primary keys for multiple index keys
83
96
  */
@@ -136,16 +149,56 @@ declare abstract class OIMIndex<TKey extends TOIMPk, TPk extends TOIMPk> {
136
149
  protected emitUpdate(keys: TKey[]): void;
137
150
  }
138
151
 
152
+ /**
153
+ * Manual index that allows direct manipulation of key-to-primary-keys mappings.
154
+ * Extends the abstract OIMIndex with manual control methods and optional comparison.
155
+ */
156
+ declare class OIMIndexManual<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndex<TIndexKey, TPk> {
157
+ constructor(options?: TOIMIndexOptions<TIndexKey, TPk>);
158
+ /**
159
+ * Set primary keys for a specific index key, replacing any existing values.
160
+ * Uses optional comparator to skip updates if PKs haven't actually changed.
161
+ */
162
+ setPks(key: TIndexKey, pks: TPk[]): void;
163
+ /**
164
+ * Add primary keys to a specific index key
165
+ */
166
+ addPks(key: TIndexKey, pks: readonly TPk[]): void;
167
+ /**
168
+ * Remove primary keys from a specific index key
169
+ */
170
+ removePks(key: TIndexKey, pks: readonly TPk[]): void;
171
+ /**
172
+ * Clear all primary keys for a specific index key, or all keys if no key specified
173
+ */
174
+ clear(key?: TIndexKey): void;
175
+ }
176
+
177
+ /**
178
+ * Static class containing OIMDB settings and constants.
179
+ * Provides access to configuration values used throughout the library.
180
+ */
181
+ declare class OIMDBSettings {
182
+ /**
183
+ * Fixed key used in the manual index to store updated keys set in coalescers.
184
+ * This constant is exported so users can create their own indexes and pass them to coalescers.
185
+ */
186
+ static readonly UPDATED_KEYS_INDEX_KEY: "__updatedKeys__";
187
+ }
188
+
139
189
  /**
140
190
  * Base abstract coalescer that groups updates by keys and emits consolidated events.
141
191
  * Designed to be extended for different entity types (collections, indexes, etc.).
142
192
  */
143
- declare abstract class OIMUpdateEventCoalescer<TKey> {
193
+ declare abstract class OIMUpdateEventCoalescer<TKey extends TOIMPk> {
144
194
  readonly emitter: OIMEventEmitter<{
145
195
  0: void;
196
+ 1: void;
197
+ 2: void;
146
198
  }>;
147
- protected updatedKeys: Set<TKey>;
199
+ protected readonly updatedKeysIndex: OIMIndexManual<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>;
148
200
  private hasEmittedChanges;
201
+ constructor(index?: OIMIndexManual<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>);
149
202
  /**
150
203
  * Get the set of keys that have been updated since last clear
151
204
  */
@@ -157,7 +210,7 @@ declare abstract class OIMUpdateEventCoalescer<TKey> {
157
210
  /**
158
211
  * Add keys to the updated set and emit HAS_CHANGES event if needed
159
212
  */
160
- protected addUpdatedKeys(keys: TKey[]): void;
213
+ protected addUpdatedKeys(keys: readonly TKey[]): void;
161
214
  /**
162
215
  * Clean up event listeners when coalescer is no longer needed
163
216
  */
@@ -176,10 +229,16 @@ type TOIMEventQueueOptions = {
176
229
  scheduler?: OIMEventQueueScheduler;
177
230
  };
178
231
 
232
+ declare enum EOIMEventQueueEventType {
233
+ AFTER_FLUSH = 0,
234
+ BEFORE_FLUSH = 1
235
+ }
236
+
179
237
  /**
180
238
  * Event queue that can optionally integrate with a scheduler for automatic flushing.
181
239
  */
182
240
  declare class OIMEventQueue {
241
+ readonly emitter: OIMEventEmitter<Record<EOIMEventQueueEventType, void>>;
183
242
  protected queue: (() => void)[];
184
243
  protected readonly scheduler?: OIMEventQueueScheduler;
185
244
  protected flushBound?: () => void;
@@ -214,7 +273,7 @@ declare class OIMEventQueue {
214
273
 
215
274
  /**
216
275
  * Options for creating an update event emitter */
217
- type TOIMUpdateEventEmitterOptions<TKey> = {
276
+ type TOIMUpdateEventEmitterOptions<TKey extends TOIMPk> = {
218
277
  coalescer: OIMUpdateEventCoalescer<TKey>;
219
278
  queue: OIMEventQueue;
220
279
  };
@@ -223,7 +282,7 @@ type TOIMUpdateEventEmitterOptions<TKey> = {
223
282
  * Universal event emitter that handles subscriptions and notifications for any key type.
224
283
  * Optimized for performance with adaptive algorithms and memory management.
225
284
  */
226
- declare class OIMUpdateEventEmitter<TKey> {
285
+ declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
227
286
  protected keyHandlers: Map<TKey, Set<TOIMEventHandler<void>>>;
228
287
  protected coalescer: OIMUpdateEventCoalescer<TKey>;
229
288
  protected queue: OIMEventQueue;
@@ -261,7 +320,7 @@ declare enum EOIMIndexEventType {
261
320
  * Index-specific coalescer that tracks index key updates and emits consolidated change events.
262
321
  * Takes an event emitter directly instead of the whole index to avoid circular dependencies.
263
322
  */
264
- declare class OIMUpdateEventCoalescerIndex<TIndexKey> extends OIMUpdateEventCoalescer<TIndexKey> {
323
+ declare class OIMUpdateEventCoalescerIndex<TIndexKey extends TOIMPk> extends OIMUpdateEventCoalescer<TIndexKey> {
265
324
  private readonly indexEmitter;
266
325
  constructor(indexEmitter: OIMEventEmitter<{
267
326
  [EOIMIndexEventType.UPDATE]: TOIMIndexUpdatePayload<TIndexKey>;
@@ -327,6 +386,8 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
327
386
  upsertMany(entities: TEntity[]): void;
328
387
  removeOne(entity: TEntity): void;
329
388
  removeMany(entities: TEntity[]): void;
389
+ removeOneByPk(pk: TPk): void;
390
+ removeManyByPks(pks: readonly TPk[]): void;
330
391
  clear(): void;
331
392
  countAll(): number;
332
393
  getAll(): TEntity[];
@@ -354,48 +415,10 @@ declare class OIMUpdateEventCoalescerCollection<TPk extends TOIMPk> extends OIMU
354
415
  private handleUpdate;
355
416
  }
356
417
 
357
- declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> {
358
- readonly collection: OIMCollection<TEntity, TPk>;
418
+ declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> {
359
419
  readonly updateEventEmitter: OIMUpdateEventEmitter<TPk>;
360
420
  readonly coalescer: OIMUpdateEventCoalescerCollection<TPk>;
361
- constructor(queue: OIMEventQueue, opts?: {
362
- collectionOpts?: TOIMCollectionOptions<TEntity, TPk>;
363
- });
364
- upsertMany(entities: TEntity[]): void;
365
- upsertOne(entity: TEntity): void;
366
- removeMany(entities: TEntity[]): void;
367
- removeOne(entity: TEntity): void;
368
- getOneByPk(pk: TPk): TEntity | undefined;
369
- getManyByPks(pks: readonly TPk[]): TEntity[];
370
- clear(): void;
371
- countAll(): number;
372
- getAll(): TEntity[];
373
- getAllPks(): TPk[];
374
- }
375
-
376
- /**
377
- * Manual index that allows direct manipulation of key-to-primary-keys mappings.
378
- * Extends the abstract OIMIndex with manual control methods and optional comparison.
379
- */
380
- declare class OIMIndexManual<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndex<TIndexKey, TPk> {
381
- constructor(options?: TOIMIndexOptions<TPk>);
382
- /**
383
- * Set primary keys for a specific index key, replacing any existing values.
384
- * Uses optional comparator to skip updates if PKs haven't actually changed.
385
- */
386
- setPks(key: TIndexKey, pks: TPk[]): void;
387
- /**
388
- * Add primary keys to a specific index key
389
- */
390
- addPks(key: TIndexKey, pks: readonly TPk[]): void;
391
- /**
392
- * Remove primary keys from a specific index key
393
- */
394
- removePks(key: TIndexKey, pks: readonly TPk[]): void;
395
- /**
396
- * Clear all primary keys for a specific index key, or all keys if no key specified
397
- */
398
- clear(key?: TIndexKey): void;
421
+ constructor(queue: OIMEventQueue, opts?: TOIMCollectionOptions<TEntity, TPk>);
399
422
  }
400
423
 
401
424
  declare class OIMReactiveIndexManual<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMReactiveIndex<TKey, TPk, OIMIndexManual<TKey, TPk>> {
@@ -409,11 +432,11 @@ declare class OIMReactiveIndexManual<TKey extends TOIMPk, TPk extends TOIMPk> ex
409
432
  clear(key?: TKey): void;
410
433
  }
411
434
 
412
- declare class OIMRICollection<TEntity extends object, TPk extends TOIMPk, TIndexName extends string, TIndexKey extends TOIMPk, TIndex extends OIMIndex<TIndexKey, TPk>, TReactiveIndex extends OIMReactiveIndex<TIndexKey, TPk, TIndex>> extends OIMReactiveCollection<TEntity, TPk> {
413
- readonly indexes: Record<TIndexName, TReactiveIndex>;
435
+ declare class OIMRICollection<TEntity extends object, TPk extends TOIMPk, TIndexName extends string, TIndexKey extends TOIMPk, TIndex extends OIMIndex<TIndexKey, TPk>, TReactiveIndex extends OIMReactiveIndex<TIndexKey, TPk, TIndex>, TReactiveIndexMap extends Record<TIndexName, TReactiveIndex> = Record<TIndexName, TReactiveIndex>> extends OIMReactiveCollection<TEntity, TPk> {
436
+ readonly indexes?: TReactiveIndexMap;
414
437
  constructor(queue: OIMEventQueue, opts: {
415
438
  collectionOpts?: TOIMCollectionOptions<TEntity, TPk>;
416
- indexes: Record<TIndexName, TReactiveIndex>;
439
+ indexes?: TReactiveIndexMap;
417
440
  });
418
441
  }
419
442
 
@@ -585,7 +608,9 @@ declare class OIMEventQueueSchedulerFactory {
585
608
  /**
586
609
  * Event types for update coalescers */
587
610
  declare enum EOIMUpdateEventCoalescerEventType {
588
- HAS_CHANGES = 0
611
+ HAS_CHANGES = 0,
612
+ BEFORE_FLUSH = 1,
613
+ AFTER_FLUSH = 2
589
614
  }
590
615
 
591
616
  type TOIMIndexKey = string | number | bigint;
@@ -601,4 +626,4 @@ type TOIMUpdatePayload<TKey> = {
601
626
  keys: readonly TKey[];
602
627
  };
603
628
 
604
- export { EOIMCollectionEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMUpdateEventCoalescerEventType, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndex, OIMIndexComparatorFactory, OIMIndexManual, OIMMap2Keys, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndex, OIMReactiveIndexManual, OIMUpdateEventCoalescer, OIMUpdateEventCoalescerCollection, OIMUpdateEventCoalescerIndex, OIMUpdateEventEmitter, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdateEventEmitterOptions, type TOIMUpdatePayload };
629
+ export { EOIMCollectionEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMUpdateEventCoalescerEventType, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMDBSettings, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndex, OIMIndexComparatorFactory, OIMIndexManual, OIMMap2Keys, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndex, OIMReactiveIndexManual, OIMUpdateEventCoalescer, OIMUpdateEventCoalescerCollection, OIMUpdateEventCoalescerIndex, OIMUpdateEventEmitter, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdateEventEmitterOptions, type TOIMUpdatePayload };
package/dist/index.d.ts CHANGED
@@ -61,10 +61,23 @@ interface TOIMIndexUpdatePayload<TKey> {
61
61
  * Returns true if the arrays are considered equal, false if they differ. */
62
62
  type TOIMIndexComparator<TPk extends TOIMPk> = (existingPks: readonly TPk[], newPks: readonly TPk[]) => boolean;
63
63
 
64
+ declare abstract class OIMIndexStore<TKey extends TOIMPk, TPk extends TOIMPk> {
65
+ abstract setOneByKey(key: TKey, pks: Set<TPk>): void;
66
+ abstract removeOneByKey(key: TKey): void;
67
+ abstract removeManyByKeys(keys: readonly TKey[]): void;
68
+ abstract getOneByKey(key: TKey): Set<TPk> | undefined;
69
+ abstract getManyByKeys(keys: readonly TKey[]): Map<TKey, Set<TPk>>;
70
+ abstract getAllKeys(): TKey[];
71
+ abstract getAll(): Map<TKey, Set<TPk>>;
72
+ abstract countAll(): number;
73
+ abstract clear(): void;
74
+ }
75
+
64
76
  /**
65
77
  * Configuration options for index instances */
66
- type TOIMIndexOptions<TPk extends TOIMPk> = {
78
+ type TOIMIndexOptions<TIndexKey extends TOIMPk, TPk extends TOIMPk> = {
67
79
  comparePks?: TOIMIndexComparator<TPk>;
80
+ store?: OIMIndexStore<TIndexKey, TPk>;
68
81
  };
69
82
 
70
83
  /**
@@ -72,12 +85,12 @@ type TOIMIndexOptions<TPk extends TOIMPk> = {
72
85
  * Provides common functionality and event system for key-to-PKs mappings.
73
86
  */
74
87
  declare abstract class OIMIndex<TKey extends TOIMPk, TPk extends TOIMPk> {
75
- protected readonly pks: Map<TKey, Set<TPk>>;
76
88
  protected readonly comparePks?: TOIMIndexComparator<TPk>;
89
+ protected readonly store: OIMIndexStore<TKey, TPk>;
77
90
  readonly emitter: OIMEventEmitter<{
78
91
  0: TOIMIndexUpdatePayload<TKey>;
79
92
  }>;
80
- constructor(options?: TOIMIndexOptions<TPk>);
93
+ constructor(options?: TOIMIndexOptions<TKey, TPk>);
81
94
  /**
82
95
  * Get primary keys for multiple index keys
83
96
  */
@@ -136,16 +149,56 @@ declare abstract class OIMIndex<TKey extends TOIMPk, TPk extends TOIMPk> {
136
149
  protected emitUpdate(keys: TKey[]): void;
137
150
  }
138
151
 
152
+ /**
153
+ * Manual index that allows direct manipulation of key-to-primary-keys mappings.
154
+ * Extends the abstract OIMIndex with manual control methods and optional comparison.
155
+ */
156
+ declare class OIMIndexManual<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndex<TIndexKey, TPk> {
157
+ constructor(options?: TOIMIndexOptions<TIndexKey, TPk>);
158
+ /**
159
+ * Set primary keys for a specific index key, replacing any existing values.
160
+ * Uses optional comparator to skip updates if PKs haven't actually changed.
161
+ */
162
+ setPks(key: TIndexKey, pks: TPk[]): void;
163
+ /**
164
+ * Add primary keys to a specific index key
165
+ */
166
+ addPks(key: TIndexKey, pks: readonly TPk[]): void;
167
+ /**
168
+ * Remove primary keys from a specific index key
169
+ */
170
+ removePks(key: TIndexKey, pks: readonly TPk[]): void;
171
+ /**
172
+ * Clear all primary keys for a specific index key, or all keys if no key specified
173
+ */
174
+ clear(key?: TIndexKey): void;
175
+ }
176
+
177
+ /**
178
+ * Static class containing OIMDB settings and constants.
179
+ * Provides access to configuration values used throughout the library.
180
+ */
181
+ declare class OIMDBSettings {
182
+ /**
183
+ * Fixed key used in the manual index to store updated keys set in coalescers.
184
+ * This constant is exported so users can create their own indexes and pass them to coalescers.
185
+ */
186
+ static readonly UPDATED_KEYS_INDEX_KEY: "__updatedKeys__";
187
+ }
188
+
139
189
  /**
140
190
  * Base abstract coalescer that groups updates by keys and emits consolidated events.
141
191
  * Designed to be extended for different entity types (collections, indexes, etc.).
142
192
  */
143
- declare abstract class OIMUpdateEventCoalescer<TKey> {
193
+ declare abstract class OIMUpdateEventCoalescer<TKey extends TOIMPk> {
144
194
  readonly emitter: OIMEventEmitter<{
145
195
  0: void;
196
+ 1: void;
197
+ 2: void;
146
198
  }>;
147
- protected updatedKeys: Set<TKey>;
199
+ protected readonly updatedKeysIndex: OIMIndexManual<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>;
148
200
  private hasEmittedChanges;
201
+ constructor(index?: OIMIndexManual<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>);
149
202
  /**
150
203
  * Get the set of keys that have been updated since last clear
151
204
  */
@@ -157,7 +210,7 @@ declare abstract class OIMUpdateEventCoalescer<TKey> {
157
210
  /**
158
211
  * Add keys to the updated set and emit HAS_CHANGES event if needed
159
212
  */
160
- protected addUpdatedKeys(keys: TKey[]): void;
213
+ protected addUpdatedKeys(keys: readonly TKey[]): void;
161
214
  /**
162
215
  * Clean up event listeners when coalescer is no longer needed
163
216
  */
@@ -176,10 +229,16 @@ type TOIMEventQueueOptions = {
176
229
  scheduler?: OIMEventQueueScheduler;
177
230
  };
178
231
 
232
+ declare enum EOIMEventQueueEventType {
233
+ AFTER_FLUSH = 0,
234
+ BEFORE_FLUSH = 1
235
+ }
236
+
179
237
  /**
180
238
  * Event queue that can optionally integrate with a scheduler for automatic flushing.
181
239
  */
182
240
  declare class OIMEventQueue {
241
+ readonly emitter: OIMEventEmitter<Record<EOIMEventQueueEventType, void>>;
183
242
  protected queue: (() => void)[];
184
243
  protected readonly scheduler?: OIMEventQueueScheduler;
185
244
  protected flushBound?: () => void;
@@ -214,7 +273,7 @@ declare class OIMEventQueue {
214
273
 
215
274
  /**
216
275
  * Options for creating an update event emitter */
217
- type TOIMUpdateEventEmitterOptions<TKey> = {
276
+ type TOIMUpdateEventEmitterOptions<TKey extends TOIMPk> = {
218
277
  coalescer: OIMUpdateEventCoalescer<TKey>;
219
278
  queue: OIMEventQueue;
220
279
  };
@@ -223,7 +282,7 @@ type TOIMUpdateEventEmitterOptions<TKey> = {
223
282
  * Universal event emitter that handles subscriptions and notifications for any key type.
224
283
  * Optimized for performance with adaptive algorithms and memory management.
225
284
  */
226
- declare class OIMUpdateEventEmitter<TKey> {
285
+ declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
227
286
  protected keyHandlers: Map<TKey, Set<TOIMEventHandler<void>>>;
228
287
  protected coalescer: OIMUpdateEventCoalescer<TKey>;
229
288
  protected queue: OIMEventQueue;
@@ -261,7 +320,7 @@ declare enum EOIMIndexEventType {
261
320
  * Index-specific coalescer that tracks index key updates and emits consolidated change events.
262
321
  * Takes an event emitter directly instead of the whole index to avoid circular dependencies.
263
322
  */
264
- declare class OIMUpdateEventCoalescerIndex<TIndexKey> extends OIMUpdateEventCoalescer<TIndexKey> {
323
+ declare class OIMUpdateEventCoalescerIndex<TIndexKey extends TOIMPk> extends OIMUpdateEventCoalescer<TIndexKey> {
265
324
  private readonly indexEmitter;
266
325
  constructor(indexEmitter: OIMEventEmitter<{
267
326
  [EOIMIndexEventType.UPDATE]: TOIMIndexUpdatePayload<TIndexKey>;
@@ -327,6 +386,8 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
327
386
  upsertMany(entities: TEntity[]): void;
328
387
  removeOne(entity: TEntity): void;
329
388
  removeMany(entities: TEntity[]): void;
389
+ removeOneByPk(pk: TPk): void;
390
+ removeManyByPks(pks: readonly TPk[]): void;
330
391
  clear(): void;
331
392
  countAll(): number;
332
393
  getAll(): TEntity[];
@@ -354,48 +415,10 @@ declare class OIMUpdateEventCoalescerCollection<TPk extends TOIMPk> extends OIMU
354
415
  private handleUpdate;
355
416
  }
356
417
 
357
- declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> {
358
- readonly collection: OIMCollection<TEntity, TPk>;
418
+ declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> {
359
419
  readonly updateEventEmitter: OIMUpdateEventEmitter<TPk>;
360
420
  readonly coalescer: OIMUpdateEventCoalescerCollection<TPk>;
361
- constructor(queue: OIMEventQueue, opts?: {
362
- collectionOpts?: TOIMCollectionOptions<TEntity, TPk>;
363
- });
364
- upsertMany(entities: TEntity[]): void;
365
- upsertOne(entity: TEntity): void;
366
- removeMany(entities: TEntity[]): void;
367
- removeOne(entity: TEntity): void;
368
- getOneByPk(pk: TPk): TEntity | undefined;
369
- getManyByPks(pks: readonly TPk[]): TEntity[];
370
- clear(): void;
371
- countAll(): number;
372
- getAll(): TEntity[];
373
- getAllPks(): TPk[];
374
- }
375
-
376
- /**
377
- * Manual index that allows direct manipulation of key-to-primary-keys mappings.
378
- * Extends the abstract OIMIndex with manual control methods and optional comparison.
379
- */
380
- declare class OIMIndexManual<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndex<TIndexKey, TPk> {
381
- constructor(options?: TOIMIndexOptions<TPk>);
382
- /**
383
- * Set primary keys for a specific index key, replacing any existing values.
384
- * Uses optional comparator to skip updates if PKs haven't actually changed.
385
- */
386
- setPks(key: TIndexKey, pks: TPk[]): void;
387
- /**
388
- * Add primary keys to a specific index key
389
- */
390
- addPks(key: TIndexKey, pks: readonly TPk[]): void;
391
- /**
392
- * Remove primary keys from a specific index key
393
- */
394
- removePks(key: TIndexKey, pks: readonly TPk[]): void;
395
- /**
396
- * Clear all primary keys for a specific index key, or all keys if no key specified
397
- */
398
- clear(key?: TIndexKey): void;
421
+ constructor(queue: OIMEventQueue, opts?: TOIMCollectionOptions<TEntity, TPk>);
399
422
  }
400
423
 
401
424
  declare class OIMReactiveIndexManual<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMReactiveIndex<TKey, TPk, OIMIndexManual<TKey, TPk>> {
@@ -409,11 +432,11 @@ declare class OIMReactiveIndexManual<TKey extends TOIMPk, TPk extends TOIMPk> ex
409
432
  clear(key?: TKey): void;
410
433
  }
411
434
 
412
- declare class OIMRICollection<TEntity extends object, TPk extends TOIMPk, TIndexName extends string, TIndexKey extends TOIMPk, TIndex extends OIMIndex<TIndexKey, TPk>, TReactiveIndex extends OIMReactiveIndex<TIndexKey, TPk, TIndex>> extends OIMReactiveCollection<TEntity, TPk> {
413
- readonly indexes: Record<TIndexName, TReactiveIndex>;
435
+ declare class OIMRICollection<TEntity extends object, TPk extends TOIMPk, TIndexName extends string, TIndexKey extends TOIMPk, TIndex extends OIMIndex<TIndexKey, TPk>, TReactiveIndex extends OIMReactiveIndex<TIndexKey, TPk, TIndex>, TReactiveIndexMap extends Record<TIndexName, TReactiveIndex> = Record<TIndexName, TReactiveIndex>> extends OIMReactiveCollection<TEntity, TPk> {
436
+ readonly indexes?: TReactiveIndexMap;
414
437
  constructor(queue: OIMEventQueue, opts: {
415
438
  collectionOpts?: TOIMCollectionOptions<TEntity, TPk>;
416
- indexes: Record<TIndexName, TReactiveIndex>;
439
+ indexes?: TReactiveIndexMap;
417
440
  });
418
441
  }
419
442
 
@@ -585,7 +608,9 @@ declare class OIMEventQueueSchedulerFactory {
585
608
  /**
586
609
  * Event types for update coalescers */
587
610
  declare enum EOIMUpdateEventCoalescerEventType {
588
- HAS_CHANGES = 0
611
+ HAS_CHANGES = 0,
612
+ BEFORE_FLUSH = 1,
613
+ AFTER_FLUSH = 2
589
614
  }
590
615
 
591
616
  type TOIMIndexKey = string | number | bigint;
@@ -601,4 +626,4 @@ type TOIMUpdatePayload<TKey> = {
601
626
  keys: readonly TKey[];
602
627
  };
603
628
 
604
- export { EOIMCollectionEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMUpdateEventCoalescerEventType, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndex, OIMIndexComparatorFactory, OIMIndexManual, OIMMap2Keys, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndex, OIMReactiveIndexManual, OIMUpdateEventCoalescer, OIMUpdateEventCoalescerCollection, OIMUpdateEventCoalescerIndex, OIMUpdateEventEmitter, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdateEventEmitterOptions, type TOIMUpdatePayload };
629
+ export { EOIMCollectionEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMUpdateEventCoalescerEventType, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMDBSettings, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndex, OIMIndexComparatorFactory, OIMIndexManual, OIMMap2Keys, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndex, OIMReactiveIndexManual, OIMUpdateEventCoalescer, OIMUpdateEventCoalescerCollection, OIMUpdateEventCoalescerIndex, OIMUpdateEventEmitter, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdateEventEmitterOptions, type TOIMUpdatePayload };