@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.
- package/dist/accessors.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +283 -260
- package/dist/index.mjs.map +1 -1
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/state.d.ts +18 -23
- package/dist/state.d.ts.map +1 -1
- package/dist/sync.d.ts +2 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/synchronized_tree.d.ts +5 -3
- package/dist/synchronized_tree.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accessors.ts +1 -1
- package/src/snapshot.test.ts +2 -2
- package/src/snapshot.ts +2 -0
- package/src/state.test.ts +10 -10
- package/src/state.ts +74 -45
- package/src/sync.test.ts +2 -2
- package/src/sync.ts +18 -19
- package/src/synchronized_tree.ts +16 -7
package/src/synchronized_tree.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { PollingComputableHooks } from '@milaboratories/computable';
|
|
2
2
|
import { PlTreeEntry } from './accessors';
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
-
|
|
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:
|
|
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 {
|
|
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(),
|