@platforma-sdk/model 1.45.0 → 1.45.23

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.
Files changed (42) hide show
  1. package/dist/components/PFrameForGraphs.cjs +5 -22
  2. package/dist/components/PFrameForGraphs.cjs.map +1 -1
  3. package/dist/components/PFrameForGraphs.d.ts +0 -2
  4. package/dist/components/PFrameForGraphs.d.ts.map +1 -1
  5. package/dist/components/PFrameForGraphs.js +7 -22
  6. package/dist/components/PFrameForGraphs.js.map +1 -1
  7. package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
  8. package/dist/components/PlAnnotations/filters_ui.d.ts +6 -4
  9. package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
  10. package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
  11. package/dist/components/PlDataTable.cjs +6 -38
  12. package/dist/components/PlDataTable.cjs.map +1 -1
  13. package/dist/components/PlDataTable.d.ts +1 -4
  14. package/dist/components/PlDataTable.d.ts.map +1 -1
  15. package/dist/components/PlDataTable.js +7 -38
  16. package/dist/components/PlDataTable.js.map +1 -1
  17. package/dist/filters/types.d.ts +7 -7
  18. package/dist/filters/types.d.ts.map +1 -1
  19. package/dist/index.cjs +2 -3
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.js +3 -3
  22. package/dist/package.json.cjs +1 -1
  23. package/dist/package.json.js +1 -1
  24. package/dist/render/api.cjs +7 -1
  25. package/dist/render/api.cjs.map +1 -1
  26. package/dist/render/api.d.ts +3 -3
  27. package/dist/render/api.d.ts.map +1 -1
  28. package/dist/render/api.js +7 -1
  29. package/dist/render/api.js.map +1 -1
  30. package/dist/render/util/pcolumn_data.cjs +21 -0
  31. package/dist/render/util/pcolumn_data.cjs.map +1 -1
  32. package/dist/render/util/pcolumn_data.d.ts +4 -1
  33. package/dist/render/util/pcolumn_data.d.ts.map +1 -1
  34. package/dist/render/util/pcolumn_data.js +21 -2
  35. package/dist/render/util/pcolumn_data.js.map +1 -1
  36. package/package.json +7 -7
  37. package/src/components/PFrameForGraphs.ts +5 -23
  38. package/src/components/PlAnnotations/filters_ui.ts +3 -5
  39. package/src/components/PlDataTable.ts +5 -40
  40. package/src/filters/types.ts +7 -7
  41. package/src/render/api.ts +9 -5
  42. package/src/render/util/pcolumn_data.ts +24 -0
@@ -34,10 +34,11 @@ import type {
34
34
  ColumnProvider,
35
35
  PColumnDataUniversal,
36
36
  RenderCtx,
37
+ TreeNodeAccessor,
37
38
  } from '../render';
38
39
  import {
40
+ allPColumnsReady,
39
41
  PColumnCollection,
40
- TreeNodeAccessor,
41
42
  } from '../render';
42
43
  import { isLinkerColumn } from './PFrameForGraphs';
43
44
 
@@ -576,44 +577,6 @@ export function getMatchingLabelColumns(
576
577
  return labelColumns;
577
578
  }
578
579
 
