@oimdb/core 1.2.1 → 1.2.2

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.cjs CHANGED
@@ -765,6 +765,10 @@ var OIMCollection = class {
765
765
  getManyByPks(pks) {
766
766
  return this.store.getManyByPks(pks);
767
767
  }
768
+ upsertOneByPk(pk, entity) {
769
+ this.upsertOneWithoutNotificationsByPk(pk, entity);
770
+ this.emitter.emit(0 /* UPDATE */, { pks: [pk] });
771
+ }
768
772
  upsertOne(entity) {
769
773
  const pk = this.upsertOneWithoutNotifications(entity);
770
774
  this.emitter.emit(0 /* UPDATE */, { pks: [pk] });
@@ -808,6 +812,15 @@ var OIMCollection = class {
808
812
  }
809
813
  upsertOneWithoutNotifications(entity) {
810
814
  const pk = this.selectPk(entity);
815
+ this.upsertOneWithoutNotificationsByPk(pk, entity);
816
+ return pk;
817
+ }
818
+ upsertOneWithoutNotificationsByPk(pk, entity) {
819
+ if (!pk) {
820
+ throw new Error(
821
+ `[OIMCollection]: PK is required to upsert an entity ${JSON.stringify(entity)}`
822
+ );
823
+ }
811
824
  const existingEntity = this.store.getOneByPk(pk);
812
825
  if (existingEntity) {
813
826
  this.store.setOneByPk(
@@ -817,7 +830,6 @@ var OIMCollection = class {
817
830
  } else {
818
831
  this.store.setOneByPk(pk, entity);
819
832
  }
820
- return pk;
821
833
  }
822
834
  };
823
835
 
package/dist/index.d.cts CHANGED
@@ -382,8 +382,9 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
382
382
  constructor(opts?: TOIMCollectionOptions<TEntity, TPk>);
383
383
  getOneByPk(pk: TPk): TEntity | undefined;
384
384
  getManyByPks(pks: readonly TPk[]): TEntity[];
385
- upsertOne(entity: TEntity): void;
386
- upsertMany(entities: TEntity[]): void;
385
+ upsertOneByPk(pk: TPk, entity: Partial<TEntity>): void;
386
+ upsertOne(entity: TEntity | Partial<TEntity>): void;
387
+ upsertMany(entities: (TEntity | Partial<TEntity>)[]): void;
387
388
  removeOne(entity: TEntity): void;
388
389
  removeMany(entities: TEntity[]): void;
389
390
  removeOneByPk(pk: TPk): void;
@@ -392,7 +393,8 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
392
393
  countAll(): number;
393
394
  getAll(): TEntity[];
394
395
  getAllPks(): TPk[];
395
- protected upsertOneWithoutNotifications(entity: TEntity): TPk;
396
+ protected upsertOneWithoutNotifications(entity: TEntity | Partial<TEntity>): TPk;
397
+ protected upsertOneWithoutNotificationsByPk(pk: TPk, entity: Partial<TEntity> | TEntity): void;
396
398
  }
397
399
 
398
400
  declare enum EOIMCollectionEventType {
package/dist/index.d.ts CHANGED
@@ -382,8 +382,9 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
382
382
  constructor(opts?: TOIMCollectionOptions<TEntity, TPk>);
383
383
  getOneByPk(pk: TPk): TEntity | undefined;
384
384
  getManyByPks(pks: readonly TPk[]): TEntity[];
385
- upsertOne(entity: TEntity): void;
386
- upsertMany(entities: TEntity[]): void;
385
+ upsertOneByPk(pk: TPk, entity: Partial<TEntity>): void;
386
+ upsertOne(entity: TEntity | Partial<TEntity>): void;
387
+ upsertMany(entities: (TEntity | Partial<TEntity>)[]): void;
387
388
  removeOne(entity: TEntity): void;
388
389
  removeMany(entities: TEntity[]): void;
389
390
  removeOneByPk(pk: TPk): void;
@@ -392,7 +393,8 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
392
393
  countAll(): number;
393
394
  getAll(): TEntity[];
394
395
  getAllPks(): TPk[];
395
- protected upsertOneWithoutNotifications(entity: TEntity): TPk;
396
+ protected upsertOneWithoutNotifications(entity: TEntity | Partial<TEntity>): TPk;
397
+ protected upsertOneWithoutNotificationsByPk(pk: TPk, entity: Partial<TEntity> | TEntity): void;
396
398
  }
397
399
 
398
400
  declare enum EOIMCollectionEventType {
package/dist/index.js CHANGED
@@ -708,6 +708,10 @@ var OIMCollection = class {
708
708
  getManyByPks(pks) {
709
709
  return this.store.getManyByPks(pks);
710
710
  }
711
+ upsertOneByPk(pk, entity) {
712
+ this.upsertOneWithoutNotificationsByPk(pk, entity);
713
+ this.emitter.emit(0 /* UPDATE */, { pks: [pk] });
714
+ }
711
715
  upsertOne(entity) {
712
716
  const pk = this.upsertOneWithoutNotifications(entity);
713
717
  this.emitter.emit(0 /* UPDATE */, { pks: [pk] });
@@ -751,6 +755,15 @@ var OIMCollection = class {
751
755
  }
752
756
  upsertOneWithoutNotifications(entity) {
753
757
  const pk = this.selectPk(entity);
758
+ this.upsertOneWithoutNotificationsByPk(pk, entity);
759
+ return pk;
760
+ }
761
+ upsertOneWithoutNotificationsByPk(pk, entity) {
762
+ if (!pk) {
763
+ throw new Error(
764
+ `[OIMCollection]: PK is required to upsert an entity ${JSON.stringify(entity)}`
765
+ );
766
+ }
754
767
  const existingEntity = this.store.getOneByPk(pk);
755
768
  if (existingEntity) {
756
769
  this.store.setOneByPk(
@@ -760,7 +773,6 @@ var OIMCollection = class {
760
773
  } else {
761
774
  this.store.setOneByPk(pk, entity);
762
775
  }
763
- return pk;
764
776
  }
765
777
  };
766
778
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oimdb/core",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Core in-memory data library with type-safe indices, reactive subscriptions, and event processing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",