@oimdb/core 1.3.1 → 1.4.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.
package/dist/index.d.cts CHANGED
@@ -10,6 +10,7 @@ declare abstract class OIMCollectionStore<TEntity extends object, TPk extends TO
10
10
  abstract getAllPks(): TPk[];
11
11
  abstract countAll(): number;
12
12
  abstract clear(): void;
13
+ abstract destroy(): void;
13
14
  }
14
15
 
15
16
  declare abstract class OIMIndexStoreSetBased<TKey extends TOIMPk, TPk extends TOIMPk> {
@@ -40,9 +41,15 @@ type TOIMEventHandler<T> = (payload: T) => void;
40
41
 
41
42
  declare class OIMEventEmitter<T extends Record<string, unknown>> {
42
43
  private buckets;
44
+ hasHandlers<K extends keyof T>(event: K): boolean;
43
45
  private getOrCreateBucket;
46
+ /**
47
+ * Compacts the handlers array by removing null entries (tombstones) left by handler removal.
48
+ * Rebuilds the indexByHandler map with updated indices and resets the tombstone count.
49
+ * This reduces array fragmentation and improves iteration performance.
50
+ */
44
51
  private compactBucket;
45
- on<K extends keyof T>(event: K, handler: TOIMEventHandler<T[K]>): void;
52
+ on<K extends keyof T>(event: K, handler: TOIMEventHandler<T[K]>): () => void;
46
53
  emit<K extends keyof T>(event: K, payload: T[K]): void;
47
54
  off<K extends keyof T>(event: K, handler: TOIMEventHandler<T[K]>): void;
48
55
  offAll<K extends keyof T>(event?: K): void;
@@ -155,6 +162,10 @@ declare abstract class OIMIndexSetBased<TKey extends TOIMPk, TPk extends TOIMPk>
155
162
  * Emit update event with changed keys
156
163
  */
157
164
  protected emitUpdate(keys: TKey[]): void;
165
+ /**
166
+ * Emit update event for a single key (fast-path override point).
167
+ */
168
+ protected emitUpdateOne(key: TKey): void;
158
169
  }
159
170
 
160
171
  /**
@@ -222,78 +233,10 @@ declare abstract class OIMIndexArrayBased<TKey extends TOIMPk, TPk extends TOIMP
222
233
  * Emit update event with changed keys
223
234
  */
224
235
  protected emitUpdate(keys: TKey[]): void;
225
- }
226
-
227
- /**
228
- * Manual Set-based index that allows direct manipulation of key-to-primary-keys mappings.
229
- * Extends the abstract OIMIndexSetBased with manual control methods and optional comparison.
230
- */
231
- declare class OIMIndexManualSetBased<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndexSetBased<TIndexKey, TPk> {
232
- constructor(options?: {
233
- comparePks?: TOIMIndexComparator<TPk>;
234
- store?: OIMIndexStoreSetBased<TIndexKey, TPk>;
235
- });
236
236
  /**
237
- * Set primary keys for a specific index key, replacing any existing values.
238
- * Uses optional comparator to skip updates if PKs haven't actually changed.
237
+ * Emit update event for a single key (fast-path override point).
239
238
  */
240
- setPks(key: TIndexKey, pks: TPk[]): void;
241
- /**
242
- * Add primary keys to a specific index key
243
- */
244
- addPks(key: TIndexKey, pks: readonly TPk[]): void;
245
- /**
246
- * Remove primary keys from a specific index key
247
- */
248
- removePks(key: TIndexKey, pks: readonly TPk[]): void;
249
- /**
250
- * Clear all primary keys for a specific index key, or all keys if no key specified
251
- */
252
- clear(key?: TIndexKey): void;
253
- }
254
-
255
- /**
256
- * Static class containing OIMDB settings and constants.
257
- * Provides access to configuration values used throughout the library.
258
- */
259
- declare class OIMDBSettings {
260
- /**
261
- * Fixed key used in the manual index to store updated keys set in coalescers.
262
- * This constant is exported so users can create their own indexes and pass them to coalescers.
263
- */
264
- static readonly UPDATED_KEYS_INDEX_KEY: "__updatedKeys__";
265
- }
266
-
267
- /**
268
- * Base abstract coalescer that groups updates by keys and emits consolidated events.
269
- * Designed to be extended for different entity types (collections, indexes, etc.).
270
- * Uses SetBased indexes for efficient key tracking.
271
- */
272
- declare abstract class OIMUpdateEventCoalescer<TKey extends TOIMPk> {
273
- readonly emitter: OIMEventEmitter<{
274
- 0: void;
275
- 1: void;
276
- 2: void;
277
- }>;
278
- protected readonly updatedKeysIndex: OIMIndexManualSetBased<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>;
279
- private hasEmittedChanges;
280
- constructor(index?: OIMIndexManualSetBased<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>);
281
- /**
282
- * Get the set of keys that have been updated since last clear
283
- */
284
- getUpdatedKeys(): Set<TKey>;
285
- /**
286
- * Clear all updated keys and reset the changed state
287
- */
288
- clearUpdatedKeys(): void;
289
- /**
290
- * Add keys to the updated set and emit HAS_CHANGES event if needed
291
- */
292
- protected addUpdatedKeys(keys: readonly TKey[]): void;
293
- /**
294
- * Clean up event listeners when coalescer is no longer needed
295
- */
296
- abstract destroy(): void;
239
+ protected emitUpdateOne(key: TKey): void;
297
240
  }
298
241
 
299
242
  /**
@@ -318,18 +261,26 @@ declare enum EOIMEventQueueEventType {
318
261
  */
