@platforma-open/milaboratories.repertoire-diversity-2.model 1.4.0 → 1.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.repertoire-diversity-2.model",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Block model",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -0,0 +1,10 @@
1
+ import type { Metric, MetricUI } from './index';
2
+
3
+ export const convertMetricsUiToArgs = (metrics: MetricUI[]): Metric[] => {
4
+ return metrics.map((metric): Metric => {
5
+ return {
6
+ type: metric.type,
7
+ downsampling: metric.downsampling,
8
+ };
9
+ });
10
+ };
package/src/index.ts CHANGED
@@ -2,18 +2,23 @@ import type { GraphMakerState } from '@milaboratories/graph-maker';
2
2
  import type { InferOutputsType, PColumnIdAndSpec, PlDataTableStateV2, PlRef } from '@platforma-sdk/model';
3
3
  import { BlockModel, createPFrameForGraphs, createPlDataTableStateV2, createPlDataTableV2 } from '@platforma-sdk/model';
4
4
 
5
+ export * from './converters';
6
+
5
7
  export type DiversityType = 'chao1' | 'd50' | 'efronThisted' |
6
8
  'observed' | 'shannonWienerIndex' | 'shannonWiener' |
7
9
  'normalizedShannonWiener' | 'inverseSimpson' | 'gini';
8
10
 
9
11
  export type Metric = {
10
- id: string;
11
12
  type: DiversityType | undefined;
12
13
  downsampling: {
13
14
  type?: 'none' | 'top' | 'cumtop' | 'hypergeometric' ;
14
15
  valueChooser?: 'min' | 'fixed' | 'max' | 'auto';
15
16
  n?: number;
16
17
  };
18
+ };
19
+
20
+ export type MetricUI = Metric & {
21
+ id: string;
17
22
  isExpanded?: boolean;
18
23
  };
19
24
 
@@ -23,14 +28,27 @@ export type BlockArgs = {
23
28
  };
24
29
 
25
30
  export type UiState = {
31
+ metrics: MetricUI[];
26
32
  blockTitle: string;
27
33
  tableState: PlDataTableStateV2;
28
34
  graphState: GraphMakerState;
29
35
  };
30
36
 
31
37
  export const model = BlockModel.create()
32
-
33
38
  .withArgs<BlockArgs>({
39
+ metrics: [],
40
+ })
41
+
42
+ .withUiState<UiState>({
43
+ blockTitle: 'Repertoire Diversity',
44
+ graphState: {
45
+ title: 'Repertoire Diversity',
46
+ template: 'bar',
47
+ currentTab: null,
48
+ },
49
+
50
+ tableState: createPlDataTableStateV2(),
51
+
34
52
  metrics: [
35
53
  {
36
54
  id: 'observed',
@@ -80,17 +98,6 @@ export const model = BlockModel.create()
80
98
  ],
81
99
  })
82
100
 
83
- .withUiState<UiState>({
84
- blockTitle: 'Repertoire Diversity',
85
- graphState: {
86
- title: 'Repertoire Diversity',
87
- template: 'bar',
88
- currentTab: null,
89
- },
90
-
91
- tableState: createPlDataTableStateV2(),
92
- })
93
-
94
101
  .argsValid((ctx) => ctx.args.abundanceRef !== undefined)
95
102
 
96
103
  .output('abundanceOptions', (ctx) =>
@@ -114,7 +121,7 @@ export const model = BlockModel.create()
114
121
  return undefined;
115
122
  }
116
123
 
117
- return createPlDataTableV2(ctx, pCols, ctx.uiState?.tableState);
124
+ return createPlDataTableV2(ctx, pCols, ctx.uiState.tableState);
118
125
  })
119
126
 
120
127
  .output('pf', (ctx) => {