579
- /** Check if all columns are computed */
580
- export function allColumnsComputed(
581
- columns: PColumn<PColumnValues | TreeNodeAccessor | DataInfo<TreeNodeAccessor>>[],
582
- ): boolean {
583
- type Data = typeof columns[number]['data'];
584
- const isValues = (d: Data): d is PColumnValues => Array.isArray(d);
585
- const isAccessor = (d: Data): d is TreeNodeAccessor => d instanceof TreeNodeAccessor;
586
- const isDataInfo = (d: Data): d is DataInfo<TreeNodeAccessor> =>
587
- typeof d === 'object' && 'type' in d;
588
-
589
- return columns
590
- .map((c) => c.data)
591
- .every((d): boolean => {
592
- if (isValues(d)) {
593
- return true;
594
- } else if (isAccessor(d)) {
595
- return d.getIsReadyOrError();
596
- } else if (isDataInfo(d)) {
597
- const type = d.type;
598
- switch (type) {
599
- case 'Json':
600
- return true;
601
- case 'JsonPartitioned':
602
- return Object.values(d.parts).every((p) => p.getIsReadyOrError());
603
- case 'BinaryPartitioned':
604
- return Object.values(d.parts)
605
- .every((p) => p.index.getIsReadyOrError() && p.values.getIsReadyOrError());
606
- case 'ParquetPartitioned':
607
- return Object.values(d.parts)
608
- .every((p) => p.getIsReadyOrError());
609
- }
610
- } else {
611
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
612
- throw Error(`unsupported column data type: ${d satisfies never}`);
613
- }
614
- });
615
- }
616
-
617
580
  function createPTableDef(params: {
618
581
  columns: PColumn<PColumnDataUniversal>[];
619
582
  labelColumns: PColumn<PColumnDataUniversal>[];
@@ -745,6 +708,7 @@ export function createPlDataTableV2<A, U>(
745
708
  coreColumnPredicate: ops?.coreColumnPredicate,
746
709
  });
747
710
  const fullHandle = ctx.createPTable(fullDef);
711
+ if (!fullHandle) return undefined;
748
712
 
749
713
  const hiddenColumns = new Set<PObjectId>(((): PObjectId[] => {
750
714
  // Inner join works as a filter - all columns must be present
@@ -779,7 +743,7 @@ export function createPlDataTableV2<A, U>(
779
743
  const visibleLabelColumns = getMatchingLabelColumns(visibleColumns.map(getColumnIdAndSpec), allLabelColumns);
780
744
 
781
745
  // if at least one column is not yet computed, we can't show the table
782
- if (!allColumnsComputed([...visibleColumns, ...visibleLabelColumns])) return undefined;
746
+ if (!allPColumnsReady([...visibleColumns, ...visibleLabelColumns])) return undefined;
783
747
 
784
748
  const visibleDef = createPTableDef({
785
749
  columns: visibleColumns,
@@ -791,6 +755,7 @@ export function createPlDataTableV2<A, U>(
791
755
  coreColumnPredicate,
792
756
  });
793
757
  const visibleHandle = ctx.createPTable(visibleDef);
758
+ if (!visibleHandle) return undefined;
794
759
 
795
760
  return {
796
761
  sourceId: tableStateNormalized.pTableParams.sourceId,
@@ -8,11 +8,11 @@ export type SimplifiedUniversalPColumnEntry = {
8
8
  obj: SimplifiedPColumnSpec;
9
9
  };
10
10
 
11
- export type FilterSpecNode<Leaf, Common = {}> =
12
- | Common & Leaf
13
- | Common & { type: 'not'; filter: Common & Leaf }
14
- | Common & { type: 'or'; filters: FilterSpecNode<Leaf, Common>[] }
15
- | Common & { type: 'and'; filters: FilterSpecNode<Leaf, Common>[] };
11
+ export type FilterSpecNode<Leaf, CommonNode = {}, CommonLeaf = {}> =
12
+ | CommonLeaf & Leaf
13
+ | CommonNode & { type: 'not'; filter: CommonLeaf & Leaf }
14
+ | CommonNode & { type: 'or'; filters: FilterSpecNode<Leaf, CommonNode, CommonLeaf>[] }
15
+ | CommonNode & { type: 'and'; filters: FilterSpecNode<Leaf, CommonNode, CommonLeaf>[] };
16
16
 
17
17
  export type FilterSpecLeaf =
18
18
  | { type: undefined }
@@ -39,8 +39,8 @@ export type FilterSpecLeaf =
39
39
  | { type: 'lessThanColumnOrEqual'; column: SUniversalPColumnId; rhs: SUniversalPColumnId; minDiff?: number }
40
40
  | { type: 'greaterThanColumnOrEqual'; column: SUniversalPColumnId; rhs: SUniversalPColumnId; minDiff?: number };
41
41
 
42
- export type FilterSpec<Leaf extends FilterSpecLeaf = FilterSpecLeaf, Common = {}> =
43
- FilterSpecNode<Leaf, Common>;
42
+ export type FilterSpec<Leaf extends FilterSpecLeaf = FilterSpecLeaf, CommonNode = {}, CommonLeaf = CommonNode> =
43
+ FilterSpecNode<Leaf, CommonNode, CommonLeaf>;
44
44
 
45
45
  export type FilterSpecType = Exclude<FilterSpec, { type: undefined }>['type'];
46
46
 
package/src/render/api.ts CHANGED
@@ -53,6 +53,7 @@ import type { LabelDerivationOps } from './util/label';
53
53
  import { deriveLabels } from './util/label';
54
54
  import type { APColumnSelectorWithSplit } from './util/split_selectors';
55
55
  import { patchInSetFilters } from './util/pframe_upgraders';
56
+ import { allPColumnsReady } from './util/pcolumn_data';
56
57
 
57
58
  export type PColumnDataUniversal = TreeNodeAccessor | DataInfo<TreeNodeAccessor> | PColumnValues;
58
59
 
@@ -618,21 +619,22 @@ export class RenderCtx<Args, UiState> {
618
619
  }
619
620
 
620
621
  // TODO remove all non-PColumn fields
621
- public createPFrame(def: PFrameDef<PColumnDataUniversal>): PFrameHandle {
622
+ public createPFrame(def: PFrameDef<PColumnDataUniversal>): PFrameHandle | undefined {
622
623
  this.verifyInlineAndExplicitColumnsSupport(def);
624
+ if (!allPColumnsReady(def)) return undefined;
623
625
  return this.ctx.createPFrame(
624
626
  def.map((c) => transformPColumnData(c)),
625
627
  );
626
628
  }
627
629
 
628
630
  // TODO remove all non-PColumn fields
629
- public createPTable(def: PTableDef<PColumn<PColumnDataUniversal>>): PTableHandle;
631
+ public createPTable(def: PTableDef<PColumn<PColumnDataUniversal>>): PTableHandle | undefined;
630
632
  public createPTable(def: {
631
633
  columns: PColumn<PColumnDataUniversal>[];
632
634
  filters?: PTableRecordFilter[];
633
635
  /** Table sorting */
634
636
  sorting?: PTableSorting[];
635
- }): PTableHandle;
637
+ }): PTableHandle | undefined;
636
638
  public createPTable(
637
639
  def:
638
640
  | PTableDef<PColumn<PColumnDataUniversal>>
@@ -642,7 +644,7 @@ export class RenderCtx<Args, UiState> {
642
644
  /** Table sorting */
643
645
  sorting?: PTableSorting[];
644
646
  },
645
- ): PTableHandle {
647
+ ): PTableHandle | undefined {
646
648
  let rawDef: PTableDef<PColumn<PColumnDataUniversal>>;
647
649
  if ('columns' in def) {
648
650
  rawDef = this.patchPTableDef({
@@ -657,7 +659,9 @@ export class RenderCtx<Args, UiState> {
657
659
  } else {
658
660
  rawDef = this.patchPTableDef(def);
659
661
  }
660
- this.verifyInlineAndExplicitColumnsSupport(extractAllColumns(rawDef.src));
662
+ const columns = extractAllColumns(rawDef.src);
663
+ this.verifyInlineAndExplicitColumnsSupport(columns);
664
+ if (!allPColumnsReady(columns)) return undefined;
661
665
  return this.ctx.createPTable(
662
666
  mapPTableDef(rawDef, (po) => transformPColumnData(po)),
663
667
  );
@@ -1,17 +1,21 @@
1
1
  import type {
2
2
  DataInfo,
3
3
  PartitionedDataInfoEntries,
4
+ PColumn,
5
+ PColumnValues,
4
6
  } from '@milaboratories/pl-model-common';
5
7
  import {
6
8
  dataInfoToEntries,
7
9
  isDataInfo,
8
10
  isDataInfoEntries,
11
+ visitDataInfo,
9
12
  type BinaryChunk,
10
13
  type DataInfoEntries,
11
14
  type PColumnDataEntry,
12
15
  type PColumnKey,
13
16
  } from '@milaboratories/pl-model-common';
14
17
  import { TreeNodeAccessor } from '../accessor';
18
+ import type { PColumnDataUniversal } from '../api';
15
19
 
16
20
  const PCD_PREFIX = 'PColumnData/';
17
21
 
@@ -507,3 +511,23 @@ DataInfoEntries<TreeNodeAccessor> | undefined {
507
511
 
508
512
  throw new Error(`Unexpected input type: ${typeof acc}`);
509
513
  }
514
+
515
+ export function isPColumnReady(c: PColumn<PColumnDataUniversal>): boolean {
516
+ const isValues = (d: PColumnDataUniversal): d is PColumnValues => Array.isArray(d);
517
+ const isAccessor = (d: PColumnDataUniversal): d is TreeNodeAccessor => d instanceof TreeNodeAccessor;
518
+
519
+ let ready = true;
520
+ if (isAccessor(c.data)) {
521
+ ready &&= c.data.getIsReadyOrError();
522
+ } else if (isDataInfo(c.data)) {
523
+ visitDataInfo(c.data, (v) => ready &&= v.getIsReadyOrError());
524
+ } else if (!isValues(c.data)) {
525
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
526
+ throw Error(`unsupported column data type: ${c.data satisfies never}`);
527
+ }
528
+ return ready;
529
+ }
530
+
531
+ export function allPColumnsReady(columns: PColumn<PColumnDataUniversal>[]): boolean {
532
+ return columns.every(isPColumnReady);
533
+ }