319
262
  declare class OIMEventQueue {
320
263
  readonly emitter: OIMEventEmitter<Record<EOIMEventQueueEventType, void>>;
321
- protected queue: (() => void)[];
264
+ protected tasks: Set<() => void>;
322
265
  protected readonly scheduler?: OIMEventQueueScheduler;
323
266
  protected flushBound?: () => void;
267
+ protected isFlushing: boolean;
324
268
  constructor(options?: TOIMEventQueueOptions);
325
269
  /**
326
- * Add a function to the queue. If scheduler is configured and autoSchedule is enabled,
327
- * automatically schedules a flush operation.
270
+ * Enqueue a one-shot task to be executed on the next flush.
271
+ * Returns a dequeue function that can be called to cancel the task before it runs.
328
272
  */
329
- enqueue(fn: () => void): void;
273
+ enqueue(fn: () => void): () => void;
274
+ get isInFlush(): boolean;
330
275
  /**
331
- * Execute all queued functions and clear the queue.
332
- * This method is safe to call multiple times and handles reentrancy.
276
+ * Dequeue (cancel) a previously enqueued task by its dequeue function.
277
+ */
278
+ dequeue(dequeueFn: () => void): void;
279
+ /**
280
+ * Execute all pending tasks.
281
+ *
282
+ * This flush drains until the queue is empty. If tasks enqueue more tasks, they will be
283
+ * executed within the same flush.
333
284
  */
334
285
  flush(): void;
335
286
  /**
@@ -344,29 +295,44 @@ declare class OIMEventQueue {
344
295
  * Clear the queue without executing functions and cancel any scheduled flush.
345
296
  */
346
297
  clear(): void;
298
+ protected ensureScheduled(): void;
347
299
  /**
348
300
  * Clean up scheduler subscription when queue is no longer needed.
349
301
  */
350
302
  destroy(): void;
351
303
  }
352
304
 
353
- /**
354
- * Options for creating an update event emitter */
355
- type TOIMUpdateEventEmitterOptions<TKey extends TOIMPk> = {
356
- coalescer: OIMUpdateEventCoalescer<TKey>;
357
- queue: OIMEventQueue;
358
- };
359
-
305
+ type TOIMUpdateEventEmitterDeliveryMode = 'queue' | 'after_flush' | 'immediate';
360
306
  /**
361
307
  * Universal event emitter that handles subscriptions and notifications for any key type.
362
308
  * Optimized for performance with adaptive algorithms and memory management.
363
309
  */
364
310
  declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
365
311
  protected keyHandlers: Map<TKey, Set<TOIMEventHandler<void>>>;
366
- protected coalescer: OIMUpdateEventCoalescer<TKey>;
367
312
  protected queue: OIMEventQueue;
368
- constructor(opts: TOIMUpdateEventEmitterOptions<TKey>);
369
- protected handleHasChanges: () => void;
313
+ private readonly deliveryMode;
314
+ private isFlushEnqueued;
315
+ private dequeueFlush?;
316
+ private updatedKeys;
317
+ private isAfterFlushDeliveryScheduled;
318
+ private unsubscribeAfterFlushDelivery?;
319
+ constructor(queue: OIMEventQueue, deliveryMode?: TOIMUpdateEventEmitterDeliveryMode);
320
+ /**
321
+ * Mark keys as updated and schedule delivery.
322
+ *
323
+ * If there are no subscriptions, this is a no-op and does not allocate or retain keys.
324
+ */
325
+ markUpdatedKeys(keys: readonly TKey[]): void;
326
+ markUpdatedKey(key: TKey): void;
327
+ markAllUpdated(): void;
328
+ protected readonly onFlush: () => void;
329
+ private deliverImmediate;
330
+ private readonly onAfterFlush;
331
+ /**
332
+ * Deliver updated keys and notify handlers once.
333
+ * Re-entrant updates during delivery are forbidden and will throw in markUpdatedKeys().
334
+ */
335
+ protected runSinglePass(makeHandlerSnapshot: (handlers: Set<TOIMEventHandler<void>>) => TOIMEventHandler<void>[]): void;
370
336
  destroy(): void;
