@milaboratories/pl-tree 1.5.2 → 1.5.3

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.mjs CHANGED
@@ -1,28 +1,33 @@
1
1
  var W = Object.defineProperty;
2
- var M = (o, e, t) => e in o ? W(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var d = (o, e, t) => M(o, typeof e != "symbol" ? e + "" : e, t);
2
+ var M = (n, e, t) => e in n ? W(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var d = (n, e, t) => M(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { resourceIdToString as R, resourceTypesEqual as A, resourceTypeToString as U, isNotNullResourceId as g, NullResourceId as T, isNullResourceId as b, stringifyWithResourceId as D, isTimeoutOrCancelError as J } from "@milaboratories/pl-client";
5
5
  import { ChangeSource as m, PollingComputableHooks as q } from "@milaboratories/computable";
6
6
  import { parsePlError as V } from "@milaboratories/pl-errors";
7
7
  import { notEmpty as p, msToHumanReadable as z } from "@milaboratories/ts-helpers";
8
8
  import H from "denque";
9
9
  import * as j from "node:timers/promises";
10
- function ae(o, e) {
11
- if (o !== void 0)
12
- return P(o, e);
10
+ function ae(n, e) {
11
+ if (n !== void 0)
12
+ return P(n, e);
13
13
  }
14
- function P(o, e) {
14
+ function P(n, e) {
15
15
  const t = {};
16
- return o.value !== void 0 && (t.value = e(o.value)), o.error !== void 0 && (t.error = e(o.error)), t;
16
+ return n.value !== void 0 && (t.value = e(n.value)), n.error !== void 0 && (t.error = e(n.error)), t;
17
17
  }
18
- function ne(o) {
19
- return typeof o == "object" && o !== null && o.__pl_tree_type_marker__ === "PlTreeEntry";
18
+ class ne extends Error {
19
+ constructor(e) {
20
+ super(e);
21
+ }
20
22
  }
21
- function oe(o) {
22
- return typeof o == "object" && o !== null && o.__pl_tree_type_marker__ === "PlTreeEntryAccessor";
23
+ function oe(n) {
24
+ return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeEntry";
23
25
  }
24
- function ue(o) {
25
- return typeof o == "object" && o !== null && o.__pl_tree_type_marker__ === "PlTreeNodeAccessor";
26
+ function ue(n) {
27
+ return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeEntryAccessor";
28
+ }
29
+ function de(n) {
30
+ return typeof n == "object" && n !== null && n.__pl_tree_type_marker__ === "PlTreeNodeAccessor";
26
31
  }
27
32
  class C {
28
33
  constructor(e, t) {
@@ -42,24 +47,24 @@ class C {
42
47
  return `[ENTRY:${R(this.rid)}]`;
43
48
  }
44
49
  }
45
- function N(o, e, t, r, s) {
46
- const n = new Y(
47
- o,
50
+ function N(n, e, t, r, s) {
51
+ const o = new Y(
52
+ n,
48
53
  e,
49
54
  e.get(t.ctx.watcher, r),
50
55
  t
51
56
  );
52
57
  if (!s.ignoreError) {
53
- const a = n.getError();
58
+ const a = o.getError();
54
59
  if (a !== void 0)
55
- throw V(p(a.getDataAsString()), n.id, n.resourceType);
60
+ throw V(p(a.getDataAsString()), o.id, o.resourceType);
56
61
  }
57
- if (s.assertResourceType !== void 0 && (Array.isArray(s.assertResourceType) ? s.assertResourceType.findIndex((a) => A(a, n.resourceType)) === -1 : !A(s.assertResourceType, n.resourceType)))
62
+ if (s.assertResourceType !== void 0 && (Array.isArray(s.assertResourceType) ? s.assertResourceType.findIndex((a) => A(a, o.resourceType)) === -1 : !A(s.assertResourceType, o.resourceType)))
58
63
  throw new Error(
59
64
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
60
- `wrong resource type ${U(n.resourceType)} but expected ${s.assertResourceType}`
65
+ `wrong resource type ${U(o.resourceType)} but expected ${s.assertResourceType}`
61
66
  );
62
- return n;
67
+ return o;
63
68
  }
64
69
  class E {
65
70
  constructor(e, t, r, s) {
@@ -70,8 +75,8 @@ class E {
70
75
  return this.instanceData.guard(), this.accessorData.hooks !== void 0 && this.instanceData.ctx.attacheHooks(this.accessorData.hooks), N(this.accessorData, this.tree, this.instanceData, this.rid, e);
71
76
  }
72
77
  }
73
- function de(o, e) {
74
- return o instanceof C ? e.accessor(o).node().resourceInfo : o;
78
+ function ce(n, e) {
79
+ return n instanceof C ? e.accessor(n).node().resourceInfo : n;
75
80
  }
76
81
  class Y {
77
82
  constructor(e, t, r, s) {
@@ -112,13 +117,13 @@ class Y {
112
117
  traverseOrErrorWithCommon(e, ...t) {
113
118
  let r = this;
114
119
  for (const s of t) {
115
- const n = typeof s == "string" ? {
120
+ const o = typeof s == "string" ? {
116
121
  ...e,
117
122
  field: s
118
123
  } : { ...e, ...s }, a = r.getField(s);
119
- if (a === void 0 || n.pureFieldErrorToUndefined && a.value === void 0 && a.error !== void 0)
124
+ if (a === void 0 || o.pureFieldErrorToUndefined && a.value === void 0 && a.error !== void 0)
120
125
  return;
121
- if ((!n.ignoreError || a.value === void 0) && a.error !== void 0)
126
+ if ((!o.ignoreError || a.value === void 0) && a.error !== void 0)
122
127
  return {
123
128
  ok: !1,
124
129
  // FIXME: in next tickets we'll allow Errors to be thrown.
@@ -126,16 +131,16 @@ class Y {
126
131
  p(a.error.getDataAsString()),
127
132
  r.id,
128
133
  r.resourceType,
129
- n.field
134
+ o.field
130
135
  )
131
136
  };
132
137
  if (a.value === void 0) {
133
- if (n.errorIfFieldNotSet)
138
+ if (o.errorIfFieldNotSet)
134
139
  return {
135
140
  ok: !1,
136
- error: `field have no assigned value ${n.field} of ${R(r.id)}`
141
+ error: new Error(`field have no assigned value ${o.field} of ${R(r.id)}`)
137
142
  };
138
- this.onUnstableLambda("unpopulated_field:" + n.field);
143
+ this.onUnstableLambda("unpopulated_field:" + o.field);
139
144
  return;
140
145
  }
141
146
  r = a.value;
@@ -230,9 +235,9 @@ class S extends Error {
230
235
  }
231
236
  }
232
237
  class $ {
233
- constructor(e, t, r, s, n, a, i) {
238
+ constructor(e, t, r, s, o, a, i) {
234
239
  d(this, "change", new m());
235
- this.name = e, this.type = t, this.value = r, this.error = s, this.status = n, this.valueIsFinal = a, this.resourceVersion = i;
240
+ this.name = e, this.type = t, this.value = r, this.error = s, this.status = o, this.valueIsFinal = a, this.resourceVersion = i;
236
241
  }
237
242
  get state() {
238
243
  return {
@@ -301,8 +306,8 @@ class G {
301
306
  getField(e, t, r = () => {
302
307
  }) {
303
308
  var a, i, f;
304
- const s = typeof t == "string" ? { field: t } : t, n = this.fieldsMap.get(s.field);
305
- if (n === void 0) {
309
+ const s = typeof t == "string" ? { field: t } : t, o = this.fieldsMap.get(s.field);
310
+ if (o === void 0) {
306
311
  if (s.errorIfFieldNotFound || s.errorIfFieldNotSet)
307
312
  throw new Error(
308
313
  `Field "${s.field}" not found in resource ${R(this.id)}`
@@ -322,12 +327,12 @@ class G {
322
327
  (f = this.dynamicFieldListChanged) == null || f.attachWatcher(e), !this._finalState && !s.stableIfNotFound && r("field_not_found:" + s.field);
323
328
  return;
324
329
  } else {
325
- if (s.assertFieldType !== void 0 && n.type !== s.assertFieldType)
330
+ if (s.assertFieldType !== void 0 && o.type !== s.assertFieldType)
326
331
  throw new Error(
327
- `Unexpected field type: expected ${s.assertFieldType} but got ${n.type} for the field name ${s.field}`
332
+ `Unexpected field type: expected ${s.assertFieldType} but got ${o.type} for the field name ${s.field}`
328
333
  );
329
334
  const l = {};
330
- return g(n.value) && (l.value = n.value), g(n.error) && (l.error = n.error), l.value === void 0 && l.error === void 0 && r("field_not_resolved:" + s.field), n.change.attachWatcher(e), l;
335
+ return g(o.value) && (l.value = o.value), g(o.error) && (l.error = o.error), l.value === void 0 && l.error === void 0 && r("field_not_resolved:" + s.field), o.change.attachWatcher(e), l;
331
336
  }
332
337
  }
333
338
  getInputsLocked(e) {
@@ -360,22 +365,22 @@ class G {
360
365
  listInputFields(e) {
361
366
  var r;
362
367
  const t = [];
363
- return this.fieldsMap.forEach((s, n) => {
364
- (s.type === "Input" || s.type === "Service") && t.push(n);
368
+ return this.fieldsMap.forEach((s, o) => {
369
+ (s.type === "Input" || s.type === "Service") && t.push(o);
365
370
  }), this.inputsLocked || (r = this.inputAndServiceFieldListChanged) == null || r.attachWatcher(e), t;
366
371
  }
367
372
  listOutputFields(e) {
368
373
  var r;
369
374
  const t = [];
370
- return this.fieldsMap.forEach((s, n) => {
371
- s.type === "Output" && t.push(n);
375
+ return this.fieldsMap.forEach((s, o) => {
376
+ s.type === "Output" && t.push(o);
372
377
  }), this.outputsLocked || (r = this.outputFieldListChanged) == null || r.attachWatcher(e), t;
373
378
  }
374
379
  listDynamicFields(e) {
375
380
  var r;
376
381
  const t = [];
377
- return this.fieldsMap.forEach((s, n) => {
378
- s.type !== "Input" && s.type !== "Output" && t.push(n);
382
+ return this.fieldsMap.forEach((s, o) => {
383
+ s.type !== "Input" && s.type !== "Output" && t.push(o);
379
384
  }), (r = this.dynamicFieldListChanged) == null || r.attachWatcher(e), t;
380
385
  }
381
386
  getKeyValue(e, t) {
@@ -426,8 +431,8 @@ class G {
426
431
  }
427
432
  /** Used for invalidation */
428
433
  markAllChanged() {
429
- var e, t, r, s, n, a, i;
430
- this.fieldsMap.forEach((f) => f.change.markChanged()), (e = this.finalChanged) == null || e.markChanged(), (t = this.resourceStateChange) == null || t.markChanged(), (r = this.lockedChange) == null || r.markChanged(), (s = this.inputAndServiceFieldListChanged) == null || s.markChanged(), (n = this.outputFieldListChanged) == null || n.markChanged(), (a = this.dynamicFieldListChanged) == null || a.markChanged(), (i = this.kvChanged) == null || i.markChanged(), this.resourceRemoved.markChanged();
434
+ var e, t, r, s, o, a, i;
435
+ this.fieldsMap.forEach((f) => f.change.markChanged()), (e = this.finalChanged) == null || e.markChanged(), (t = this.resourceStateChange) == null || t.markChanged(), (r = this.lockedChange) == null || r.markChanged(), (s = this.inputAndServiceFieldListChanged) == null || s.markChanged(), (o = this.outputFieldListChanged) == null || o.markChanged(), (a = this.dynamicFieldListChanged) == null || a.markChanged(), (i = this.kvChanged) == null || i.markChanged(), this.resourceRemoved.markChanged();
431
436
  }
432
437
  }
433
438
  class O {
@@ -535,10 +540,10 @@ class O {
535
540
  throw this.invalidateTree(), new S(`orphan resource ${a}`);
536
541
  i.refCount++;
537
542
  }
538
- let n = s;
539
- for (; n.length > 0; ) {
543
+ let o = s;
544
+ for (; o.length > 0; ) {
540
545
  const a = [];
541
- for (const i of n) {
546
+ for (const i of o) {
542
547
  const f = this.resources.get(i);
543
548
  if (!f)
544
549
  throw this.invalidateTree(), new S(`orphan resource ${i}`);
@@ -546,7 +551,7 @@ class O {
546
551
  g(l.value) && a.push(l.value), g(l.error) && a.push(l.error), l.change.markChanged();
547
552
  }), g(f.error) && a.push(f.error), f.resourceRemoved.markChanged(), this.resources.delete(i));
548
553
  }
549
- n = a;
554
+ o = a;
550
555
  }
551
556
  if (!t) {
552
557
  for (const a of e)
@@ -570,11 +575,11 @@ class O {
570
575
  return Array.from(this.resources.values()).map((e) => e.extendedState);
571
576
  }
572
577
  }
573
- function Q(o, e) {
578
+ function Q(n, e) {
574
579
  const t = [], r = /* @__PURE__ */ new Set();
575
- return o.forEachResource((s) => {
580
+ return n.forEachResource((s) => {
576
581
  s.finalState ? r.add(s.id) : t.push(s.id);
577
- }), t.length === 0 && r.size === 0 && t.push(o.root), { seedResources: t, finalResources: r, pruningFunction: e };
582
+ }), t.length === 0 && r.size === 0 && t.push(n.root), { seedResources: t, finalResources: r, pruningFunction: e };
578
583
  }
579
584
  function F() {
580
585
  return {
@@ -590,33 +595,33 @@ function F() {
590
595
  millisSpent: 0
591
596
  };
592
597
  }
593
- function ce(o) {
594
- let e = `Requests: ${o.requests}
598
+ function he(n) {
599
+ let e = `Requests: ${n.requests}
595
600
  `;
596
- return e += `Total time: ${z(o.millisSpent)}
597
- `, e += `Round-trips: ${o.roundTrips}
598
- `, e += `Resources: ${o.retrievedResources}
599
- `, e += `Fields: ${o.retrievedFields}
600
- `, e += `KV: ${o.retrievedKeyValues}
601
- `, e += `Data Bytes: ${o.retrievedResourceDataBytes}
602
- `, e += `KV Bytes: ${o.retrievedKeyValueBytes}
603
- `, e += `Pruned fields: ${o.prunedFields}
604
- `, e += `Final resources skipped: ${o.finalResourcesSkipped}`, e;
601
+ return e += `Total time: ${z(n.millisSpent)}
602
+ `, e += `Round-trips: ${n.roundTrips}
603
+ `, e += `Resources: ${n.retrievedResources}
604
+ `, e += `Fields: ${n.retrievedFields}
605
+ `, e += `KV: ${n.retrievedKeyValues}
606
+ `, e += `Data Bytes: ${n.retrievedResourceDataBytes}
607
+ `, e += `KV Bytes: ${n.retrievedKeyValueBytes}
608
+ `, e += `Pruned fields: ${n.prunedFields}
609
+ `, e += `Final resources skipped: ${n.finalResourcesSkipped}`, e;
605
610
  }
606
- async function X(o, e, t) {
611
+ async function X(n, e, t) {
607
612
  var c;
608
613
  const r = Date.now();
609
614
  t && t.requests++;
610
- const { seedResources: s, finalResources: n, pruningFunction: a } = e, i = new H();
615
+ const { seedResources: s, finalResources: o, pruningFunction: a } = e, i = new H();
611
616
  let f = !0, l = 0;
612
617
  const h = /* @__PURE__ */ new Set(), k = (v) => {
613
618
  if (b(v) || h.has(v)) return;
614
- if (n.has(v)) {
619
+ if (o.has(v)) {
615
620
  t && t.finalResourcesSkipped++;
616
621
  return;
617
622
  }
618
623
  h.add(v);
619
- const y = o.getResourceDataIfExists(v, !0), w = o.listKeyValuesIfResourceExists(v), B = f;
624
+ const y = n.getResourceDataIfExists(v, !0), w = n.listKeyValuesIfResourceExists(v), B = f;
620
625
  f && (f = !1), i.push(
621
626
  (async () => {
622
627
  const [I, _] = await Promise.all([y, w]);
@@ -651,13 +656,13 @@ async function X(o, e, t) {
651
656
  }
652
657
  return t && (t.millisSpent += Date.now() - r, t.roundTrips += l), u;
653
658
  }
654
- function he(o) {
655
- return o;
659
+ function le(n) {
660
+ return n;
656
661
  }
657
- function le(o, e, t) {
662
+ function fe(n, e, t) {
658
663
  var a;
659
- const r = o instanceof C ? p(t).accessor(o).node() : o instanceof E ? o.node() : o, n = { ...r.resourceInfo };
660
- if (e.data !== void 0 && (e.data === "raw" ? n.data = r.getData() : n.data = e.data.parse(r.getDataAsJson())), e.fields !== void 0) {
664
+ const r = n instanceof C ? p(t).accessor(n).node() : n instanceof E ? n.node() : n, o = { ...r.resourceInfo };
665
+ if (e.data !== void 0 && (e.data === "raw" ? o.data = r.getData() : o.data = e.data.parse(r.getDataAsJson())), e.fields !== void 0) {
661
666
  const i = {};
662
667
  for (const [f, l] of Object.entries(e.fields))
663
668
  i[f] = (a = r.traverse({
@@ -665,7 +670,7 @@ function le(o, e, t) {
665
670
  errorIfFieldNotSet: l,
666
671
  stableIfNotFound: !l
667
672
  })) == null ? void 0 : a.id;
668
- n.fields = i;
673
+ o.fields = i;
669
674
  }
670
675
  if (e.kv !== void 0) {
671
676
  const i = {};
@@ -675,13 +680,13 @@ function le(o, e, t) {
675
680
  throw new Error(`Key not found ${f}`);
676
681
  l === "raw" ? i[f] = h : i[f] = l.parse(JSON.parse(Buffer.from(h).toString("utf-8")));
677
682
  }
678
- n.kv = i;
683
+ o.kv = i;
679
684
  }
680
- return n;
685
+ return o;
681
686
  }
682
- function fe(o, e, t) {
683
- if (o instanceof C) {
684
- const r = t.accessor(o).node(), s = r.resourceInfo, n = e.map((a) => {
687
+ function ge(n, e, t) {
688
+ if (n instanceof C) {
689
+ const r = t.accessor(n).node(), s = r.resourceInfo, o = e.map((a) => {
685
690
  var i, f;
686
691
  return [
687
692
  a,
@@ -690,18 +695,18 @@ function fe(o, e, t) {
690
695
  });
691
696
  return {
692
697
  ...s,
693
- fields: new Map(n),
698
+ fields: new Map(o),
694
699
  data: r.getData() ?? new Uint8Array()
695
700
  };
696
701
  }
697
- return o;
702
+ return n;
698
703
  }
699
- function ge(o, e, t) {
700
- if (!(o instanceof C)) return o;
701
- const r = t.accessor(o).node(), s = r.resourceInfo, n = e.map((a) => [a, r.getKeyValue(a)]);
704
+ function pe(n, e, t) {
705
+ if (!(n instanceof C)) return n;
706
+ const r = t.accessor(n).node(), s = r.resourceInfo, o = e.map((a) => [a, r.getKeyValue(a)]);
702
707
  return {
703
708
  ...s,
704
- metadata: Object.fromEntries(n)
709
+ metadata: Object.fromEntries(o)
705
710
  };
706
711
  }
707
712
  class K {
@@ -721,8 +726,8 @@ class K {
721
726
  /** If true this tree state is permanently terminaed. */
722
727
  d(this, "terminated", !1);
723
728
  this.pl = e, this.root = t, this.logger = s;
724
- const { finalPredicateOverride: n, pruning: a, pollingInterval: i, stopPollingDelay: f, logStat: l } = r;
725
- this.pruning = a, this.pollingInterval = i, this.finalPredicate = n ?? e.finalPredicate, this.logStat = l, this.state = new O(t, this.finalPredicate), this.hooks = new q(
729
+ const { finalPredicateOverride: o, pruning: a, pollingInterval: i, stopPollingDelay: f, logStat: l } = r;
730
+ this.pruning = a, this.pollingInterval = i, this.finalPredicate = o ?? e.finalPredicate, this.logStat = l, this.state = new O(t, this.finalPredicate), this.hooks = new q(
726
731
  () => this.startUpdating(),
727
732
  () => this.stopUpdating(),
728
733
  { stopDebounce: f },
@@ -758,7 +763,7 @@ class K {
758
763
  /** Executed from the main loop, and initialization procedure. */
759
764
  async refresh(e, t) {
760
765
  if (this.terminated) throw new Error("tree synchronization is terminated");
761
- const r = Q(this.state, this.pruning), s = await this.pl.withReadTx("ReadingTree", async (n) => await X(n, r, e), t);
766
+ const r = Q(this.state, this.pruning), s = await this.pl.withReadTx("ReadingTree", async (o) => await X(o, r, e), t);
762
767
  this.state.updateFromResourceData(s, !0);
763
768
  }
764
769
  async mainLoop() {
@@ -768,19 +773,19 @@ class K {
768
773
  let s;
769
774
  this.scheduledOnNextState.length > 0 && (s = this.scheduledOnNextState, this.scheduledOnNextState = []);
770
775
  try {
771
- if (this.logStat === "per-request" && (e = F()), await this.refresh(e), e && this.logger && this.logger.info(`Tree stat (success): ${JSON.stringify(e)}`), s !== void 0) for (const n of s) n.resolve();
772
- } catch (n) {
773
- if (e && this.logger && this.logger.info(`Tree stat (error): ${JSON.stringify(e)}`), s !== void 0) for (const a of s) a.reject(n);
774
- if (n instanceof S) {
775
- (t = this.logger) == null || t.error(n), this.state.invalidateTree("stat update error"), this.state = new O(this.root, this.finalPredicate);
776
+ if (this.logStat === "per-request" && (e = F()), await this.refresh(e), e && this.logger && this.logger.info(`Tree stat (success): ${JSON.stringify(e)}`), s !== void 0) for (const o of s) o.resolve();
777
+ } catch (o) {
778
+ if (e && this.logger && this.logger.info(`Tree stat (error): ${JSON.stringify(e)}`), s !== void 0) for (const a of s) a.reject(o);
779
+ if (o instanceof S) {
780
+ (t = this.logger) == null || t.error(o), this.state.invalidateTree("stat update error"), this.state = new O(this.root, this.finalPredicate);
776
781
  continue;
777
- } else (r = this.logger) == null || r.warn(n);
782
+ } else (r = this.logger) == null || r.warn(o);
778
783
  }
779
784
  if (!this.keepRunning || this.terminated) break;
780
785
  try {
781
786
  await j.setTimeout(this.pollingInterval, this.abortController.signal);
782
- } catch (n) {
783
- if (!J(n)) throw new Error("Unexpected error", { cause: n });
787
+ } catch (o) {
788
+ if (!J(o)) throw new Error("Unexpected error", { cause: o });
784
789
  break;
785
790
  }
786
791
  }
@@ -805,10 +810,10 @@ class K {
805
810
  this.currentLoop !== void 0 && await this.currentLoop;
806
811
  }
807
812
  static async init(e, t, r, s) {
808
- const n = new K(e, t, r, s), a = r.logStat ? F() : void 0;
813
+ const o = new K(e, t, r, s), a = r.logStat ? F() : void 0;
809
814
  let i = !1;
810
815
  try {
811
- await n.refresh(a, {
816
+ await o.refresh(a, {
812
817
  timeout: r.initialTreeLoadingTimeout
813
818
  }), i = !0;
814
819
  } finally {
@@ -816,10 +821,10 @@ class K {
816
821
  `Tree stat (initial load, ${i ? "success" : "failure"}): ${JSON.stringify(a)}`
817
822
  );
818
823
  }
819
- return n;
824
+ return o;
820
825
  }
821
826
  }
822
- function pe(o) {
827
+ function ve(n) {
823
828
  var t;
824
829
  const e = {
825
830
  total: {
@@ -832,7 +837,7 @@ function pe(o) {
832
837
  },
833
838
  byResourceType: {}
834
839
  };
835
- for (const r of o) {
840
+ for (const r of n) {
836
841
  const s = `${r.type.name}/${r.type.version}`;
837
842
  e.byResourceType[s] || (e.byResourceType[s] = {
838
843
  count: 0,
@@ -842,23 +847,24 @@ function pe(o) {
842
847
  kvCount: 0,
843
848
  kvBytes: 0
844
849
  });
845
- const n = e.byResourceType[s];
846
- n.count++, e.total.count++;
850
+ const o = e.byResourceType[s];
851
+ o.count++, e.total.count++;
847
852
  for (const a of r.fields)
848
- n.fieldNameBytes += a.name.length, n.fieldsCount++, e.total.fieldNameBytes += a.name.length, e.total.fieldsCount++;
853
+ o.fieldNameBytes += a.name.length, o.fieldsCount++, e.total.fieldNameBytes += a.name.length, e.total.fieldsCount++;
849
854
  if (r.data) {
850
855
  const a = ((t = r.data) == null ? void 0 : t.length) ?? 0;
851
- n.dataBytes += a, e.total.dataBytes += a;
856
+ o.dataBytes += a, e.total.dataBytes += a;
852
857
  }
853
- n.kvCount += r.kv.length, e.total.kvCount += r.kv.length;
858
+ o.kvCount += r.kv.length, e.total.kvCount += r.kv.length;
854
859
  for (const a of r.kv) {
855
860
  const i = a.key.length + a.value.length;
856
- n.kvBytes += i, e.total.kvBytes += i;
861
+ o.kvBytes += i, e.total.kvBytes += i;
857
862
  }
858
863
  }
859
864
  return e;
860
865
  }
861
866
  export {
867
+ ne as PlError,
862
868
  C as PlTreeEntry,
863
869
  E as PlTreeEntryAccessor,
864
870
  Y as PlTreeNodeAccessor,
@@ -867,19 +873,19 @@ export {
867
873
  K as SynchronizedTreeState,
868
874
  S as TreeStateUpdateError,
869
875
  Q as constructTreeLoadingRequest,
870
- ce as formatTreeLoadingStat,
876
+ he as formatTreeLoadingStat,
871
877
  F as initialTreeLoadingStat,
872
- ne as isPlTreeEntry,
873
- oe as isPlTreeEntryAccessor,
874
- ue as isPlTreeNodeAccessor,
878
+ oe as isPlTreeEntry,
879
+ ue as isPlTreeEntryAccessor,
880
+ de as isPlTreeNodeAccessor,
875
881
  X as loadTreeState,
876
- le as makeResourceSnapshot,
882
+ fe as makeResourceSnapshot,
877
883
  P as mapValueAndError,
878
884
  ae as mapValueAndErrorIfDefined,
879
- he as rsSchema,
880
- pe as treeDumpStats,
881
- de as treeEntryToResourceInfo,
882
- fe as treeEntryToResourceWithData,
883
- ge as treeEntryToResourceWithMetadata
885
+ le as rsSchema,
886
+ ve as treeDumpStats,
887
+ ce as treeEntryToResourceInfo,
888
+ ge as treeEntryToResourceWithData,
889
+ pe as treeEntryToResourceWithMetadata
884
890
  };
885
891
  //# sourceMappingURL=index.mjs.map