@elderbyte/ngx-starter 14.4.0-beta.20 → 14.4.0-beta.21

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.
@@ -2549,6 +2549,24 @@ class Pageable {
2549
2549
  }
2550
2550
  }
2551
2551
 
2552
+ class JsonMapUtil {
2553
+ static toJsonMap(esMap) {
2554
+ const entries = Array.from(esMap.entries());
2555
+ const jsonMap = {};
2556
+ entries.reduce((o, [key, value]) => {
2557
+ o[key] = value;
2558
+ return o;
2559
+ }, jsonMap);
2560
+ return jsonMap;
2561
+ }
2562
+ static toMap(jsonMap, toIdFn = key => key) {
2563
+ const map = new Map();
2564
+ Object.keys(jsonMap)
2565
+ .forEach(k => map.set(toIdFn(k), jsonMap[k]));
2566
+ return map;
2567
+ }
2568
+ }
2569
+
2552
2570
  class EntitySetPatch {
2553
2571
  /***************************************************************************
2554
2572
  * *
@@ -2583,7 +2601,75 @@ class EntitySetPatch {
2583
2601
  }
2584
2602
  /***************************************************************************
2585
2603
  * *
2586
- * Public API *
2604
+ * Query *
2605
+ * *
2606
+ **************************************************************************/
2607
+ getUpsertsById() {
2608
+ return JsonMapUtil.toMap(this.upsertsById);
2609
+ }
2610
+ getUpdatesById() {
2611
+ return JsonMapUtil.toMap(this.updatesById);
2612
+ }
2613
+ getUpsertOnes() {
2614
+ return [...this.upsertOnes];
2615
+ }
2616
+ getUpdateOnes() {
2617
+ return [...this.updateOnes];
2618
+ }
2619
+ /**
2620
+ * Gets all ids which should be deleted.
2621
+ * Also consider isDeleteOther, which means
2622
+ * everything gets deleted.
2623
+ */
2624
+ collectDeletions() {
2625
+ return [
2626
+ ...Array.from(this.getUpsertsById().entries())
2627
+ .filter(([id, update]) => !update)
2628
+ .map(([id, update]) => id),
2629
+ ...Array.from(this.getUpdatesById().entries())
2630
+ .filter(([id, update]) => !update)
2631
+ .map(([id, update]) => id),
2632
+ ];
2633
+ }
2634
+ /**
2635
+ * Delete all entities which are not
2636
+ * explicitly defined in this update.
2637
+ * "Replace with" semantics.
2638
+ */
2639
+ get isDeleteOther() {
2640
+ return this.deleteOther;
2641
+ }
2642
+ /**
2643
+ * Collects all upserts. (Updates are ignored)
2644
+ */
2645
+ collectUpserts() {
2646
+ return [
2647
+ ...Array.from(this.getUpsertsById().entries())
2648
+ .filter(([id, update]) => !!update)
2649
+ .map(([id, update]) => update),
2650
+ ...this.upsertOnes
2651
+ ];
2652
+ }
2653
+ /**
2654
+ * Collects all updates. (Upserts are ignored)
2655
+ */
2656
+ collectUpdates() {
2657
+ return [
2658
+ ...Array.from(this.getUpdatesById().entries())
2659
+ .filter(([id, update]) => !!update)
2660
+ .map(([id, update]) => update),
2661
+ ...this.updateOnes
2662
+ ];
2663
+ }
2664
+ collectUpdatesAndUpserts() {
2665
+ return [
2666
+ ...this.collectUpserts(),
2667
+ ...this.collectUpdates()
2668
+ ];
2669
+ }
2670
+ /***************************************************************************
2671
+ * *
2672
+ * Builder API *
2587
2673
  * *
2588
2674
  **************************************************************************/
2589
2675
  update(updateOne) {
@@ -2631,11 +2717,15 @@ class EntitySetPatch {
2631
2717
  return this;
2632
2718
  }
2633
2719
  deleteAll() {
2720
+ this.clear();
2721
+ this.deleteAllOther();
2722
+ return this;
2723
+ }
2724
+ clear() {
2634
2725
  this.upsertOnes = [];
2635
2726
  this.upsertsById = {};
2636
2727
  this.updateOnes = [];
2637
2728
  this.updatesById = {};
2638
- this.deleteAllOther();
2639
2729
  return this;
2640
2730
  }
2641
2731
  }
@@ -7984,24 +8074,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImpor
7984
8074
  }]
7985
8075
  }], ctorParameters: function () { return [{ type: i1$3.Router }, { type: i1$3.ActivatedRoute }]; } });
7986
8076
 
7987
- class JsonMapUtil {
7988
- static toJsonMap(esMap) {
7989
- const entries = Array.from(esMap.entries());
7990
- const jsonMap = {};
7991
- entries.reduce((o, [key, value]) => {
7992
- o[key] = value;
7993
- return o;
7994
- }, jsonMap);
7995
- return jsonMap;
7996
- }
7997
- static toMap(jsonMap) {
7998
- const map = new Map();
7999
- Object.keys(jsonMap)
8000
- .forEach(k => map.set(k, jsonMap[k]));
8001
- return map;
8002
- }
8003
- }
8004
-
8005
8077
  class Sets {
8006
8078
  /**
8007
8079
  * Compares the content of two sets for equality in O(n).