371
337
  /**
372
338
  * Get performance metrics for monitoring and debugging
@@ -391,34 +357,15 @@ declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
391
357
  unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
392
358
  }
393
359
 
394
- declare enum EOIMIndexEventType {
395
- UPDATE = 0
396
- }
397
-
398
- /**
399
- * Index-specific coalescer that tracks index key updates and emits consolidated change events.
400
- * Takes an event emitter directly instead of the whole index to avoid circular dependencies.
401
- */
402
- declare class OIMUpdateEventCoalescerIndex<TIndexKey extends TOIMPk> extends OIMUpdateEventCoalescer<TIndexKey> {
403
- private readonly indexEmitter;
404
- constructor(indexEmitter: OIMEventEmitter<{
405
- [EOIMIndexEventType.UPDATE]: TOIMIndexUpdatePayload<TIndexKey>;
406
- }>);
407
- destroy(): void;
408
- /**
409
- * When the index is updated, we keep track of the updated keys.
410
- */
411
- private handleUpdate;
360
+ interface IOIMKeyedSubscription<TKey extends TOIMPk> {
361
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
362
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
412
363
  }
413
364
 
414
- declare abstract class OIMReactiveIndexSetBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> {
365
+ declare abstract class OIMReactiveIndexSetBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> implements IOIMKeyedSubscription<TKey> {
415
366
  readonly index: TIndex;
416
- readonly updateEventEmitter: OIMUpdateEventEmitter<TKey>;
417
- readonly coalescer: OIMUpdateEventCoalescerIndex<TKey>;
418
- constructor(queue: OIMEventQueue, opts?: {
419
- index: TIndex;
420
- });
421
- protected abstract createDefaultIndex(): TIndex;
367
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
368
+ constructor(queue: OIMEventQueue, createIndex: (updateEmitter: OIMUpdateEventEmitter<TKey>) => TIndex);
422
369
  getPksByKey(key: TKey): Set<TPk>;
423
370
  getPksByKeys(keys: readonly TKey[]): Map<TKey, Set<TPk>>;
424
371
  hasKey(key: TKey): boolean;
@@ -433,17 +380,25 @@ declare abstract class OIMReactiveIndexSetBased<TKey extends TOIMPk, TPk extends
433
380
  maxBucketSize: number;
434
381
  minBucketSize: number;
435
382
  };
383
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
384
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
385
+ unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
386
+ unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
387
+ hasSubscriptions(): boolean;
388
+ getHandlerCount(key: TKey): number;
389
+ getSubscriptionMetrics(): {
390
+ totalKeys: number;
391
+ totalHandlers: number;
392
+ averageHandlersPerKey: number;
393
+ queueLength: number;
394
+ };
436
395
  destroy(): void;
437
396
  }
438
397
 
439
- declare abstract class OIMReactiveIndexArrayBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> {
398
+ declare abstract class OIMReactiveIndexArrayBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> implements IOIMKeyedSubscription<TKey> {
440
399
  readonly index: TIndex;
441
- readonly updateEventEmitter: OIMUpdateEventEmitter<TKey>;
442
- readonly coalescer: OIMUpdateEventCoalescerIndex<TKey>;
443
- constructor(queue: OIMEventQueue, opts?: {
444
- index: TIndex;
445
- });
446
- protected abstract createDefaultIndex(): TIndex;
400
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
401
+ constructor(queue: OIMEventQueue, createIndex: (updateEmitter: OIMUpdateEventEmitter<TKey>) => TIndex);
447
402
  getPksByKey(key: TKey): TPk[];
448
403
  getPksByKeys(keys: readonly TKey[]): Map<TKey, TPk[]>;
449
404
  hasKey(key: TKey): boolean;
@@ -458,9 +413,35 @@ declare abstract class OIMReactiveIndexArrayBased<TKey extends TOIMPk, TPk exten
458
413
  maxBucketSize: number;
459
414
  minBucketSize: number;
460
415
  };
416
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
417
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
418
+ unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
419
+ unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
420
+ hasSubscriptions(): boolean;
421
+ getHandlerCount(key: TKey): number;
422
+ getSubscriptionMetrics(): {
423
+ totalKeys: number;
424
+ totalHandlers: number;
425
+ averageHandlersPerKey: number;
426
+ queueLength: number;
427
+ };
461
428
  destroy(): void;
462
429
  }
463
430
 
431
+ declare abstract class OIMObjectStore<TKey extends string | number | symbol, TValue> {
432
+ abstract setProperty(key: TKey, value: TValue): void;
433
+ abstract merge(draft: Partial<Record<TKey, TValue>>): void;
434
+ abstract delete(key: TKey): void;
435
+ abstract get(key: TKey): TValue | undefined;
436
+ abstract getAll(): Record<TKey, TValue>;
437
+ abstract clear(): void;
438
+ abstract count(): number;
439
+ abstract keys(): TKey[];
440
+ abstract values(): TValue[];
441
+ abstract entries(): [TKey, TValue][];
442
+ abstract destroy(): void;
443
+ }
444
+
464
445
  type TOIMPkSelector<TEntity extends object, TPk extends TOIMPk> = (entity: TEntity) => TPk;
465
446
 
466
447
  type TOIMEntityUpdater<TEntity extends object> = (draft: Partial<TEntity>, prevEntity: TEntity) => TEntity;
@@ -480,7 +461,7 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
480
461
  readonly emitter: OIMEventEmitter<{
481
462
  0: TOIMCollectionUpdatePayload<TPk>;
482
463
  }>;
483
- protected readonly selectPk: TOIMPkSelector<TEntity, TPk>;
464
+ readonly selectPk: TOIMPkSelector<TEntity, TPk>;
484
465
  protected readonly store: OIMCollectionStore<TEntity, TPk>;
485
466
  protected readonly updateEntity: TOIMEntityUpdater<TEntity>;
486
467
  constructor(opts?: TOIMCollectionOptions<TEntity, TPk>);
@@ -499,39 +480,131 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
499
480
  getAllPks(): TPk[];
500
481
  protected upsertOneWithoutNotifications(entity: TEntity | Partial<TEntity>): TPk;
501
482
  protected upsertOneWithoutNotificationsByPk(pk: TPk, entity: Partial<TEntity> | TEntity): void;
483
+ destroy(): void;
502
484
  }
503
485
 
