@milaboratories/pl-tree 1.4.2 → 1.4.4

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.
@@ -1,7 +1,12 @@
1
1
  import { PollingComputableHooks } from '@milaboratories/computable';
2
2
  import { PlTreeEntry } from './accessors';
3
- import { isTimeoutOrCancelError, PlClient, ResourceId } from '@milaboratories/pl-client';
4
- import { FinalPredicate, PlTreeState, TreeStateUpdateError } from './state';
3
+ import {
4
+ FinalResourceDataPredicate,
5
+ isTimeoutOrCancelError,
6
+ PlClient,
7
+ ResourceId
8
+ } from '@milaboratories/pl-client';
9
+ import { PlTreeState, TreeStateUpdateError } from './state';
5
10
  import {
6
11
  constructTreeLoadingRequest,
7
12
  initialTreeLoadingStat,
@@ -15,7 +20,11 @@ import { MiLogger } from '@milaboratories/ts-helpers';
15
20
  type StatLoggingMode = 'cumulative' | 'per-request';
16
21
 
17
22
  export type SynchronizedTreeOps = {
18
- finalPredicate?: FinalPredicate;
23
+ /** Override final predicate from the PlClient */
24
+ finalPredicateOverride?: FinalResourceDataPredicate;
25
+
26
+ /** Pruning function to limit set of fields through which tree will
27
+ * traverse during state synchronization */
19
28
  pruning?: PruningFunction;
20
29
 
21
30
  /** Interval after last sync to sleep before the next one */
@@ -33,7 +42,7 @@ type ScheduledRefresh = {
33
42
  };
34
43
 
35
44
  export class SynchronizedTreeState {
36
- private readonly finalPredicate: FinalPredicate | undefined;
45
+ private readonly finalPredicate: FinalResourceDataPredicate;
37
46
  private state: PlTreeState;
38
47
  private readonly pollingInterval: number;
39
48
  private readonly pruning?: PruningFunction;
@@ -47,12 +56,12 @@ export class SynchronizedTreeState {
47
56
  ops: SynchronizedTreeOps,
48
57
  private readonly logger?: MiLogger
49
58
  ) {
50
- const { finalPredicate, pruning, pollingInterval, stopPollingDelay, logStat } = ops;
59
+ const { finalPredicateOverride, pruning, pollingInterval, stopPollingDelay, logStat } = ops;
51
60
  this.pruning = pruning;
52
61
  this.pollingInterval = pollingInterval;
53
- this.finalPredicate = finalPredicate;
62
+ this.finalPredicate = finalPredicateOverride ?? pl.finalPredicate;
54
63
  this.logStat = logStat;
55
- this.state = new PlTreeState(root, finalPredicate);
64
+ this.state = new PlTreeState(root, this.finalPredicate);
56
65
  this.hooks = new PollingComputableHooks(
57
66
  () => this.startUpdating(),
58
67
  () => this.stopUpdating(),