504
- declare enum EOIMCollectionEventType {
505
- UPDATE = 0
486
+ declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> implements IOIMKeyedSubscription<TPk> {
487
+ private readonly queue;
488
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TPk>;
489
+ private readonly anyUpdateHandlers;
490
+ private pendingAnyUpdatePks;
491
+ private isAnyUpdateClearPending;
492
+ private isAnyUpdateScheduled;
493
+ private dequeueAnyUpdate?;
494
+ constructor(queue: OIMEventQueue, opts?: TOIMCollectionOptions<TEntity, TPk>);
495
+ subscribeOnKey(pk: TPk, handler: TOIMEventHandler<void>): () => void;
496
+ subscribeOnKeys(pks: readonly TPk[], handler: TOIMEventHandler<void>): () => void;
497
+ unsubscribeFromKey(pk: TPk, handler: TOIMEventHandler<void>): void;
498
+ unsubscribeFromKeys(pks: readonly TPk[], handler: TOIMEventHandler<void>): void;
499
+ destroySubscriptions(): void;
500
+ hasSubscriptions(): boolean;
501
+ getHandlerCount(pk: TPk): number;
502
+ getMetrics(): {
503
+ totalKeys: number;
504
+ totalHandlers: number;
505
+ averageHandlersPerKey: number;
506
+ queueLength: number;
507
+ };
508
+ subscribeOnAnyUpdate(handler: (pks: readonly TPk[]) => void): () => void;
509
+ upsertOneByPk(pk: TPk, entity: Partial<TEntity>): void;
510
+ upsertOne(entity: TEntity | Partial<TEntity>): void;
511
+ upsertMany(entities: (TEntity | Partial<TEntity>)[]): void;
512
+ removeOne(entity: TEntity): void;
513
+ removeMany(entities: TEntity[]): void;
514
+ removeOneByPk(pk: TPk): void;
515
+ removeManyByPks(pks: readonly TPk[]): void;
516
+ clear(): void;
517
+ private trackAnyUpdatePk;
518
+ private trackAnyUpdatePks;
519
+ private trackAnyUpdateClear;
520
+ private ensureAnyUpdateEnqueued;
521
+ private readonly runAnyUpdate;
522
+ destroy(): void;
506
523
  }
507
524
 
508
525
  /**
509
- * Collection-specific coalescer that tracks primary key updates and emits consolidated change events.
510
- * Takes an event emitter directly instead of the whole collection to avoid circular dependencies.
511
- */
512
- declare class OIMUpdateEventCoalescerCollection<TPk extends TOIMPk> extends OIMUpdateEventCoalescer<TPk> {
513
- private readonly collectionEmitter;
514
- constructor(collectionEmitter: OIMEventEmitter<{
515
- [EOIMCollectionEventType.UPDATE]: TOIMCollectionUpdatePayload<TPk>;
516
- }>);
526
+ * Payload type for update events that contain keys */
527
+ type TOIMUpdatePayload<TKey> = {
528
+ keys: readonly TKey[];
529
+ };
530
+
531
+ type TOIMObjectOptions<TKey extends string, TValue> = {
532
+ store?: OIMObjectStore<TKey, TValue>;
533
+ };
534
+
535
+ /** It's like a store - but with event emitter */
536
+ declare class OIMObject<TKey extends string, TValue> {
537
+ readonly emitter: OIMEventEmitter<{
538
+ 0: TOIMUpdatePayload<TKey>;
539
+ }>;
540
+ protected readonly store: OIMObjectStore<TKey, TValue>;
541
+ constructor(opts?: TOIMObjectOptions<TKey, TValue>);
542
+ setProperty(key: TKey, value: TValue): void;
543
+ merge(draft: Partial<Record<TKey, TValue>>): void;
544
+ delete(key: TKey): void;
545
+ get(key: TKey): TValue | undefined;
546
+ getAll(): Record<TKey, TValue>;
547
+ clear(): void;
548
+ count(): number;
549
+ keys(): TKey[];
550
+ values(): TValue[];
551
+ entries(): [TKey, TValue][];
517
552
  destroy(): void;
518
- /**
519
- * When the collection is updated, we keep track of the updated pks.
520
- */
521
- private handleUpdate;
522
553
  }
523
554
 
524
- declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> {
525
- readonly updateEventEmitter: OIMUpdateEventEmitter<TPk>;
526
- readonly coalescer: OIMUpdateEventCoalescerCollection<TPk>;
527
- constructor(queue: OIMEventQueue, opts?: TOIMCollectionOptions<TEntity, TPk>);
555
+ declare class OIMReactiveObject<TKey extends string, TValue> extends OIMObject<TKey, TValue> implements IOIMKeyedSubscription<TKey> {
556
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
557
+ constructor(queue: OIMEventQueue, opts?: TOIMObjectOptions<TKey, TValue>);
558
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
559
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
560
+ unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
561
+ unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
562
+ hasSubscriptions(): boolean;
563
+ getHandlerCount(key: TKey): number;
564
+ getMetrics(): {
565
+ totalKeys: number;
566
+ totalHandlers: number;
567
+ averageHandlersPerKey: number;
568
+ queueLength: number;
569
+ };
570
+ destroy(): void;
571
+ }
572
+
573
+ /**
574
+ * Manual Set-based index that allows direct manipulation of key-to-primary-keys mappings.
575
+ * Extends the abstract OIMIndexSetBased with manual control methods and optional comparison.
576
+ */
577
+ declare class OIMIndexManualSetBased<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndexSetBased<TIndexKey, TPk> {
578
+ constructor(options?: {
579
+ comparePks?: TOIMIndexComparator<TPk>;
580
+ store?: OIMIndexStoreSetBased<TIndexKey, TPk>;
581
+ });
582
+ /**
583
+ * Set primary keys for a specific index key, replacing any existing values.
584
+ * Uses optional comparator to skip updates if PKs haven't actually changed.
585
+ */
586
+ setPks(key: TIndexKey, pks: TPk[]): void;
587
+ /**
588
+ * Add primary keys to a specific index key
589
+ */
590
+ addPks(key: TIndexKey, pks: readonly TPk[]): void;
591
+ /**
592
+ * Remove primary keys from a specific index key
593
+ */
594
+ removePks(key: TIndexKey, pks: readonly TPk[]): void;
595
+ /**
596
+ * Clear all primary keys for a specific index key, or all keys if no key specified
597
+ */
598
+ clear(key?: TIndexKey): void;
528
599
  }
529
600
 
530
601
  declare class OIMReactiveIndexManualSetBased<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMReactiveIndexSetBased<TKey, TPk, OIMIndexManualSetBased<TKey, TPk>> {
531
602
  constructor(queue: OIMEventQueue, opts?: {
532
- index: OIMIndexManualSetBased<TKey, TPk>;
603
+ indexOptions?: {
604
+ comparePks?: TOIMIndexComparator<TPk>;
605
+ store?: OIMIndexStoreSetBased<TKey, TPk>;
606
+ };
533
607
  });
534
- protected createDefaultIndex(): OIMIndexManualSetBased<TKey, TPk>;
535
608
  setPks(key: TKey, pks: TPk[]): void;
536
609
  addPks(key: TKey, pks: readonly TPk[]): void;
537
610
  removePks(key: TKey, pks: readonly TPk[]): void;
@@ -568,9 +641,11 @@ declare class OIMIndexManualArrayBased<TIndexKey extends TOIMPk, TPk extends TOI
568
641
 
569
642
  declare class OIMReactiveIndexManualArrayBased<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMReactiveIndexArrayBased<TKey, TPk, OIMIndexManualArrayBased<TKey, TPk>> {
570
643
  constructor(queue: OIMEventQueue, opts?: {
571
- index: OIMIndexManualArrayBased<TKey, TPk>;
644
+ indexOptions?: {
645
+ comparePks?: TOIMIndexComparator<TPk>;
646
+ store?: OIMIndexStoreArrayBased<TKey, TPk>;
647
+ };
572
648
  });
573
- protected createDefaultIndex(): OIMIndexManualArrayBased<TKey, TPk>;
574
649
  setPks(key: TKey, pks: TPk[]): void;
575
650
  addPks(key: TKey, pks: readonly TPk[]): void;
576
651
  removePks(key: TKey, pks: readonly TPk[]): void;
@@ -598,6 +673,44 @@ declare class OIMCollectionStoreMapDriven<TEntity extends object, TPk extends TO
598
673
  countAll(): number;
599
674
  clear(): void;
600
675
  getAllPks(): TPk[];
676
+ destroy(): void;
677
+ }
678
+
679
+ declare class OIMObjectStoreMapDriven<TKey extends TOIMPk, TValue> extends OIMObjectStore<TKey, TValue> {
680
+ protected readonly properties: Map<TKey, TValue>;
681
+ setProperty(key: TKey, value: TValue): void;
682
+ merge(draft: Partial<Record<TKey, TValue>>): void;
683
+ delete(key: TKey): void;
684
+ get(key: TKey): TValue | undefined;
685
+ getAll(): Record<TKey, TValue>;
686
+ clear(): void;
687
+ count(): number;
688
+ keys(): TKey[];
689
+ values(): TValue[];
690
+ entries(): [TKey, TValue][];
691
+ destroy(): void;
692
+ }
693
+
694
+ /**
695
+ * Record-driven store (plain object) for OIMObject.
696
+ *
697
+ * Note: object keys are strings at runtime, so this store is limited to string keys
698
+ * for type-safety and predictable semantics.
699
+ */
700
+ declare class OIMObjectStoreRecordDriven<TKey extends string, TValue> extends OIMObjectStore<TKey, TValue> {
701
+ protected properties: Record<TKey, TValue>;
702
+ constructor(initial?: Partial<Record<TKey, TValue>>);
703
+ setProperty(key: TKey, value: TValue): void;
704
+ merge(draft: Partial<Record<TKey, TValue>>): void;
705
+ delete(key: TKey): void;
706
+ get(key: TKey): TValue | undefined;
707
+ getAll(): Record<TKey, TValue>;
708
+ clear(): void;
709
+ count(): number;
710
+ keys(): TKey[];
711
+ values(): TValue[];
712
+ entries(): [TKey, TValue][];
713
+ destroy(): void;
601
714
  }
602
715
 
603
716
  declare class OIMIndexStoreMapDrivenSetBased<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndexStoreSetBased<TKey, TPk> {
@@ -680,6 +793,145 @@ declare class OIMPkSelectorFactory<TEntity extends object, TPk extends TOIMPk> {
680
793
  }, TPk>;
681
794
  }
682
795
 
796
+ type TOIMFieldKey<TEntity extends object> = keyof TEntity & string;
797
+ /**
798
+ * Wrapper around `OIMCollection` that tracks "changed fields" per entity PK.
799
+ *
800
+ * Important: to get field-level info, you must perform writes through this wrapper.
801
+ *
802
+ * DX: if the underlying collection is mutated directly (bypassing this wrapper), we detect it
803
+ * via collection update events and infer changed fields by diffing the last observed entity snapshot.
804
+ */
805
+ declare class OIMCollectionChangedFieldsWrapper<TEntity extends object, TPk extends TOIMPk> {
806
+ readonly collection: OIMCollection<TEntity, TPk>;
807
+ private readonly selectPk;
808
+ private readonly unsubscribeAfterFlush;
809
+ private readonly unsubscribeFromCollectionEmitter;
810
+ private isInWrite;
811
+ private readonly lastEntitySnapshotByPk;
812
+ /**
813
+ * Emits updates scoped by PK. Subscribe, then read state via `getChangedFieldsByPk(...)`
814
+ * or drain via `consumeChangedFieldsByPk(...)`.
815
+ */
816
+ readonly changedPksEventEmitter: OIMUpdateEventEmitter<TPk>;
817
+ /**
818
+ * Emits updates scoped by field name. Subscribe, then read state via
819
+ * `getChangedPksByField(...)` or drain via `consumeChangedPksByField(...)`.
820
+ */
821
+ readonly changedFieldsEventEmitter: OIMUpdateEventEmitter<TOIMFieldKey<TEntity>>;
822
+ private readonly changedFieldsByPk;
823
+ private readonly changedPksByField;
824
+ constructor(queue: OIMEventQueue, collection: OIMCollection<TEntity, TPk>, opts?: {
825
+ /**
826
+ * Optional PK selector for convenience APIs like `upsertOne(...)`.
827
+ * If not provided, only `upsertOneByPk(...)` should be used.
828
+ */
829
+ selectPk?: (entity: TEntity | Partial<TEntity>) => TPk;
830
+ });
831
+ upsertOneByPk(pk: TPk, patch: Partial<TEntity>): void;
832
+ upsertOne(entity: TEntity | Partial<TEntity>): void;
833
+ upsertMany(entities: (TEntity | Partial<TEntity>)[]): void;
834
+ getChangedFieldsByPk(pk: TPk): ReadonlySet<TOIMFieldKey<TEntity>>;
835
+ consumeChangedFieldsByPk(pk: TPk): Set<TOIMFieldKey<TEntity>>;
836
+ getChangedPksByField(field: TOIMFieldKey<TEntity>): ReadonlySet<TPk>;
837
+ consumeChangedPksByField(field: TOIMFieldKey<TEntity>): Set<TPk>;
838
+ clear(): void;
839
+ destroy(): void;
840
+ private readonly onAfterFlush;
841
+ private readonly onCollectionUpdate;
842
+ private withWrite;
843
+ private trackExternalMutationByPk;
844
+ private diffChangedKeys;
845
+ private updateEntitySnapshot;
846
+ private trackChangedKeys;
847
+ private trackPatch;
848
+ }
849
+
850
+ /**
851
+ * Manual ordered Array-based index.
852
+ *
853
+ * Unlike `OIMIndexManualArrayBased.addPks/removePks`, this class is explicitly ordered:
854
+ * - preserves order
855
+ * - allows O(1) append (`push`)
856
+ * - supports `move` and `removeAt` without computing diffs
857
+ *
858
+ * It emits UPDATE events per key on every successful mutation.
859
+ */
860
+ declare class OIMIndexManualOrderedArrayBased<TKey extends TOIMPk, TItemKey extends TOIMPk> extends OIMIndexArrayBased<TKey, TItemKey> {
861
+ clear(key?: TKey): void;
862
+ push(key: TKey, itemKey: TItemKey): number;
863
+ insertAt(key: TKey, index: number, itemKey: TItemKey): void;
864
+ removeAt(key: TKey, index: number): TItemKey | undefined;
865
+ move(key: TKey, fromIndex: number, toIndex: number): TItemKey | undefined;
866
+ reset(key: TKey, itemKeys: readonly TItemKey[]): void;
867
+ private getOrCreateList;
868
+ }
869
+
870
+ type TOIMOrderedListCommand<TPk extends TOIMPk> = {
871
+ type: 'add';
872
+ key: TPk;
873
+ index: number;
874
+ } | {
875
+ type: 'remove';
876
+ key: TPk;
877
+ index: number;
878
+ } | {
879
+ type: 'move';
880
+ key: TPk;
881
+ fromIndex: number;
882
+ toIndex: number;
883
+ } | {
884
+ /**
885
+ * Replace the whole list for this key (preferred name).
886
+ */
887
+ type: 'set';
888
+ keys: readonly TPk[];
889
+ };
890
+
891
+ /**
892
+ * Ordered-list wrapper that stores arrays per key and emits a per-key command stream.
893
+ *
894
+ * This is designed for imperative renderers: instead of diffing the full list on each update,
895
+ * you subscribe to `commandsEventEmitter` on a single list key and apply commands sequentially.
896
+ *
897
+ * Notes:
898
+ * - Commands are buffered per key and delivered batched per queue flush.
899
+ * - Order of commands is preserved.
900
+ * - A future optimizer can collapse the command buffer into `set(...)` if needed.
901
+ */
902
+ declare class OIMOrderedListIndexCommandStreamWrapper<TKey extends TOIMPk, TItemKey extends TOIMPk> {
903
+ readonly commandsEventEmitter: OIMUpdateEventEmitter<TKey>;
904
+ private readonly unsubscribeAfterFlush;
905
+ private readonly unsubscribeFromIndexEmitter;
906
+ private isInWrite;
907
+ private readonly commandsByKey;
908
+ /** Underlying ordered index (source of truth for the list). */
909
+ readonly index: OIMIndexManualOrderedArrayBased<TKey, TItemKey>;
910
+ constructor(queue: OIMEventQueue, index?: OIMIndexManualOrderedArrayBased<TKey, TItemKey>);
911
+ getPksByKey(key: TKey): readonly TItemKey[];
912
+ hasKey(key: TKey): boolean;
913
+ getKeys(): readonly TKey[];
914
+ push(key: TKey, itemKey: TItemKey): void;
915
+ removeAt(key: TKey, index: number): void;
916
+ move(key: TKey, fromIndex: number, toIndex: number): void;
917
+ set(key: TKey, keys: readonly TItemKey[]): void;
918
+ /**
919
+ * Read-only peek at buffered commands without clearing them.
920
+ */
921
+ getBufferedCommands(key: TKey): readonly TOIMOrderedListCommand<TItemKey>[];
922
+ /**
923
+ * Drain buffered commands for a key, preserving order.
924
+ * Intended usage: call inside a `commandsEventEmitter.subscribeOnKey(key, ...)` handler.
925
+ */
926
+ consumeCommands(key: TKey): TOIMOrderedListCommand<TItemKey>[];
927
+ clear(key?: TKey): void;
928
+ destroy(): void;
929
+ private readonly onAfterFlush;
930
+ private readonly onIndexUpdate;
931
+ private withWrite;
932
+ private appendCommand;
933
+ }
934
+
683
935
  /**
684
936
  * Animation frame-based scheduler that executes flushes synchronized with the browser's repaint cycle.
685
937
  * Ideal for UI-related updates that need to be synchronized with rendering.
@@ -777,12 +1029,16 @@ declare class OIMEventQueueSchedulerFactory {
777
1029
  static createImmediate(): OIMEventQueueSchedulerImmediate;
778
1030
  }
779
1031
 
780
- /**
781
- * Event types for update coalescers */
782
- declare enum EOIMUpdateEventCoalescerEventType {
783
- HAS_CHANGES = 0,
784
- BEFORE_FLUSH = 1,
785
- AFTER_FLUSH = 2
1032
+ declare enum EOIMCollectionEventType {
1033
+ UPDATE = 0
1034
+ }
1035
+
1036
+ declare enum EOIMIndexEventType {
1037
+ UPDATE = 0
1038
+ }
1039
+
1040
+ declare enum EOIMObjectEventType {
1041
+ UPDATE = 0
786
1042
  }
787
1043
 
788
1044
  type TOIMIndexKey = string | number | bigint;
@@ -810,9 +1066,287 @@ type TOIMIndexPksUpdatePayload<TKey extends TOIMPk, TPk extends TOIMPk> = {
810
1066
  };
811
1067
 
812
1068
  /**
813
- * Payload type for update events that contain keys */
814
- type TOIMUpdatePayload<TKey> = {
1069
+ * Static class containing OIMDB settings and constants.
1070
+ * Provides access to configuration values used throughout the library.
1071
+ */
1072
+ declare class OIMDBSettings {
1073
+ /**
1074
+ * Fixed key used in the manual index to store updated keys set in coalescers.
1075
+ * This constant is exported so users can create their own indexes and pass them to coalescers.
1076
+ */
1077
+ static readonly UPDATED_KEYS_INDEX_KEY: "__updatedKeys__";
1078
+ static readonly FLUSHING_KEYS_INDEX_KEY: "__flushingKeys__";
1079
+ }
1080
+
1081
+ interface IOIMEffectDependency {
1082
+ subscribe(onUpdate: () => void): () => void;
1083
+ }
1084
+
1085
+ type TOIMComputedOptions<TValue> = {
1086
+ compute: () => TValue;
1087
+ deps?: readonly IOIMEffectDependency[];
1088
+ compare?: (a: TValue, b: TValue) => boolean;
1089
+ };
1090
+
1091
+ type TOIMComputedUpdatePayload<TKey extends TOIMPk> = {
815
1092
  keys: readonly TKey[];
816
1093
  };
817
1094
 
818
- export { EOIMCollectionEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMUpdateEventCoalescerEventType, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMDBSettings, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualSetBased, OIMIndexSetBased, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMUpdateEventCoalescer, OIMUpdateEventCoalescerCollection, OIMUpdateEventCoalescerIndex, OIMUpdateEventEmitter, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdateEventEmitterOptions, type TOIMUpdatePayload };
1095
+ /**
1096
+ * Computative runtime that schedules derived computations by levels and runs them
1097
+ * on `queue.flush()` boundary (AFTER_FLUSH).
1098
+ */
1099
+ declare class OIMComputativeRuntime {
1100
+ readonly queue: OIMEventQueue;
1101
+ private isFlushScheduled;
1102
+ private isFlushing;
1103
+ private minLevel;
1104
+ private maxLevel;
1105
+ private readonly dirtyByLevel;
1106
+ private readonly afterFlushTasks;
1107
+ constructor(queue: OIMEventQueue);
1108
+ /**
1109
+ * Schedule a one-shot task to run on the next `queue.flush()` (AFTER_FLUSH),
1110
+ * ordered by `level` ascending.
1111
+ */
1112
+ schedule(task: () => void, level?: number): () => void;
1113
+ /**
1114
+ * Run once at the start of the next runtime flush (i.e. after queue.flush()).
1115
+ * Useful for resubscribing dependencies exactly once per source flush.
1116
+ */
1117
+ scheduleAfterFlush(task: () => void): () => void;
1118
+ private flush;
1119
+ }
1120
+
1121
+ type TOIMComputedKey$2 = 'value';
1122
+ declare class OIMComputed<TValue> {
1123
+ readonly emitter: OIMEventEmitter<{
1124
+ update: TOIMComputedUpdatePayload<TOIMComputedKey$2>;
1125
+ }>;
1126
+ readonly updateEventEmitter: OIMUpdateEventEmitter<TOIMComputedKey$2>;
1127
+ private readonly runtime;
1128
+ private readonly compute;
1129
+ private readonly compare;
1130
+ private readonly deps;
1131
+ private value;
1132
+ private hasValue;
1133
+ private isDirty;
1134
+ private readonly effect;
1135
+ constructor(runtime: OIMComputativeRuntime, opts: TOIMComputedOptions<TValue>);
1136
+ get(): TValue;
1137
+ getIfReady(): TValue | undefined;
1138
+ destroy(): void;
1139
+ private recomputeAndEmitIfChanged;
1140
+ }
1141
+
1142
+ declare enum EOIMComputedEventType {
1143
+ UPDATE = "update"
1144
+ }
1145
+
1146
+ type TOIMComputedKey$1 = 'value';
1147
+ interface IOIMComputedEventSource {
1148
+ emitter: OIMEventEmitter<{
1149
+ [EOIMComputedEventType.UPDATE]: TOIMComputedUpdatePayload<TOIMComputedKey$1>;
1150
+ }>;
1151
+ }
1152
+
1153
+ type TOIMEffectOptions = {
1154
+ deps?: readonly IOIMEffectDependency[];
1155
+ onUpdate?: () => void;
1156
+ run: () => void;
1157
+ };
1158
+
1159
+ declare class OIMEffect {
1160
+ private readonly runtime;
1161
+ private readonly onUpdate?;
1162
+ private readonly run;
1163
+ private readonly deps;
1164
+ private readonly sourceDeps;
1165
+ private readonly computedDeps;
1166
+ private sourceUnsubscribers;
1167
+ private computedUnsubscribers;
1168
+ private dequeueResubscribe?;
1169
+ private isResubscribeEnqueued;
1170
+ private isTemporarilyUnsubscribedForFlush;
1171
+ private isScheduled;
1172
+ private dequeueScheduled?;
1173
+ private readonly runTask;
1174
+ constructor(runtime: OIMComputativeRuntime, opts: TOIMEffectOptions);
1175
+ destroy(): void;
1176
+ private onSourceInvalidate;
1177
+ private onComputedInvalidate;
1178
+ private runOnce;
1179
+ private subscribeToDeps;
1180
+ private unsubscribeFromSourceDeps;
1181
+ private unsubscribeFromAllDeps;
1182
+ private ensureResubscribeAfterFlush;
1183
+ private readonly onAfterFlush;
1184
+ }
1185
+
1186
+ declare class OIMEffectDependencyKeyed<TKey extends TOIMPk> implements IOIMEffectDependency {
1187
+ private readonly subscription;
1188
+ private readonly key;
1189
+ private readonly keys;
1190
+ constructor(subscription: IOIMKeyedSubscription<TKey>, keyOrKeys: TKey | readonly TKey[]);
1191
+ subscribe(onUpdate: () => void): () => void;
1192
+ }
1193
+
1194
+ declare class OIMEffectDependencyKeyedObject<TKey extends string, TValue> implements IOIMEffectDependency {
1195
+ private readonly dep;
1196
+ constructor(object: OIMReactiveObject<TKey, TValue>, key: TKey);
1197
+ constructor(object: OIMReactiveObject<TKey, TValue>, keys: readonly TKey[]);
1198
+ subscribe(onUpdate: () => void): () => void;
1199
+ }
1200
+
1201
+ declare class OIMEffectDependencyKeyedCollection<TEntity extends object, TPk extends TOIMPk> implements IOIMEffectDependency {
1202
+ private readonly dep;
1203
+ constructor(collection: OIMReactiveCollection<TEntity, TPk>, pk: TPk);
1204
+ constructor(collection: OIMReactiveCollection<TEntity, TPk>, pks: readonly TPk[]);
1205
+ subscribe(onUpdate: () => void): () => void;
1206
+ }
1207
+
1208
+ declare class OIMEffectDependencyKeyedIndex<TKey extends TOIMPk> implements IOIMEffectDependency {
1209
+ private readonly dep;
1210
+ constructor(index: IOIMKeyedSubscription<TKey>, key: TKey);
1211
+ constructor(index: IOIMKeyedSubscription<TKey>, keys: readonly TKey[]);
1212
+ subscribe(onUpdate: () => void): () => void;
1213
+ }
1214
+
1215
+ type TOIMComputedKey = 'value';
1216
+ type TOIMComputedLike = {
1217
+ emitter: OIMEventEmitter<{
1218
+ update: TOIMComputedUpdatePayload<TOIMComputedKey>;
1219
+ }>;
1220
+ updateEventEmitter: OIMUpdateEventEmitter<TOIMComputedKey>;
1221
+ };
1222
+ /**
1223
+ * Effect dependency on a computed.
1224
+ */
1225
+ declare class OIMEffectDependencyComputed implements IOIMEffectDependency {
1226
+ private readonly computed;
1227
+ constructor(computed: TOIMComputedLike);
1228
+ subscribe(onUpdate: () => void): () => void;
1229
+ }
1230
+
1231
+ interface IOIMSelectorComputedDependency {
1232
+ subscribe(onUpdate: () => void): () => void;
1233
+ }
1234
+
1235
+ interface IOIMSelectorSourceDependency {
1236
+ subscribe(onUpdate: () => void): () => void;
1237
+ }
1238
+
1239
+ declare abstract class OIMSelector<TValue> {
1240
+ protected readonly runtime: OIMComputativeRuntime;
1241
+ protected readonly sourceDeps: readonly IOIMSelectorSourceDependency[];
1242
+ protected readonly computedDeps: readonly IOIMSelectorComputedDependency[];
1243
+ private readonly listeners;
1244
+ private sourceUnsubscribers;
1245
+ private computedUnsubscribers;
1246
+ private dequeueResubscribe?;
1247
+ private isResubscribeEnqueued;
1248
+ private isTemporarilyUnsubscribedForFlush;
1249
+ private isDeliveryEnqueued;
1250
+ private dequeueDelivery?;
1251
+ private hasLastValue;
1252
+ private lastValue;
1253
+ protected get queue(): OIMEventQueue;
1254
+ protected constructor(runtime: OIMComputativeRuntime, sourceDeps: readonly IOIMSelectorSourceDependency[], computedDeps?: readonly IOIMSelectorComputedDependency[]);
1255
+ abstract getValue(): TValue;
1256
+ /**
1257
+ * Start watching this selector. The callback is called immediately with the current value,
1258
+ * then coalesced and delivered on `queue.flush()` when the selector invalidates.
1259
+ */
1260
+ watch(onValue: (value: TValue) => void): () => void;
1261
+ protected areEqual(prev: TValue, next: TValue): boolean;
1262
+ private readonly onSourceInvalidate;
1263
+ private readonly onComputedInvalidate;
1264
+ private readonly deliver;
1265
+ private setLastValue;
1266
+ private subscribeToDeps;
1267
+ private unsubscribeFromSourceDeps;
1268
+ private unsubscribeFromAllDeps;
1269
+ private ensureResubscribeAfterFlush;
1270
+ private readonly onAfterFlush;
1271
+ }
1272
+
1273
+ declare class OIMCollectionByPkSelector<TEntity extends object, TPk extends TOIMPk> extends OIMSelector<TEntity | undefined> {
1274
+ private readonly collection;
1275
+ private readonly pk;
1276
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, pk: TPk);
1277
+ getValue(): TEntity | undefined;
1278
+ }
1279
+
1280
+ declare class OIMCollectionByPksSelector<TEntity extends object, TPk extends TOIMPk> extends OIMSelector<readonly (TEntity | undefined)[]> {
1281
+ private readonly collection;
1282
+ private readonly pks;
1283
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, pks: readonly TPk[]);
1284
+ getValue(): readonly (TEntity | undefined)[];
1285
+ protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
1286
+ }
1287
+
1288
+ declare class OIMObjectValueByKeySelector<TKey extends string, TValue> extends OIMSelector<TValue | undefined> {
1289
+ private readonly obj;
1290
+ private readonly key;
1291
+ constructor(runtime: OIMComputativeRuntime, obj: OIMReactiveObject<TKey, TValue>, key: TKey);
1292
+ getValue(): TValue | undefined;
1293
+ }
1294
+
1295
+ declare class OIMObjectValuesByKeysSelector<TKey extends string, TValue> extends OIMSelector<readonly (TValue | undefined)[]> {
1296
+ private readonly obj;
1297
+ private readonly keys;
1298
+ constructor(runtime: OIMComputativeRuntime, obj: OIMReactiveObject<TKey, TValue>, keys: readonly TKey[]);
1299
+ getValue(): readonly (TValue | undefined)[];
1300
+ protected areEqual(prev: readonly (TValue | undefined)[], next: readonly (TValue | undefined)[]): boolean;
1301
+ }
1302
+
1303
+ declare class OIMIndexPksByKeySetBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> extends OIMSelector<Set<TPk>> {
1304
+ private readonly reactiveIndex;
1305
+ private readonly key;
1306
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexSetBased<TKey, TPk, TIndex>, key: TKey);
1307
+ getValue(): Set<TPk>;
1308
+ }
1309
+
1310
+ declare class OIMIndexPksByKeyArrayBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> extends OIMSelector<readonly TPk[]> {
1311
+ private readonly reactiveIndex;
1312
+ private readonly key;
1313
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexArrayBased<TKey, TPk, TIndex>, key: TKey);
1314
+ getValue(): readonly TPk[];
1315
+ protected areEqual(prev: readonly TPk[], next: readonly TPk[]): boolean;
1316
+ }
1317
+
1318
+ declare class OIMIndexPksByKeysSetBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> extends OIMSelector<readonly TPk[]> {
1319
+ private readonly reactiveIndex;
1320
+ private readonly keys;
1321
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexSetBased<TKey, TPk, TIndex>, keys: readonly TKey[]);
1322
+ getValue(): readonly TPk[];
1323
+ protected areEqual(prev: readonly TPk[], next: readonly TPk[]): boolean;
1324
+ }
1325
+
1326
+ declare class OIMIndexPksByKeysArrayBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> extends OIMSelector<readonly TPk[]> {
1327
+ private readonly reactiveIndex;
1328
+ private readonly keys;
1329
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexArrayBased<TKey, TPk, TIndex>, keys: readonly TKey[]);
1330
+ getValue(): readonly TPk[];
1331
+ protected areEqual(prev: readonly TPk[], next: readonly TPk[]): boolean;
1332
+ }
1333
+
1334
+ declare class OIMEntitiesByIndexKeySetBasedSelector<TEntity extends object, TPk extends TOIMPk, TKey extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> extends OIMSelector<readonly (TEntity | undefined)[]> {
1335
+ private readonly collection;
1336
+ private readonly reactiveIndex;
1337
+ private readonly key;
1338
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, reactiveIndex: OIMReactiveIndexSetBased<TKey, TPk, TIndex>, key: TKey);
1339
+ getValue(): readonly (TEntity | undefined)[];
1340
+ protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
1341
+ }
1342
+
1343
+ declare class OIMEntitiesByIndexKeyArrayBasedSelector<TEntity extends object, TPk extends TOIMPk, TKey extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> extends OIMSelector<readonly (TEntity | undefined)[]> {
1344
+ private readonly collection;
1345
+ private readonly reactiveIndex;
1346
+ private readonly key;
1347
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, reactiveIndex: OIMReactiveIndexArrayBased<TKey, TPk, TIndex>, key: TKey);
1348
+ getValue(): readonly (TEntity | undefined)[];
1349
+ protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
1350
+ }
1351
+
1352
+ export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFieldsWrapper, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputativeRuntime, OIMComputed, OIMDBSettings, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListIndexCommandStreamWrapper, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMEffectOptions, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload };