@milaboratories/graph-maker 1.1.143 → 1.1.145

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 (48) hide show
  1. package/dist/GraphMaker/index.vue.d.ts.map +1 -1
  2. package/dist/GraphMaker/index.vue.js.map +1 -1
  3. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js +64 -64
  4. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js.map +1 -1
  5. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js +31 -31
  6. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
  7. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js +39 -32
  8. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js.map +1 -1
  9. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ControllerBase.js +68 -62
  10. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ControllerBase.js.map +1 -1
  11. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/dendro.js +5 -5
  12. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/histogram.js +8 -8
  13. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot-umap.js +3 -3
  14. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot.js +6 -6
  15. package/dist/node_modules/@milaboratories/pf-plots/dist/index.js +12 -9
  16. package/dist/node_modules/@milaboratories/pf-plots/dist/index.js.map +1 -1
  17. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-error-like/dist/{index.js → error_like_shape.js} +1 -1
  18. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-error-like/dist/error_like_shape.js.map +1 -0
  19. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/blob.js +8 -0
  20. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/blob.js.map +1 -0
  21. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/data_types.js +63 -0
  22. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/data_types.js.map +1 -0
  23. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/linker_columns.js +152 -0
  24. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/linker_columns.js.map +1 -0
  25. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/spec/spec.js +189 -0
  26. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/spec/spec.js.map +1 -0
  27. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/errors.js +18 -0
  28. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/errors.js.map +1 -0
  29. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/json.js +12 -0
  30. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/json.js.map +1 -0
  31. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/plid.js +7 -0
  32. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/plid.js.map +1 -0
  33. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/ref.js +8 -0
  34. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/ref.js.map +1 -0
  35. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/components/PlDataTable.js +13 -0
  36. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/components/PlDataTable.js.map +1 -0
  37. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/render/util/label.js +89 -0
  38. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/render/util/label.js.map +1 -0
  39. package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js +50 -45
  40. package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js.map +1 -1
  41. package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js +54 -50
  42. package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js.map +1 -1
  43. package/package.json +4 -4
  44. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-error-like/dist/index.js.map +0 -1
  45. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/index.js +0 -979
  46. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/index.js.map +0 -1
  47. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/index.js +0 -1599
  48. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/index.js.map +0 -1
@@ -0,0 +1,152 @@
1
+ import { parseJson as k, canonicalizeJson as m } from "../../json.js";
2
+ import { readAnnotationJson as y, getNormalizedAxesList as w, getArrayFromAxisTree as x, getAxesTree as d, getAxisId as u, Annotation as S } from "./spec/spec.js";
3
+ var L = Object.defineProperty, v = (A, e, s) => e in A ? L(A, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : A[e] = s, F = (A, e, s) => v(A, e + "", s);
4
+ class p {
5
+ constructor(e) {
6
+ F(this, "data"), this.data = e;
7
+ }
8
+ get keys() {
9
+ return this.data.keys();
10
+ }
11
+ get keyAxesIds() {
12
+ return [...this.data.keys()].map(k);
13
+ }
14
+ static fromColumns(e) {
15
+ var s, t;
16
+ const a = /* @__PURE__ */ new Map();
17
+ for (const l of e.filter((o) => !!y(o.spec, S.IsLinkerColumn))) {
18
+ const o = p.getAxesGroups(w(l.spec.axesSpec));
19
+ if (o.length !== 2)
20
+ continue;
21
+ const [n, r] = o, c = p.getAxesRoots(n).map((i) => {
22
+ const h = x(d(i));
23
+ return [m(h.map(u)), h];
24
+ }), f = p.getAxesRoots(r).map((i) => {
25
+ const h = x(d(i));
26
+ return [m(h.map(u)), h];
27
+ });
28
+ for (const [i, h] of c)
29
+ a.has(i) || a.set(i, { keyAxesSpec: h, linkWith: /* @__PURE__ */ new Map() });
30
+ for (const [i, h] of f)
31
+ a.has(i) || a.set(i, { keyAxesSpec: h, linkWith: /* @__PURE__ */ new Map() });
32
+ for (const [i] of c)
33
+ for (const [h] of f)
34
+ (s = a.get(i)) == null || s.linkWith.set(h, l), (t = a.get(h)) == null || t.linkWith.set(i, l);
35
+ }
36
+ return new this(a);
37
+ }
38
+ /** Get all available nodes of linker graphs if start from sourceAxesKeys */
39
+ searchAvailableAxesKeys(e) {
40
+ const s = new Set(e), t = /* @__PURE__ */ new Set();
41
+ let a = e;
42
+ for (; a.length; ) {
43
+ const l = [];
44
+ for (const o of a) {
45
+ const n = this.data.get(o);
46
+ if (n)
47
+ for (const r of n.linkWith.keys())
48
+ !t.has(r) && !s.has(r) && (l.push(r), t.add(r));
49
+ }
50
+ a = l;
51
+ }
52
+ return t;
53
+ }
54
+ /** Get all linker columns that are necessary to reach endKey from startKey */
55
+ searchLinkerPath(e, s) {
56
+ const t = {};
57
+ let a = /* @__PURE__ */ new Set([e]);
58
+ const l = /* @__PURE__ */ new Set([e]);
59
+ for (; a.size; ) {
60
+ const o = /* @__PURE__ */ new Set();
61
+ for (const n of a) {
62
+ const r = this.data.get(n);
63
+ if (r)
64
+ for (const c of r.linkWith.keys())
65
+ if (t[c] = n, c === s) {
66
+ const f = [];
67
+ let i = s;
68
+ for (; t[i] !== e; )
69
+ f.push(i), i = t[i];
70
+ return f.push(i), f.map((h) => this.data.get(h).linkWith.get(t[h]));
71
+ } else l.has(c) || (o.add(c), l.add(c));
72
+ }
73
+ a = o;
74
+ }
75
+ return [];
76
+ }
77
+ getLinkerColumnsForAxes({ from: e, to: s, throwWhenNoLinkExists: t = !0 }) {
78
+ const a = e.map(p.getLinkerKeyFromAxisSpec);
79
+ return Array.from(new Map(p.getAxesRoots(s).map(p.getLinkerKeyFromAxisSpec).flatMap((l) => {
80
+ const o = a.map((n) => this.searchLinkerPath(n, l)).reduce((n, r) => n.length && n.length < r.length || !r.length ? n : r, []).map((n) => [n.columnId, n]);
81
+ if (!o.length && t)
82
+ throw Error(`Unable to find linker column for ${l}`);
83
+ return o;
84
+ })).values());
85
+ }
86
+ /** Get list of axisSpecs from keys of linker columns map */
87
+ getAxesListFromKeysList(e) {
88
+ return Array.from(new Map(e.flatMap((s) => {
89
+ var t;
90
+ return ((t = this.data.get(s)) == null ? void 0 : t.keyAxesSpec) ?? [];
91
+ }).map((s) => [m(u(s)), s])).values());
92
+ }
93
+ /** Get axes of target axes that are impossible to be linked to source axes with current linker map */
94
+ getNonLinkableAxes(e, s) {
95
+ const t = e.map(p.getLinkerKeyFromAxisSpec), a = s.map(p.getLinkerKeyFromAxisSpec);
96
+ return Array.from(new Map(s.filter((l, o) => {
97
+ const n = a[o];
98
+ return !t.some((r) => this.searchLinkerPath(r, n).length);
99
+ }).flatMap((l) => x(d(l)).map((o) => [m(u(o)), o]))).values());
100
+ }
101
+ /** Get all axes that can be connected to sourceAxes by linkers */
102
+ getReachableByLinkersAxesFromAxes(e) {
103
+ const s = e.map(p.getLinkerKeyFromAxisSpec), t = this.searchAvailableAxesKeys(s);
104
+ return this.getAxesListFromKeysList([...t]);
105
+ }
106
+ static getLinkerKeyFromAxisSpec(e) {
107
+ return m(x(d(e)).map(u));
108
+ }
109
+ /** Split array of axes into several arrays by parents: axes of one group are parents for each other.
110
+ There are no order inside every group. */
111
+ static getAxesGroups(e) {
112
+ switch (e.length) {
113
+ case 0:
114
+ return [];
115
+ case 1:
116
+ return [[e[0]]];
117
+ }
118
+ const s = e.map((r) => m(u(r))), t = e.map((r) => new Set(r.parentAxesSpec.map((c) => m(u(c))).map((c) => {
119
+ const f = s.indexOf(c);
120
+ if (f === -1)
121
+ throw new Error(`malformed axesSpec: ${JSON.stringify(e)}, unable to locate parent ${c}`);
122
+ return f;
123
+ }))), a = [...e.keys()], l = [], o = /* @__PURE__ */ new Set();
124
+ let n = a.find((r) => !o.has(r));
125
+ for (; n !== void 0; ) {
126
+ const r = [n];
127
+ o.add(n);
128
+ let c = [n];
129
+ for (; c.length; ) {
130
+ const f = /* @__PURE__ */ new Set();
131
+ for (const i of c) {
132
+ const h = t[i];
133
+ a.forEach((g) => {
134
+ g === i || o.has(g) || (t[g].has(i) || h.has(g)) && (r.push(g), f.add(g), o.add(g));
135
+ });
136
+ }
137
+ c = [...f];
138
+ }
139
+ l.push([...r]), n = a.find((f) => !o.has(f));
140
+ }
141
+ return l.map((r) => r.map((c) => e[c]));
142
+ }
143
+ /** Get all axes that are not parents of any other axis */
144
+ static getAxesRoots(e) {
145
+ const s = new Set(e.flatMap((t) => t.parentAxesSpec).map((t) => m(u(t))));
146
+ return e.filter((t) => !s.has(m(u(t))));
147
+ }
148
+ }
149
+ export {
150
+ p as LinkerMap
151
+ };
152
+ //# sourceMappingURL=linker_columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linker_columns.js","sources":["../../../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@milaboratories/pl-model-common/src/drivers/pframe/linker_columns.ts"],"sourcesContent":["import {\n canonicalizeJson,\n parseJson,\n type CanonicalizedJson,\n} from '../../json';\nimport {\n Annotation,\n readAnnotationJson,\n type AxisSpec,\n type PColumnIdAndSpec,\n type AxisSpecNormalized,\n type AxisId,\n getAxisId,\n getNormalizedAxesList,\n getArrayFromAxisTree,\n getAxesTree,\n} from './spec/spec';\n\ntype LinkerKey = CanonicalizedJson<AxisId[]>;\nexport type CompositeLinkerMap = Map<\n LinkerKey,\n {\n keyAxesSpec: AxisSpecNormalized[]; // axis specs - source for the key\n linkWith: Map<LinkerKey, PColumnIdAndSpec>; // for every axis (possibly in group with parents - available by linkers another axes and corresponding linkers)\n }\n>;\n\ninterface LinkersData {\n data: CompositeLinkerMap;\n}\nexport class LinkerMap implements LinkersData {\n /** Graph of linkers connected by axes (single or grouped by parents) */\n readonly data: CompositeLinkerMap;\n\n constructor(linkerMap: CompositeLinkerMap) {\n this.data = linkerMap;\n }\n\n get keys() {\n return this.data.keys();\n }\n\n get keyAxesIds() {\n return [...this.data.keys()].map(parseJson);\n }\n\n static fromColumns(columns: PColumnIdAndSpec[]) {\n const result: CompositeLinkerMap = new Map();\n for (const linker of columns.filter((l) => !!readAnnotationJson(l.spec, Annotation.IsLinkerColumn))) {\n const groups = LinkerMap.getAxesGroups(getNormalizedAxesList(linker.spec.axesSpec)); // split input axes into groups by parent links from annotation\n\n if (groups.length !== 2) {\n continue; // not a valid linker column\n }\n const [left, right] = groups;\n\n // In case of group:\n // A - C\n // \\_ B _ D\n // E/\n // put 2 variants as keys:\n // A - C\n // \\_ B _ D\n // and\n // E - B - D\n const leftKeyVariants: [LinkerKey, AxisSpecNormalized[]][] = LinkerMap.getAxesRoots(left).map((axis) => {\n const axes = getArrayFromAxisTree(getAxesTree(axis));\n const key = canonicalizeJson(axes.map(getAxisId));\n return [key, axes];\n });\n const rightKeyVariants: [LinkerKey, AxisSpecNormalized[]][] = LinkerMap.getAxesRoots(right).map((axis) => {\n const axes = getArrayFromAxisTree(getAxesTree(axis));\n const key = canonicalizeJson(axes.map(getAxisId));\n return [key, axes];\n });\n\n for (const [keyLeft, spec] of leftKeyVariants) {\n if (!result.has(keyLeft)) {\n result.set(keyLeft, { keyAxesSpec: spec, linkWith: new Map() });\n }\n }\n for (const [keyRight, spec] of rightKeyVariants) {\n if (!result.has(keyRight)) {\n result.set(keyRight, { keyAxesSpec: spec, linkWith: new Map() });\n }\n }\n for (const [keyLeft] of leftKeyVariants) {\n for (const [keyRight] of rightKeyVariants) {\n result.get(keyLeft)?.linkWith.set(keyRight, linker);\n result.get(keyRight)?.linkWith.set(keyLeft, linker);\n }\n }\n }\n return new this(result);\n }\n\n /** Get all available nodes of linker graphs if start from sourceAxesKeys */\n searchAvailableAxesKeys(sourceAxesKeys: LinkerKey[]): Set<LinkerKey> {\n const startKeys = new Set(sourceAxesKeys);\n const allAvailableKeys = new Set<LinkerKey>();\n let nextKeys = sourceAxesKeys;\n while (nextKeys.length) {\n const next: LinkerKey[] = [];\n for (const key of nextKeys) {\n const node = this.data.get(key);\n if (!node) continue;\n for (const availableKey of node.linkWith.keys()) {\n if (!allAvailableKeys.has(availableKey) && !startKeys.has(availableKey)) {\n next.push(availableKey);\n allAvailableKeys.add(availableKey);\n }\n }\n }\n nextKeys = next;\n }\n return allAvailableKeys;\n }\n\n /** Get all linker columns that are necessary to reach endKey from startKey */\n searchLinkerPath(startKey: LinkerKey, endKey: LinkerKey): PColumnIdAndSpec[] {\n const previous: Record<LinkerKey, LinkerKey> = {};\n let nextIds = new Set([startKey]);\n const visited = new Set([startKey]);\n while (nextIds.size) {\n const next = new Set<LinkerKey>();\n for (const nextId of nextIds) {\n const node = this.data.get(nextId);\n if (!node) continue;\n for (const availableId of node.linkWith.keys()) {\n previous[availableId] = nextId;\n if (availableId === endKey) {\n const ids: LinkerKey[] = [];\n let current = endKey;\n while (previous[current] !== startKey) {\n ids.push(current);\n current = previous[current];\n }\n ids.push(current);\n return ids.map((id: LinkerKey) => this.data.get(id)!.linkWith.get(previous[id])!);\n } else if (!visited.has(availableId)) {\n next.add(availableId);\n visited.add(availableId);\n }\n }\n }\n nextIds = next;\n }\n return [];\n }\n\n getLinkerColumnsForAxes({\n from: sourceAxes,\n to: targetAxes,\n throwWhenNoLinkExists = true,\n }: {\n from: AxisSpecNormalized[];\n to: AxisSpecNormalized[];\n throwWhenNoLinkExists?: boolean;\n }): PColumnIdAndSpec[] {\n // start keys - all possible keys in linker map using sourceAxes (for example, all axes of block's columns or all axes of columns in data-inputs)\n const startKeys: LinkerKey[] = sourceAxes.map(LinkerMap.getLinkerKeyFromAxisSpec);\n\n return Array.from(\n new Map(\n LinkerMap.getAxesRoots(targetAxes)\n .map(LinkerMap.getLinkerKeyFromAxisSpec) // target keys contain all axes to be linked; if some of target axes has parents they must be in the key\n .flatMap((targetKey) => {\n const linkers = startKeys\n .map((startKey) => this.searchLinkerPath(startKey, targetKey))\n .reduce((shortestPath, path) => (shortestPath.length && shortestPath.length < path.length) || !path.length ? shortestPath : path,\n [] as PColumnIdAndSpec[])\n .map((linker) => [linker.columnId, linker] as const);\n if (!linkers.length && throwWhenNoLinkExists) {\n throw Error(`Unable to find linker column for ${targetKey}`);\n }\n return linkers;\n }),\n ).values(),\n );\n }\n\n /** Get list of axisSpecs from keys of linker columns map */\n getAxesListFromKeysList(keys: LinkerKey[]): AxisSpecNormalized[] {\n return Array.from(\n new Map(\n keys.flatMap((key) => this.data.get(key)?.keyAxesSpec ?? [])\n .map((axis) => [canonicalizeJson(getAxisId(axis)), axis]),\n ).values(),\n );\n }\n\n /** Get axes of target axes that are impossible to be linked to source axes with current linker map */\n getNonLinkableAxes(\n sourceAxes: AxisSpecNormalized[],\n targetAxes: AxisSpecNormalized[],\n ): AxisSpecNormalized[] {\n const startKeys = sourceAxes.map(LinkerMap.getLinkerKeyFromAxisSpec);\n // target keys contain all axes to be linked; if some of target axes has parents they must be in the key\n const targetKeys = targetAxes.map(LinkerMap.getLinkerKeyFromAxisSpec);\n\n const axes = Array.from(\n new Map(\n targetAxes\n .filter((_targetAxis, idx) => {\n const targetKey = targetKeys[idx];\n return !startKeys.some((startKey) => this.searchLinkerPath(startKey, targetKey).length);\n })\n .flatMap((axis) => getArrayFromAxisTree(getAxesTree(axis)).map((axis) => [canonicalizeJson(getAxisId(axis)), axis])),\n ).values(),\n );\n return axes;\n }\n\n /** Get all axes that can be connected to sourceAxes by linkers */\n getReachableByLinkersAxesFromAxes(sourceAxes: AxisSpecNormalized[]): AxisSpec[] {\n const startKeys = sourceAxes.map(LinkerMap.getLinkerKeyFromAxisSpec);\n const availableKeys = this.searchAvailableAxesKeys(startKeys);\n return this.getAxesListFromKeysList([...availableKeys]);\n }\n\n static getLinkerKeyFromAxisSpec(axis: AxisSpecNormalized): LinkerKey {\n return canonicalizeJson(getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));\n }\n\n /** Split array of axes into several arrays by parents: axes of one group are parents for each other.\n There are no order inside every group. */\n static getAxesGroups(axesSpec: AxisSpecNormalized[]): AxisSpecNormalized[][] {\n switch (axesSpec.length) {\n case 0: return [];\n case 1: return [[axesSpec[0]]];\n default: break;\n }\n\n const axisKeys = axesSpec.map((spec) => canonicalizeJson(getAxisId(spec)));\n const axisParentsIdxs = axesSpec.map(\n (spec) => new Set(\n spec.parentAxesSpec\n .map((spec) => canonicalizeJson(getAxisId(spec)))\n .map((el) => {\n const idx = axisKeys.indexOf(el);\n if (idx === -1) {\n throw new Error(`malformed axesSpec: ${JSON.stringify(axesSpec)}, unable to locate parent ${el}`);\n }\n return idx;\n }),\n ),\n );\n\n const allIdxs = [...axesSpec.keys()];\n const groups: number[][] = []; // groups of axis indexes\n\n const usedIdxs = new Set<number>();\n let nextFreeEl = allIdxs.find((idx) => !usedIdxs.has(idx));\n while (nextFreeEl !== undefined) {\n const currentGroup = [nextFreeEl];\n usedIdxs.add(nextFreeEl);\n\n let nextElsOfCurrentGroup = [nextFreeEl];\n while (nextElsOfCurrentGroup.length) {\n const next = new Set<number>();\n for (const groupIdx of nextElsOfCurrentGroup) {\n const groupElementParents = axisParentsIdxs[groupIdx];\n allIdxs.forEach((idx) => {\n if (idx === groupIdx || usedIdxs.has(idx)) {\n return;\n }\n const parents = axisParentsIdxs[idx];\n if (parents.has(groupIdx) || groupElementParents.has(idx)) {\n currentGroup.push(idx);\n next.add(idx);\n usedIdxs.add(idx);\n }\n });\n }\n nextElsOfCurrentGroup = [...next];\n }\n\n groups.push([...currentGroup]);\n nextFreeEl = allIdxs.find((idx) => !usedIdxs.has(idx));\n };\n\n return groups.map((group) => group.map((idx) => axesSpec[idx]));\n }\n\n /** Get all axes that are not parents of any other axis */\n static getAxesRoots(axes: AxisSpecNormalized[]): AxisSpecNormalized[] {\n const parentsSet = new Set(axes.flatMap((axis) => axis.parentAxesSpec).map((spec) => canonicalizeJson(getAxisId(spec))));\n return axes.filter((axis) => !parentsSet.has(canonicalizeJson(getAxisId(axis))));\n }\n}\n"],"names":["LinkerMap","linkerMap","__publicField","parseJson","columns","result","linker","l","readAnnotationJson","Annotation","groups","getNormalizedAxesList","left","right","leftKeyVariants","axis","axes","getArrayFromAxisTree","getAxesTree","canonicalizeJson","getAxisId","rightKeyVariants","keyLeft","spec","keyRight","_a","_b","sourceAxesKeys","startKeys","allAvailableKeys","nextKeys","next","key","node","availableKey","startKey","endKey","previous","nextIds","visited","nextId","availableId","ids","current","id","sourceAxes","targetAxes","throwWhenNoLinkExists","targetKey","linkers","shortestPath","path","keys","targetKeys","_targetAxis","idx","availableKeys","axesSpec","axisKeys","axisParentsIdxs","el","allIdxs","usedIdxs","nextFreeEl","currentGroup","nextElsOfCurrentGroup","groupIdx","groupElementParents","group","parentsSet"],"mappings":";;;AA8Ba,MAAAA,EAAS;AAAA,EAIpB,YAAYC,GAA6B;AAFhCC,IAAAA,EAAA,MAAA,MAAA,GAGP,KAAK,OAAOD;AAAAA,EACd;AAAA,EAEA,IAAI,OAAI;AACN,WAAO,KAAK,KAAK,KAAA;AAAA,EACnB;AAAA,EAEA,IAAI,aAAU;AACZ,WAAO,CAAC,GAAG,KAAK,KAAK,MAAM,EAAE,IAAIE,CAAS;AAAA,EAC5C;AAAA,EAEA,OAAO,YAAYC,GAA2B;;AAC5C,UAAMC,wBAAiC,IAAA;AACvC,eAAWC,KAA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C,CAAC;AAAA,EACjF;AACD;","x_google_ignoreList":[0]}
@@ -0,0 +1,189 @@
1
+ import { ensureError as A } from "../../../errors.js";
2
+ import { canonicalizeJson as l } from "../../../json.js";
3
+ import o from "../../../../../../zod/lib/index.js";
4
+ const V = {
5
+ Int: "Int",
6
+ Long: "Long",
7
+ Float: "Float",
8
+ Double: "Double",
9
+ String: "String",
10
+ Bytes: "Bytes"
11
+ };
12
+ function m(n, e) {
13
+ return n == null ? void 0 : n[e];
14
+ }
15
+ function g(n, e, t, a = "readMetadataJsonOrThrow") {
16
+ const r = m(n, t);
17
+ if (r === void 0)
18
+ return;
19
+ const s = e[t];
20
+ try {
21
+ const i = JSON.parse(r);
22
+ return s.parse(i);
23
+ } catch (i) {
24
+ throw new Error(`${a} failed, key: ${String(t)}, value: ${r}, error: ${A(i)}`);
25
+ }
26
+ }
27
+ function b(n, e, t) {
28
+ try {
29
+ return g(n, e, t);
30
+ } catch {
31
+ return;
32
+ }
33
+ }
34
+ const p = {
35
+ DiscreteValues: "pl7.app/discreteValues",
36
+ Graph: {
37
+ IsVirtual: "pl7.app/graph/isVirtual"
38
+ },
39
+ HideDataFromUi: "pl7.app/hideDataFromUi",
40
+ IsLinkerColumn: "pl7.app/isLinkerColumn",
41
+ Label: "pl7.app/label",
42
+ Max: "pl7.app/max",
43
+ Min: "pl7.app/min",
44
+ Parents: "pl7.app/parents",
45
+ Sequence: {
46
+ Annotation: {
47
+ Mapping: "pl7.app/sequence/annotation/mapping"
48
+ },
49
+ IsAnnotation: "pl7.app/sequence/isAnnotation"
50
+ },
51
+ Table: {
52
+ OrderPriority: "pl7.app/table/orderPriority"
53
+ },
54
+ Trace: "pl7.app/trace"
55
+ }, y = {
56
+ [p.DiscreteValues]: o.array(o.string()).or(o.array(o.number())),
57
+ [p.Graph.IsVirtual]: o.boolean(),
58
+ [p.HideDataFromUi]: o.boolean(),
59
+ [p.IsLinkerColumn]: o.boolean(),
60
+ [p.Max]: o.number(),
61
+ [p.Min]: o.number(),
62
+ [p.Parents]: o.array(o.string()),
63
+ [p.Sequence.Annotation.Mapping]: o.record(o.string(), o.string()),
64
+ [p.Sequence.IsAnnotation]: o.boolean(),
65
+ [p.Table.OrderPriority]: o.number(),
66
+ [p.Trace]: o.record(o.string(), o.unknown())
67
+ };
68
+ function D(n, e) {
69
+ return m(n == null ? void 0 : n.annotations, e);
70
+ }
71
+ function S(n, e) {
72
+ return b(n == null ? void 0 : n.annotations, y, e);
73
+ }
74
+ function u(n) {
75
+ return { axis: n, children: [] };
76
+ }
77
+ function M(n) {
78
+ const e = u(n);
79
+ let t = [e];
80
+ for (; t.length; ) {
81
+ const a = [];
82
+ for (const r of t)
83
+ r.children = r.axis.parentAxesSpec.map(u), a.push(...r.children);
84
+ t = a;
85
+ }
86
+ return e;
87
+ }
88
+ function I(n) {
89
+ const e = [n.axis];
90
+ let t = [n];
91
+ for (; t.length; ) {
92
+ const a = [];
93
+ for (const r of t)
94
+ for (const s of r.children)
95
+ e.push(s.axis), a.push(s);
96
+ t = a;
97
+ }
98
+ return e;
99
+ }
100
+ function d(n) {
101
+ return l(I(M(n)).map(f));
102
+ }
103
+ function P(n, e) {
104
+ if (n.name !== e.name)
105
+ return n.name < e.name ? 1 : -1;
106
+ if (n.type !== e.type)
107
+ return n.type < e.type ? 1 : -1;
108
+ const t = l(n.domain ?? {}), a = l(e.domain ?? {});
109
+ if (t !== a)
110
+ return t < a ? 1 : -1;
111
+ const r = d(n), s = d(e);
112
+ if (r !== s)
113
+ return r < s ? 1 : -1;
114
+ const i = l(n.annotations ?? {}), c = l(e.annotations ?? {});
115
+ return i !== c ? i < c ? 1 : -1 : 0;
116
+ }
117
+ function T(n) {
118
+ const e = S(n, p.Parents);
119
+ return e === void 0 ? [] : e;
120
+ }
121
+ function h(n) {
122
+ n.parentAxesSpec.forEach(h), n.parentAxesSpec.sort(P);
123
+ }
124
+ function L(n) {
125
+ let e = [u(n)];
126
+ const t = new Set(l(f(n)));
127
+ for (; e.length; ) {
128
+ const a = [], r = /* @__PURE__ */ new Set();
129
+ for (const s of e) {
130
+ s.children = s.axis.parentAxesSpec.map(u);
131
+ for (const i of s.children) {
132
+ const c = l(f(i.axis));
133
+ if (!r.has(c)) {
134
+ if (a.push(i), r.add(c), t.has(c))
135
+ return !0;
136
+ t.add(c);
137
+ }
138
+ }
139
+ }
140
+ e = a;
141
+ }
142
+ return !1;
143
+ }
144
+ function F(n) {
145
+ if (!n.length)
146
+ return [];
147
+ const e = n.map((t) => {
148
+ const { parentAxes: a, ...r } = t;
149
+ return { ...r, annotations: { ...r.annotations }, parentAxesSpec: [] };
150
+ });
151
+ return n.forEach((t, a) => {
152
+ var r;
153
+ const s = e[a];
154
+ if (t.parentAxes)
155
+ s.parentAxesSpec = t.parentAxes.map((i) => e[i]);
156
+ else {
157
+ const i = T(t).map((c) => e.find((x) => x.name === c));
158
+ s.parentAxesSpec = i.some((c) => c === void 0) ? [] : i, (r = s.annotations) == null || delete r[p.Parents];
159
+ }
160
+ }), e.some(L) ? e.forEach((t) => {
161
+ t.parentAxesSpec = [];
162
+ }) : e.forEach((t) => {
163
+ h(t);
164
+ }), e;
165
+ }
166
+ const O = {
167
+ Label: "pl7.app/label"
168
+ };
169
+ function f(n) {
170
+ const { type: e, name: t, domain: a } = n, r = { type: e, name: t };
171
+ return a && Object.entries(a).length > 0 && Object.assign(r, { domain: a }), r;
172
+ }
173
+ export {
174
+ p as Annotation,
175
+ y as AnnotationJson,
176
+ O as PColumnName,
177
+ V as ValueType,
178
+ d as canonicalizeAxisWithParents,
179
+ I as getArrayFromAxisTree,
180
+ M as getAxesTree,
181
+ f as getAxisId,
182
+ F as getNormalizedAxesList,
183
+ D as readAnnotation,
184
+ S as readAnnotationJson,
185
+ m as readMetadata,
186
+ b as readMetadataJson,
187
+ g as readMetadataJsonOrThrow
188
+ };
189
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sources":["../../../../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@milaboratories/pl-model-common/src/drivers/pframe/spec/spec.ts"],"sourcesContent":["import { ensureError } from '../../../errors';\nimport {\n canonicalizeJson,\n type CanonicalizedJson,\n type StringifiedJson,\n} from '../../../json';\nimport type {\n PObject,\n PObjectId,\n PObjectSpec,\n} from '../../../pool';\nimport { z } from 'zod';\n\ntype Expect<T extends true> = T;\ntype Equal<X, Y> =\n (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;\n\nexport const ValueType = {\n Int: 'Int',\n Long: 'Long',\n Float: 'Float',\n Double: 'Double',\n String: 'String',\n Bytes: 'Bytes',\n} as const;\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = (typeof ValueType)[keyof typeof ValueType];\n\nexport type Metadata = Record<string, string>;\n\nexport function readMetadata<U extends Metadata, T extends keyof U = keyof U>(\n metadata: Metadata | undefined,\n key: T,\n): U[T] | undefined {\n return (metadata as U | undefined)?.[key];\n}\n\ntype MetadataJsonImpl<M> = {\n [P in keyof M as (M[P] extends StringifiedJson ? P : never)]: M[P] extends StringifiedJson<infer U> ? z.ZodType<U> : never;\n};\nexport type MetadataJson<M> = MetadataJsonImpl<Required<M>>;\n\nexport function readMetadataJsonOrThrow<M extends Metadata, T extends keyof MetadataJson<M>>(\n metadata: Metadata | undefined,\n metadataJson: MetadataJson<M>,\n key: T,\n methodNameInError: string = 'readMetadataJsonOrThrow',\n): z.infer<MetadataJson<M>[T]> | undefined {\n const json = readMetadata<M, T>(metadata, key);\n if (json === undefined) return undefined;\n\n const schema = metadataJson[key];\n try {\n const value = JSON.parse(json);\n return schema.parse(value);\n } catch (error: unknown) {\n throw new Error(\n `${methodNameInError} failed, `\n + `key: ${String(key)}, `\n + `value: ${json}, `\n + `error: ${ensureError(error)}`,\n );\n }\n}\n\nexport function readMetadataJson<M extends Metadata, T extends keyof MetadataJson<M>>(\n metadata: Metadata | undefined,\n metadataJson: MetadataJson<M>,\n key: T,\n): z.infer<MetadataJson<M>[T]> | undefined {\n try {\n return readMetadataJsonOrThrow(metadata, metadataJson, key);\n } catch {\n return undefined; // treat invalid values as unset\n }\n}\n\n/// Well-known domains\nexport const Domain = {\n Alphabet: 'pl7.app/alphabet',\n BlockId: 'pl7.app/blockId',\n} as const;\n\nexport type Domain = Metadata & Partial<{\n [Domain.Alphabet]: 'nucleotide' | 'aminoacid' | string;\n [Domain.BlockId]: string;\n}>;\n\nexport type DomainJson = MetadataJson<Domain>;\nexport const DomainJson: DomainJson = {};\n\n/// Helper function for reading plain domain values\nexport function readDomain<T extends keyof Domain>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): Domain[T] | undefined {\n return readMetadata<Domain, T>(spec?.domain, key);\n}\n\n/// Helper function for reading json-encoded domain values, throws on JSON parsing error\nexport function readDomainJsonOrThrow<T extends keyof DomainJson>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<DomainJson[T]> | undefined {\n return readMetadataJsonOrThrow<Domain, T>(spec?.domain, DomainJson, key, 'readDomainJsonOrThrow');\n}\n\n/// Helper function for reading json-encoded domain values, returns undefined on JSON parsing error\nexport function readDomainJson<T extends keyof DomainJson>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<DomainJson[T]> | undefined {\n return readMetadataJson<Domain, T>(spec?.domain, DomainJson, key);\n}\n\n/// Well-known annotations\nexport const Annotation = {\n Alphabet: 'pl7.app/alphabet',\n DiscreteValues: 'pl7.app/discreteValues',\n Format: 'pl7.app/format',\n Graph: {\n IsVirtual: 'pl7.app/graph/isVirtual',\n },\n HideDataFromUi: 'pl7.app/hideDataFromUi',\n IsLinkerColumn: 'pl7.app/isLinkerColumn',\n Label: 'pl7.app/label',\n Max: 'pl7.app/max',\n Min: 'pl7.app/min',\n Parents: 'pl7.app/parents',\n Sequence: {\n Annotation: {\n Mapping: 'pl7.app/sequence/annotation/mapping',\n },\n IsAnnotation: 'pl7.app/sequence/isAnnotation',\n },\n Table: {\n FontFamily: 'pl7.app/table/fontFamily',\n OrderPriority: 'pl7.app/table/orderPriority',\n Visibility: 'pl7.app/table/visibility',\n },\n Trace: 'pl7.app/trace',\n} as const;\n\nexport type Annotation = Metadata & Partial<{\n [Annotation.Alphabet]: 'nucleotide' | 'aminoacid' | string;\n [Annotation.DiscreteValues]: StringifiedJson<number[]> | StringifiedJson<string[]>;\n [Annotation.Format]: string;\n [Annotation.Graph.IsVirtual]: StringifiedJson<boolean>;\n [Annotation.HideDataFromUi]: StringifiedJson<boolean>;\n [Annotation.IsLinkerColumn]: StringifiedJson<boolean>;\n [Annotation.Label]: string;\n [Annotation.Max]: StringifiedJson<number>;\n [Annotation.Min]: StringifiedJson<number>;\n [Annotation.Parents]: StringifiedJson<AxisSpec['name'][]>;\n [Annotation.Sequence.Annotation.Mapping]: StringifiedJson<Record<string, string>>;\n [Annotation.Sequence.IsAnnotation]: StringifiedJson<boolean>;\n [Annotation.Table.FontFamily]: string;\n [Annotation.Table.OrderPriority]: StringifiedJson<number>;\n [Annotation.Table.Visibility]: 'hidden' | 'optional' | string;\n [Annotation.Trace]: StringifiedJson<Record<string, unknown>>;\n}>;\n\n// export const AxisSpec = z.object({\n// type: z.nativeEnum(ValueType),\n// name: z.string(),\n// domain: z.record(z.string(), z.string()).optional(),\n// annotations: z.record(z.string(), z.string()).optional(),\n// parentAxes: z.array(z.number()).optional(),\n// }).passthrough();\n// type _test = Expect<Equal<\n// Readonly<z.infer<typeof AxisSpec>>,\n// Readonly<AxisSpec & Record<string, unknown>>\n// >>;\n\nexport type AnnotationJson = MetadataJson<Annotation>;\nexport const AnnotationJson: AnnotationJson = {\n [Annotation.DiscreteValues]: z.array(z.string()).or(z.array(z.number())),\n [Annotation.Graph.IsVirtual]: z.boolean(),\n [Annotation.HideDataFromUi]: z.boolean(),\n [Annotation.IsLinkerColumn]: z.boolean(),\n [Annotation.Max]: z.number(),\n [Annotation.Min]: z.number(),\n [Annotation.Parents]: z.array(z.string()),\n [Annotation.Sequence.Annotation.Mapping]: z.record(z.string(), z.string()),\n [Annotation.Sequence.IsAnnotation]: z.boolean(),\n [Annotation.Table.OrderPriority]: z.number(),\n [Annotation.Trace]: z.record(z.string(), z.unknown()),\n};\n\n/// Helper function for reading plain annotation values\nexport function readAnnotation<T extends keyof Annotation>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): Annotation[T] | undefined {\n return readMetadata<Annotation, T>(spec?.annotations, key);\n}\n\n/// Helper function for reading json-encoded annotation values, throws on JSON parsing error\nexport function readAnnotationJsonOrThrow<T extends keyof AnnotationJson>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<AnnotationJson[T]> | undefined {\n return readMetadataJsonOrThrow<Annotation, T>(spec?.annotations, AnnotationJson, key, 'readAnnotationJsonOrThrow');\n}\n\n/// Helper function for reading json-encoded annotation values, returns undefined on JSON parsing error\nexport function readAnnotationJson<T extends keyof AnnotationJson>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<AnnotationJson[T]> | undefined {\n return readMetadataJson<Annotation, T>(spec?.annotations, AnnotationJson, key);\n}\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n * */\nexport interface AxisSpec {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n}\n\n/** Parents are specs, not indexes; normalized axis can be used considering its parents independently from column */\nexport interface AxisSpecNormalized extends Omit<AxisSpec, 'parentAxes'> {\n parentAxesSpec: AxisSpecNormalized[];\n}\n\n/** Tree: axis is a root, its parents are children */\nexport type AxisTree = {\n axis: AxisSpecNormalized;\n children: AxisTree[]; // parents\n};\n\nfunction makeAxisTree(axis: AxisSpecNormalized): AxisTree {\n return { axis, children: [] };\n}\n\n/** Build tree by axis parents annotations */\nexport function getAxesTree(rootAxis: AxisSpecNormalized): AxisTree {\n const root = makeAxisTree(rootAxis);\n let nodesQ = [root];\n while (nodesQ.length) {\n const nextNodes: AxisTree[] = [];\n for (const node of nodesQ) {\n node.children = node.axis.parentAxesSpec.map(makeAxisTree);\n nextNodes.push(...node.children);\n }\n nodesQ = nextNodes;\n }\n return root;\n}\n\n/** Get set of canonicalized axisIds from axisTree */\nexport function getSetFromAxisTree(tree: AxisTree): Set<CanonicalizedJson<AxisId>> {\n const set = new Set([canonicalizeJson(getAxisId(tree.axis))]);\n let nodesQ = [tree];\n while (nodesQ.length) {\n const nextNodes = [];\n for (const node of nodesQ) {\n for (const parent of node.children) {\n set.add(canonicalizeJson(getAxisId(parent.axis)));\n nextNodes.push(parent);\n }\n }\n nodesQ = nextNodes;\n }\n return set;\n}\n\n/** Get array of axisSpecs from axisTree */\nexport function getArrayFromAxisTree(tree: AxisTree): AxisSpecNormalized[] {\n const res = [tree.axis];\n let nodesQ = [tree];\n while (nodesQ.length) {\n const nextNodes = [];\n for (const node of nodesQ) {\n for (const parent of node.children) {\n res.push(parent.axis);\n nextNodes.push(parent);\n }\n }\n nodesQ = nextNodes;\n }\n return res;\n}\n\nexport function canonicalizeAxisWithParents(axis: AxisSpecNormalized) {\n return canonicalizeJson(getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));\n}\n\nfunction normalizingAxesComparator(axis1: AxisSpecNormalized, axis2: AxisSpecNormalized): 1 | -1 | 0 {\n if (axis1.name !== axis2.name) {\n return axis1.name < axis2.name ? 1 : -1;\n }\n if (axis1.type !== axis2.type) {\n return axis1.type < axis2.type ? 1 : -1;\n }\n const domain1 = canonicalizeJson(axis1.domain ?? {});\n const domain2 = canonicalizeJson(axis2.domain ?? {});\n if (domain1 !== domain2) {\n return domain1 < domain2 ? 1 : -1;\n }\n\n const parents1 = canonicalizeAxisWithParents(axis1);\n const parents2 = canonicalizeAxisWithParents(axis2);\n\n if (parents1 !== parents2) {\n return parents1 < parents2 ? 1 : -1;\n }\n\n const annotation1 = canonicalizeJson(axis1.annotations ?? {});\n const annotation2 = canonicalizeJson(axis2.annotations ?? {});\n if (annotation1 !== annotation2) {\n return annotation1 < annotation2 ? 1 : -1;\n }\n return 0;\n}\n\nfunction parseParentsFromAnnotations(axis: AxisSpec) {\n const parentsList = readAnnotationJson(axis, Annotation.Parents);\n if (parentsList === undefined) {\n return [];\n }\n return parentsList;\n}\n\nfunction sortParentsDeep(axisSpec: AxisSpecNormalized) {\n axisSpec.parentAxesSpec.forEach(sortParentsDeep);\n axisSpec.parentAxesSpec.sort(normalizingAxesComparator);\n}\n\nfunction hasCycleOfParents(axisSpec: AxisSpecNormalized) {\n const root = makeAxisTree(axisSpec);\n let nodesQ = [root];\n const ancestors = new Set(canonicalizeJson(getAxisId(axisSpec)));\n while (nodesQ.length) {\n const nextNodes: AxisTree[] = [];\n const levelIds = new Set<CanonicalizedJson<AxisId>>();\n for (const node of nodesQ) {\n node.children = node.axis.parentAxesSpec.map(makeAxisTree);\n for (const child of node.children) {\n const childId = canonicalizeJson(getAxisId(child.axis));\n if (!levelIds.has(childId)) {\n nextNodes.push(child);\n levelIds.add(childId);\n if (ancestors.has(childId)) {\n return true;\n }\n ancestors.add(childId);\n }\n }\n }\n nodesQ = nextNodes;\n }\n return false;\n}\n\n/** Create list of normalized axisSpec (parents are in array of specs, not indexes) */\nexport function getNormalizedAxesList(axes: AxisSpec[]): AxisSpecNormalized[] {\n if (!axes.length) {\n return [];\n }\n const modifiedAxes: AxisSpecNormalized[] = axes.map((axis) => {\n const { parentAxes: _, ...copiedRest } = axis;\n return { ...copiedRest, annotations: { ...copiedRest.annotations }, parentAxesSpec: [] };\n });\n\n axes.forEach((axis, idx) => {\n const modifiedAxis = modifiedAxes[idx];\n if (axis.parentAxes) { // if we have parents by indexes then take from the list\n modifiedAxis.parentAxesSpec = axis.parentAxes.map((idx) => modifiedAxes[idx]);\n } else { // else try to parse from annotation name\n const parents = parseParentsFromAnnotations(axis).map((name) => modifiedAxes.find((axis) => axis.name === name));\n modifiedAxis.parentAxesSpec = parents.some((p) => p === undefined) ? [] : parents as AxisSpecNormalized[];\n\n delete modifiedAxis.annotations?.[Annotation.Parents];\n }\n });\n\n if (modifiedAxes.some(hasCycleOfParents)) { // Axes list is broken\n modifiedAxes.forEach((axis) => {\n axis.parentAxesSpec = [];\n });\n } else {\n modifiedAxes.forEach((axis) => {\n sortParentsDeep(axis);\n });\n }\n\n return modifiedAxes;\n}\n\n/** Create list of regular axisSpec from normalized (parents are indexes, inside of current axes list) */\nexport function getDenormalizedAxesList(axesSpec: AxisSpecNormalized[]): AxisSpec[] {\n const idsList = axesSpec.map((axisSpec) => canonicalizeJson(getAxisId(axisSpec)));\n return axesSpec.map((axisSpec) => {\n const parentsIds = axisSpec.parentAxesSpec.map((axisSpec) => canonicalizeJson(getAxisId(axisSpec)));\n const parentIdxs = parentsIds.map((id) => idsList.indexOf(id));\n const { parentAxesSpec: _, ...copiedRest } = axisSpec;\n if (parentIdxs.length) {\n return { ...copiedRest, parentAxes: parentIdxs } as AxisSpec;\n }\n return copiedRest;\n });\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/// Well-known column names\nexport const PColumnName = {\n Label: 'pl7.app/label',\n Table: {\n RowSelection: 'pl7.app/table/row-selection',\n },\n} as const;\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n * */\nexport interface PUniversalColumnSpec extends PObjectSpec {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: 'PColumn';\n\n /** Type of column values */\n readonly valueType: string;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n}\n\n/**\n * Specification of a data column.\n *\n * Data column is a specialized type of PColumn that stores only simple values (strings and numbers)\n * addressed by multiple keys. This is in contrast to other PColumn variants that can store more complex\n * values like files or other abstract data types. Data columns are optimized for storing and processing\n * basic tabular data.\n */\nexport interface PDataColumnSpec extends PUniversalColumnSpec {\n /** Type of column values */\n readonly valueType: ValueType;\n}\n\n// @todo: change this to PUniversalColumnSpec\nexport type PColumnSpec = PDataColumnSpec;\n\n/** Unique PColumnSpec identifier */\nexport type PColumnSpecId = {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: 'PColumn';\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes id */\n readonly axesId: AxesId;\n};\n\nexport function getPColumnSpecId(spec: PColumnSpec): PColumnSpecId {\n return {\n kind: spec.kind,\n valueType: spec.valueType,\n name: spec.name,\n domain: spec.domain,\n parentAxes: spec.parentAxes,\n axesId: getAxesId(spec.axesSpec),\n };\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Get column id and spec from a column */\nexport function getColumnIdAndSpec<Data>(column: PColumn<Data>): PColumnIdAndSpec {\n return {\n columnId: column.id,\n spec: column.spec,\n };\n}\n\n/** Information returned by {@link PFrame.listColumns} method */\nexport interface PColumnInfo extends PColumnIdAndSpec {\n /** True if data was associated with this PColumn */\n readonly hasData: boolean;\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain } = spec;\n const result = { type, name };\n if (domain && Object.entries(domain).length > 0) {\n Object.assign(result, { domain });\n }\n return result;\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Canonicalizes axis id */\nexport function canonicalizeAxisId(id: AxisId): CanonicalizedJson<AxisId> {\n return canonicalizeJson(getAxisId(id));\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return query.name === target.name && matchDomain(query.domain, target.domain);\n}\n"],"names":["ValueType","readMetadata","metadata","key","readMetadataJsonOrThrow","metadataJson","methodNameInError","json","schema","value","error","ensureError","readMetadataJson","Annotation","AnnotationJson","z","readAnnotation","spec","readAnnotationJson","makeAxisTree","axis","getAxesTree","rootAxis","root","nodesQ","nextNodes","node","getArrayFromAxisTree","tree","res","parent","canonicalizeAxisWithParents","canonicalizeJson","getAxisId","normalizingAxesComparator","axis1","axis2","domain1","domain2","parents1","parents2","annotation1","annotation2","parseParentsFromAnnotations","parentsList","sortParentsDeep","axisSpec","hasCycleOfParents","ancestors","levelIds","child","childId","getNormalizedAxesList","axes","modifiedAxes","_","copiedRest","idx","modifiedAxis","parents","name","p","_a","PColumnName","type","domain","result"],"mappings":";;;AAiBO,MAAMA,IAAY;AAAA,EACvB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;;AAQH,SAAUC,EACdC,GACAC,GAAM;AAEN,SAAQD,KAAA,gBAAAA,EAA6BC,CAAAA;AACvC;AAOM,SAAUC,EACdF,GACAG,GACAF,GACAG,IAA4B,2BAAyB;AAErD,QAAMC,IAAON,EAAmBC,GAAUC,CAAG;AAC7C,MAAII,MAAS;AAAW;AAExB,QAAMC,IAASH,EAAaF,CAAG;AAC/B,MAAI;AACF,UAAMM,IAAQ,KAAK,MAAMF,CAAI;AAC7B,WAAOC,EAAO,MAAMC,CAAK;AAAA,EAC3B,SAASC,GAAgB;AACvB,UAAM,IAAI,MACR,GAAGJ,CAAiB,iBACV,OAAOH,CAAG,CAAC,YACTI,CAAI,YACJI,EAAYD,CAAK,CAAC,EAAE;AAAA,EAEpC;AACF;AAEgB,SAAAE,EACdV,GACAG,GAC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,EAAE,SAAS,KAC5C,OAAO,OAAOC,GAAQ,EAAE,QAAAD,EAAAA,CAAQ,GAE3BC;AACT;","x_google_ignoreList":[0]}
@@ -0,0 +1,18 @@
1
+ function t(r) {
2
+ if (typeof r == "string")
3
+ return `String value was thrown: ${r}`;
4
+ if (r && typeof r == "object")
5
+ try {
6
+ return `Plain object was thrown: ${JSON.stringify(r)}`;
7
+ } catch (n) {
8
+ return `Non-serializable object was thrown (JSON.stringify failed: ${n instanceof Error ? n.message : String(n)}): ${String(r)}`;
9
+ }
10
+ return `Non-Error value (${typeof r}) was thrown: ${r}`;
11
+ }
12
+ function e(r) {
13
+ return r instanceof Error ? r : new Error(t(r));
14
+ }
15
+ export {
16
+ e as ensureError
17
+ };
18
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":["../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@milaboratories/pl-model-common/src/errors.ts"],"sourcesContent":["/**\n * Just for convenience, usually it is an Error with name 'AbortError'\n */\nexport class AbortError extends Error {\n name = 'AbortError';\n}\n\n/**\n * Throw this to show a message without stack trace in UI\n */\nexport class UiError extends Error {\n name = 'UiError';\n}\n\nexport function isAbortError(error: unknown): error is Error & { name: 'AbortError' } {\n return error instanceof Error && error.name === 'AbortError';\n}\n\nexport function hasAbortError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return error.name === 'AbortError' || hasAbortError(error.cause);\n}\n\nexport function isAggregateError(error: unknown): error is AggregateError {\n return error instanceof Error && error.name === 'AggregateError';\n}\n\nexport class PFrameError extends Error {\n name = 'PFrameError';\n}\n\nexport function isPFrameError(error: unknown): error is PFrameError {\n return error instanceof Error && error.name === 'PFrameError';\n}\n\nexport class PFrameDriverError extends PFrameError {\n name = 'PFrameError.Driver';\n}\n\nexport function isPFrameDriverError(error: unknown): error is PFrameDriverError {\n return error instanceof Error && error.name === 'PFrameError.Driver';\n}\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === 'string') {\n return `String value was thrown: ${value}`;\n }\n\n if (value && typeof value === 'object') {\n try {\n return `Plain object was thrown: ${JSON.stringify(value)}`;\n } catch (jsonError) {\n const errorMessage = jsonError instanceof Error ? jsonError.message : String(jsonError);\n return `Non-serializable object was thrown (JSON.stringify failed: ${errorMessage}): ${String(value)}`;\n }\n }\n\n return String(`Non-Error value (${typeof value}) was thrown: ${value}`);\n}\n\nexport function ensureError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n\n return new Error(stringifyValue(value));\n}\n\n// Error serialization for IPC/network transmission (Error objects can't be JSON serialized)\n\nexport type SerializedError = {\n name: string;\n message: string;\n stack: string | undefined;\n cause?: SerializedError;\n};\n\nexport function deserializeError(obj: SerializedError): Error {\n const cause = obj.cause ? deserializeError(obj.cause) : undefined;\n\n const error = new Error(obj.message, cause !== undefined ? { cause } : undefined);\n error.name = obj.name || 'Error';\n error.stack = obj.stack;\n\n return error;\n}\n\nexport function serializeError(e: unknown): SerializedError {\n const error = ensureError(e);\n const cause = error.cause ? serializeError(error.cause) : undefined;\n\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...(error.cause !== undefined && { cause }),\n };\n}\n\nexport type ResultOrError<S, F = Error> = {\n value: S;\n error?: undefined;\n} | {\n error: F;\n};\n\nexport function unwrapResult<T>(result: ResultOrError<T, Error | SerializedError>): T {\n if (result.error) {\n throw result.error instanceof Error ? result.error : deserializeError(result.error);\n }\n return result.value;\n}\n\nexport function serializeResult<T>(result: ResultOrError<T>): ResultOrError<T, SerializedError> {\n if (result.error) {\n return { error: serializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function deserializeResult<T>(result: ResultOrError<T, SerializedError>): ResultOrError<T> {\n if (result.error) {\n return { error: deserializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function wrapCallback<T>(callback: () => T): ResultOrError<T> {\n try {\n const value = callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport async function wrapAsyncCallback<T>(callback: () => Promise<T>): Promise<ResultOrError<T>> {\n try {\n const value = await callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport function wrapAndSerialize<T>(callback: () => T): ResultOrError<T, SerializedError> {\n const result = wrapCallback(callback);\n return serializeResult(result);\n}\n\nexport async function wrapAndSerializeAsync<T>(callback: () => Promise<T>): Promise<ResultOrError<T, SerializedError>> {\n const result = await wrapAsyncCallback(callback);\n return serializeResult(result);\n}\n"],"names":["stringifyValue","value","jsonError","ensureError"],"mappings":"AA8CA,SAASA,EAAeC,GAAc;AACpC,MAAI,OAAOA,KAAU;AACnB,WAAO,4BAA4BA,CAAK;AAG1C,MAAIA,KAAS,OAAOA,KAAU;AAC5B,QAAI;AACF,aAAO,4BAA4B,KAAK,UAAUA,CAAK,CAAC;AAAA,IAC1D,SAASC,GAAW;AAElB,aAAO,8DADcA,aAAqB,QAAQA,EAAU,UAAU,OAAOA,CAAS,CACL,MAAM,OAAOD,CAAK,CAAC;AAAA,IACtG;AAGF,SAAc,oBAAoB,OAAOA,CAAK,iBAAiBA,CAAK;AACtE;AAEM,SAAUE,EAAYF,GAAc;AACxC,SAAIA,aAAiB,QACZA,IAGF,IAAI,MAAMD,EAAeC,CAAK,CAAC;AACxC;","x_google_ignoreList":[0]}
@@ -0,0 +1,12 @@
1
+ import r from "../../../../_virtual/canonicalize.js";
2
+ function e(n) {
3
+ return r(n);
4
+ }
5
+ function t(n) {
6
+ return JSON.parse(n);
7
+ }
8
+ export {
9
+ e as canonicalizeJson,
10
+ t as parseJson
11
+ };
12
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sources":["../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@milaboratories/pl-model-common/src/json.ts"],"sourcesContent":["import canonicalize from 'canonicalize';\n\ntype JsonPrimitive = string | number | boolean | null | undefined;\n\ntype JsonValue = JsonPrimitive | JsonValue[] | {\n [key: string]: JsonValue;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype NotAssignableToJson = bigint | symbol | Function;\n\nexport type JsonCompatible<T> = unknown extends T ? unknown : {\n [P in keyof T]:\n T[P] extends JsonValue ? T[P] :\n T[P] extends NotAssignableToJson ? never :\n JsonCompatible<T[P]>;\n};\n\nexport type StringifiedJson<T = unknown> = JsonCompatible<T> extends never ? never : string & {\n __json_stringified: T;\n};\n\nexport function stringifyJson<T>(value: JsonCompatible<T>): StringifiedJson<T> {\n return JSON.stringify(value)! as StringifiedJson<T>;\n}\n\nexport type CanonicalizedJson<T = unknown> = JsonCompatible<T> extends never ? never : string & {\n __json_canonicalized: T;\n};\n\nexport function canonicalizeJson<T>(value: JsonCompatible<T>): CanonicalizedJson<T> {\n return canonicalize(value)! as CanonicalizedJson<T>;\n}\n\nexport function parseJson<T>(value: StringifiedJson<T> | CanonicalizedJson<T>): T {\n return JSON.parse(value) as T;\n}\n"],"names":["canonicalizeJson","value","canonicalize","parseJson"],"mappings":";AA8BM,SAAUA,EAAoBC,GAAwB;AAC1D,SAAOC,EAAaD,CAAK;AAC3B;AAEM,SAAUE,EAAaF,GAAgD;AAC3E,SAAO,KAAK,MAAMA,CAAK;AACzB;","x_google_ignoreList":[0]}
@@ -0,0 +1,7 @@
1
+ import t from "../../../zod/lib/index.js";
2
+ const r = 24;
3
+ t.string().length(r).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
4
+ export {
5
+ r as PlIdLength
6
+ };
7
+ //# sourceMappingURL=plid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plid.js","sources":["../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@milaboratories/pl-model-common/src/plid.ts"],"sourcesContent":["import { z } from 'zod';\nimport { base32Encode } from './base32_encode';\n\n/** Number of raw bytes in the PlId. */\nexport const PlIdBytes = 15;\n/** Characters in string representation */\nexport const PlIdLength = 24; // = 15 bytes * 8 bits / 5 bits per char in base32\n\nexport const PlId = z\n .string()\n .length(PlIdLength)\n .regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/) // RFC4648\n .brand('PlId');\nexport type PlId = z.infer<typeof PlId>;\n\nexport function uniquePlId(): PlId {\n const data = new Uint8Array(PlIdBytes);\n crypto.getRandomValues(data);\n return PlId.parse(base32Encode(data, 'RFC4648'));\n}\n\nexport function plId(bytes: Uint8Array): PlId {\n if (bytes.length !== PlIdBytes) throw new Error(`Wrong number of bytes: ${bytes.length}`);\n return PlId.parse(base32Encode(bytes, 'RFC4648'));\n}\n\nexport async function digestPlId(data: string): Promise<PlId> {\n const encoder = new TextEncoder();\n const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(data));\n return plId(new Uint8Array(bytes.slice(0, 15)));\n}\n"],"names":["PlIdLength","z"],"mappings":";AAMa,MAAAA,IAAa;AAENC,EACjB,OAAA,EACA,OAAOD,CAAU,EACjB,MAAM,oCAAoC,EAC1C,MAAM,MAAM;","x_google_ignoreList":[0]}
@@ -0,0 +1,8 @@
1
+ import e from "../../../zod/lib/index.js";
2
+ e.object({
3
+ __isRef: e.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
4
+ blockId: e.string().describe("Upstream block id"),
5
+ name: e.string().describe("Name of the output provided to the upstream block's output context"),
6
+ requireEnrichments: e.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
7
+ }).describe("Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees.").readonly();
8
+ //# sourceMappingURL=ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.js","sources":["../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@milaboratories/pl-model-common/src/ref.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string()\n .describe('Upstream block id'),\n name: z.string()\n .describe('Name of the output provided to the upstream block\\'s output context'),\n requireEnrichments: z.literal(true).optional()\n .describe('True if current block that stores this reference in its args, may need enrichments '\n + 'for the references value originating from the blocks in between current and referenced block'),\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that '\n + '{@link __isRef} is present and equal to true, internal logic relies on this marker '\n + 'to build block dependency trees.',\n )\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/**\n * Type guard to check if a value is a PlRef.\n *\n * @param value - The value to check.\n * @returns True if the value is a PlRef, false otherwise.\n */\nexport function isPlRef(value: unknown): value is PlRef {\n return (\n typeof value === 'object'\n && value !== null\n && '__isRef' in value\n && (value as { __isRef: unknown }).__isRef === true\n && 'blockId' in value\n && 'name' in value\n );\n}\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/**\n * Creates a PlRef with the given blockId and name.\n *\n * @param blockId - The blockId of the reference.\n * @param name - The name of the reference.\n * @param requireEnrichments - Whether the reference requires enrichments.\n */\nexport function createPlRef(blockId: string, name: string, requireEnrichments: boolean = false) {\n if (requireEnrichments)\n return {\n __isRef: true,\n blockId,\n name,\n requireEnrichments: true,\n };\n else\n return {\n __isRef: true,\n blockId,\n name,\n };\n}\n\n/**\n * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the\n * requireEnrichments property.\n *\n * @param ref - The original PlRef object.\n * @param requireEnrichments - If true, the `requireEnrichments: true` property is added\n * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.\n * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.\n */\nexport function withEnrichments(ref: PlRef, requireEnrichments: boolean = true): PlRef {\n if (requireEnrichments)\n return {\n ...ref,\n requireEnrichments: true,\n };\n else {\n const { requireEnrichments: _, ...rest } = ref;\n return rest;\n }\n}\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments: boolean = false) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);\n}\n"],"names":["z"],"mappings":";AAEqBA,EAClB,OAAO;AAAA,EACN,SAASA,EACN,QAAQ,EAAI,EACZ,SAAS,6DAA6D;AAAA,EACzE,SAASA,EAAE,SACR,SAAS,mBAAmB;AAAA,EAC/B,MAAMA,EAAE,SACL,SAAS,oEAAqE;AAAA,EACjF,oBAAoBA,EAAE,QAAQ,EAAI,EAAE,SAAA,EACjC,SAAS,iLACwF;AACrG,CAAA,EACA,SACC,qMAEoC,EAErC,SAAA;","x_google_ignoreList":[0]}
@@ -0,0 +1,13 @@
1
+ import "../../../../@milaboratories/pl-model-common/dist/drivers/blob.js";
2
+ import { PColumnName as m } from "../../../../@milaboratories/pl-model-common/dist/drivers/pframe/spec/spec.js";
3
+ import "../../../../../_virtual/canonicalize.js";
4
+ import "../../../../@milaboratories/pl-model-common/dist/plid.js";
5
+ import "../../../../@milaboratories/pl-model-common/dist/ref.js";
6
+ import "../render/util/label.js";
7
+ function n(o) {
8
+ return o.axesSpec.length === 1 && o.name === m.Label;
9
+ }
10
+ export {
11
+ n as isLabelColumn
12
+ };
13
+ //# sourceMappingURL=PlDataTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlDataTable.js","sources":["../../../../../../../../../../node_modules/@milaboratories/pf-plots/node_modules/@platforma-sdk/model/src/components/PlDataTable.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpec,\n CanonicalizedJson,\n DataInfo,\n ListOptionBase,\n PColumn,\n PColumnIdAndSpec,\n PColumnSpec,\n PColumnValues,\n PObjectId,\n PTableColumnId,\n PTableColumnIdAxis,\n PTableColumnIdColumn,\n PTableColumnSpec,\n PTableDef,\n PTableHandle,\n PTableRecordFilter,\n PTableRecordSingleValueFilterV2,\n PTableSorting,\n} from '@milaboratories/pl-model-common';\nimport {\n Annotation,\n canonicalizeJson,\n getAxisId,\n getColumnIdAndSpec,\n matchAxisId,\n PColumnName,\n readAnnotation,\n} from '@milaboratories/pl-model-common';\nimport type {\n AxisLabelProvider,\n ColumnProvider,\n PColumnDataUniversal,\n RenderCtx,\n} from '../render';\nimport {\n PColumnCollection,\n TreeNodeAccessor,\n} from '../render';\nimport { isLinkerColumn } from './PFrameForGraphs';\n\nexport type PlTableColumnId = {\n /** Original column spec */\n source: PTableColumnSpec;\n /** Column spec with labeled axes replaced by label columns */\n labeled: PTableColumnSpec;\n};\n\nexport type PlTableColumnIdJson = CanonicalizedJson<PlTableColumnId>;\n\nexport type PlDataTableGridStateCore = {\n /** Includes column ordering */\n columnOrder?: {\n /** All colIds in order */\n orderedColIds: PlTableColumnIdJson[];\n };\n /** Includes current sort columns and direction */\n sort?: {\n /** Sorted columns and directions in order */\n sortModel: {\n /** Column Id to apply the sort to. */\n colId: PlTableColumnIdJson;\n /** Sort direction */\n sort: 'asc' | 'desc';\n }[];\n };\n /** Includes column visibility */\n columnVisibility?: {\n /** All colIds which were hidden */\n hiddenColIds: PlTableColumnIdJson[];\n };\n};\n\nexport type PlDataTableSheet = {\n /** spec of the axis to use */\n axis: AxisSpec;\n /** options to show in the filter dropdown */\n options: ListOptionBase<string | number>[];\n /** default (selected) value */\n defaultValue?: string | number;\n};\n\nexport type PlDataTableSheetState = {\n /** id of the axis */\n axisId: AxisId;\n /** selected value */\n value: string | number;\n};\n\n/**\n * PlDataTableV2 persisted state\n */\nexport type PlDataTableStateV2 =\n // Old versions of the state\n | {\n // no version\n gridState: {\n columnOrder?: {\n orderedColIds: CanonicalizedJson<PTableColumnSpec>[];\n };\n sort?: {\n sortModel: {\n colId: CanonicalizedJson<PTableColumnSpec>;\n sort: 'asc' | 'desc';\n }[];\n };\n columnVisibility?: {\n hiddenColIds: CanonicalizedJson<PTableColumnSpec>[];\n };\n sourceId?: string;\n sheets?: Record<CanonicalizedJson<AxisId>, string | number>;\n };\n pTableParams?: {\n sorting?: PTableSorting[];\n filters?: PTableRecordFilter[];\n };\n }\n | {\n version: 2;\n stateCache: {\n sourceId: string;\n gridState: {\n columnOrder?: {\n orderedColIds: CanonicalizedJson<PTableColumnSpec>[];\n };\n sort?: {\n sortModel: {\n colId: CanonicalizedJson<PTableColumnSpec>;\n sort: 'asc' | 'desc';\n }[];\n };\n columnVisibility?: {\n hiddenColIds: CanonicalizedJson<PTableColumnSpec>[];\n };\n };\n sheetsState: PlDataTableSheetState[];\n }[];\n pTableParams: {\n hiddenColIds: PObjectId[] | null;\n filters: PTableRecordFilter[];\n sorting: PTableSorting[];\n };\n }\n | {\n version: 3;\n stateCache: {\n sourceId: string;\n gridState: {\n columnOrder?: {\n orderedColIds: CanonicalizedJson<PTableColumnSpec>[];\n };\n sort?: {\n sortModel: {\n colId: CanonicalizedJson<PTableColumnSpec>;\n sort: 'asc' | 'desc';\n }[];\n };\n columnVisibility?: {\n hiddenColIds: CanonicalizedJson<PTableColumnSpec>[];\n };\n };\n sheetsState: PlDataTableSheetState[];\n filtersState: PlDataTableFilterState[];\n }[];\n pTableParams: PTableParamsV2;\n }\n // Normalized state\n | PlDataTableStateV2Normalized;\n\nexport type PlDataTableStateV2CacheEntry = {\n /** DataSource identifier for state management */\n sourceId: string;\n /** Internal ag-grid state */\n gridState: PlDataTableGridStateCore;\n /** Sheets state */\n sheetsState: PlDataTableSheetState[];\n /** Filters state */\n filtersState: PlDataTableFilterState[];\n};\n\nexport type PTableParamsV2 =\n | {\n sourceId: null;\n hiddenColIds: null;\n partitionFilters: [];\n filters: [];\n sorting: [];\n }\n | {\n sourceId: string;\n hiddenColIds: PObjectId[] | null;\n partitionFilters: PTableRecordFilter[];\n filters: PTableRecordFilter[];\n sorting: PTableSorting[];\n };\n\nexport type PlDataTableStateV2Normalized = {\n /** Version for upgrades */\n version: 4;\n /** Internal states, LRU cache for 5 sourceId-s */\n stateCache: PlDataTableStateV2CacheEntry[];\n /** PTable params derived from the cache state for the current sourceId */\n pTableParams: PTableParamsV2;\n};\n\nexport function makeDefaultPTableParams(): PTableParamsV2 {\n return {\n sourceId: null,\n hiddenColIds: null,\n partitionFilters: [],\n filters: [],\n sorting: [],\n };\n}\n\n/** Create default PlDataTableStateV2 */\nexport function createPlDataTableStateV2(): PlDataTableStateV2Normalized {\n return {\n version: 4,\n stateCache: [],\n pTableParams: makeDefaultPTableParams(),\n };\n}\n\n/** Upgrade PlDataTableStateV2 to the latest version */\nexport function upgradePlDataTableStateV2(state: PlDataTableStateV2): PlDataTableStateV2Normalized {\n // v1 -> v2\n if (!('version' in state)) {\n // Non upgradeable as sourceId calculation algorithm has changed, resetting state to default\n state = createPlDataTableStateV2();\n }\n // v2 -> v3\n if (state.version === 2) {\n state = {\n version: 3,\n stateCache: state.stateCache.map((entry) => ({\n ...entry,\n filtersState: [],\n })),\n pTableParams: makeDefaultPTableParams(),\n };\n }\n // v3 -> v4\n if (state.version === 3) {\n // Non upgradeable as column ids calculation algorithm has changed, resetting state to default\n state = createPlDataTableStateV2();\n }\n return state;\n}\n\nexport type PlDataTableFilterState = {\n id: PTableColumnId;\n alphabetic: boolean;\n filter: null | {\n value: PlTableFilter;\n disabled: boolean;\n };\n};\n\n/** PlTableFilters filter entry */\nexport type PlTableFilterIsNotNA = {\n /** Predicate type */\n type: 'isNotNA';\n};\n\n/** PlTableFilters filter entry */\nexport type PlTableFilterIsNA = {\n /** Predicate type */\n type: 'isNA';\n};\n\n/** PlTableFilters filter entries applicable to both string and number values */\nexport type PlTableFilterCommon = PlTableFilterIsNotNA | PlTableFilterIsNA;\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberEquals = {\n /** Predicate type */\n type: 'number_equals';\n /** Referense value */\n reference: number;\n};\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberNotEquals = {\n /** Predicate type */\n type: 'number_notEquals';\n /** Referense value */\n reference: number;\n};\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberGreaterThan = {\n /** Predicate type */\n type: 'number_greaterThan';\n /** Referense value */\n reference: number;\n};\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberGreaterThanOrEqualTo = {\n /** Predicate type */\n type: 'number_greaterThanOrEqualTo';\n /** Referense value */\n reference: number;\n};\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberLessThan = {\n /** Predicate type */\n type: 'number_lessThan';\n /** Referense value */\n reference: number;\n};\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberLessThanOrEqualTo = {\n /** Predicate type */\n type: 'number_lessThanOrEqualTo';\n /** Referense value */\n reference: number;\n};\n\n/** PlTableFilters numeric filter entry */\nexport type PlTableFilterNumberBetween = {\n /** Predicate type */\n type: 'number_between';\n /** Referense value for the lower bound */\n lowerBound: number;\n /** Defines whether values equal to lower bound reference value should be matched */\n includeLowerBound: boolean;\n /** Referense value for the upper bound */\n upperBound: number;\n /** Defines whether values equal to upper bound reference value should be matched */\n includeUpperBound: boolean;\n};\n\n/** All PlTableFilters numeric filter entries */\nexport type PlTableFilterNumber =\n | PlTableFilterCommon\n | PlTableFilterNumberEquals\n | PlTableFilterNumberNotEquals\n | PlTableFilterNumberGreaterThan\n | PlTableFilterNumberGreaterThanOrEqualTo\n | PlTableFilterNumberLessThan\n | PlTableFilterNumberLessThanOrEqualTo\n | PlTableFilterNumberBetween;\n/** All types of PlTableFilters numeric filter entries */\nexport type PlTableFilterNumberType = PlTableFilterNumber['type'];\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringEquals = {\n /** Predicate type */\n type: 'string_equals';\n /** Referense value */\n reference: string;\n};\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringNotEquals = {\n /** Predicate type */\n type: 'string_notEquals';\n /** Referense value */\n reference: string;\n};\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringContains = {\n /** Predicate type */\n type: 'string_contains';\n /** Referense value */\n reference: string;\n};\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringDoesNotContain = {\n /** Predicate type */\n type: 'string_doesNotContain';\n /** Referense value */\n reference: string;\n};\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringMatches = {\n /** Predicate type */\n type: 'string_matches';\n /** Referense value */\n reference: string;\n};\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringDoesNotMatch = {\n /** Predicate type */\n type: 'string_doesNotMatch';\n /** Referense value */\n reference: string;\n};\n\n/** PlTableFilters string filter entry */\nexport type PlTableFilterStringContainsFuzzyMatch = {\n /** Predicate type */\n type: 'string_containsFuzzyMatch';\n /** Referense value */\n reference: string;\n /**\n * Maximum acceptable edit distance between reference value and matched substring\n * @see https://en.wikipedia.org/wiki/Edit_distance\n */\n maxEdits: number;\n /**\n * When {@link substitutionsOnly} is set to false\n * Levenshtein distance is used as edit distance (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used as edit distance (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n substitutionsOnly: boolean;\n /**\n * Single character in {@link reference} that will labelColumn any\n * single character in searched text.\n */\n wildcard?: string;\n};\n\n/** All PlTableFilters string filter entries */\nexport type PlTableFilterString =\n | PlTableFilterCommon\n | PlTableFilterStringEquals\n | PlTableFilterStringNotEquals\n | PlTableFilterStringContains\n | PlTableFilterStringDoesNotContain\n | PlTableFilterStringMatches\n | PlTableFilterStringDoesNotMatch\n | PlTableFilterStringContainsFuzzyMatch;\n/** All types of PlTableFilters string filter entries */\nexport type PlTableFilterStringType = PlTableFilterString['type'];\n\n/** All PlTableFilters filter entries */\nexport type PlTableFilter = PlTableFilterNumber | PlTableFilterString;\n/** All types of PlTableFilters filter entries */\nexport type PlTableFilterType = PlTableFilter['type'];\n\nexport type CreatePlDataTableOps = {\n /** Filters for columns and non-partitioned axes */\n filters?: PTableRecordFilter[];\n\n /** Sorting to columns hidden from user */\n sorting?: PTableSorting[];\n\n /**\n * Selects columns for which will be inner-joined to the table.\n *\n * Default behaviour: all columns are considered to be core\n */\n coreColumnPredicate?: (spec: PColumnSpec) => boolean;\n\n /**\n * Determines how core columns should be joined together:\n * inner - so user will only see records present in all core columns\n * full - so user will only see records present in any of the core columns\n *\n * All non-core columns will be left joined to the table produced by the core\n * columns, in other words records form the pool of non-core columns will only\n * make their way into the final table if core table contins corresponding key.\n *\n * Default: 'full'\n */\n coreJoinType?: 'inner' | 'full';\n};\n\n/** Check if column is a label column */\nexport function isLabelColumn(column: PColumnSpec) {\n return column.axesSpec.length === 1 && column.name === PColumnName.Label;\n}\n\n/** Get all label columns from the result pool */\nexport function getAllLabelColumns(\n resultPool: AxisLabelProvider & ColumnProvider,\n): PColumn<PColumnDataUniversal>[] | undefined {\n return new PColumnCollection()\n .addAxisLabelProvider(resultPool)\n .addColumnProvider(resultPool)\n .getColumns({\n name: PColumnName.Label,\n axes: [{}], // exactly one axis\n }, { dontWaitAllData: true });\n}\n\n/** Get label columns matching the provided columns from the result pool */\nexport function getMatchingLabelColumns(\n columns: PColumnIdAndSpec[],\n allLabelColumns: PColumn<PColumnDataUniversal>[],\n): PColumn<PColumnDataUniversal>[] {\n // split input columns into label and value columns\n const inputLabelColumns: typeof columns = [];\n const inputValueColumns: typeof columns = [];\n for (const column of columns) {\n if (isLabelColumn(column.spec)) {\n inputLabelColumns.push(column);\n } else {\n inputValueColumns.push(column);\n }\n }\n\n // collect distinct axes of value columns\n const unlabeledAxes: AxisId[] = [];\n for (const column of inputValueColumns) {\n for (const axis of column.spec.axesSpec) {\n const axisId = getAxisId(axis);\n if (!unlabeledAxes.some((id) => matchAxisId(id, axisId))) {\n unlabeledAxes.push(axisId);\n }\n }\n }\n\n // remove axes matched by input label columns\n for (const labelColumn of inputLabelColumns) {\n const labelAxisId = getAxisId(labelColumn.spec.axesSpec[0]);\n const labelMatch = unlabeledAxes.findIndex((axisId) => matchAxisId(axisId, labelAxisId));\n if (labelMatch !== -1) {\n unlabeledAxes.splice(labelMatch, 1);\n }\n }\n\n // warning: changing this id will break backward compatibility\n const colId = (id: PObjectId, domain?: Record<string, string>): PObjectId => {\n let wid = id.toString();\n if (domain) {\n for (const k in domain) {\n wid += k;\n wid += domain[k];\n }\n }\n return wid as PObjectId;\n };\n\n // search label columns for unmatched axes\n const labelColumns: typeof allLabelColumns = [];\n for (const labelColumn of allLabelColumns) {\n const labelAxis = labelColumn.spec.axesSpec[0];\n const labelAxisId = getAxisId(labelAxis);\n const labelMatch = unlabeledAxes.findIndex((axisId) => matchAxisId(axisId, labelAxisId));\n if (labelMatch !== -1) {\n const axisId = unlabeledAxes[labelMatch];\n const dataDomainLen = Object.keys(axisId.domain ?? {}).length;\n const labelDomainLen = Object.keys(labelAxis.domain ?? {}).length;\n if (dataDomainLen > labelDomainLen) {\n labelColumns.push({\n id: colId(labelColumn.id, axisId.domain),\n spec: {\n ...labelColumn.spec,\n axesSpec: [{ ...axisId, annotations: labelAxis.annotations }],\n },\n data: labelColumn.data,\n });\n } else {\n labelColumns.push(labelColumn);\n }\n unlabeledAxes.splice(labelMatch, 1);\n }\n }\n return labelColumns;\n}\n\n/** Check if all columns are computed */\nexport function allColumnsComputed(\n columns: PColumn<PColumnValues | TreeNodeAccessor | DataInfo<TreeNodeAccessor>>[],\n): boolean {\n type Data = typeof columns[number]['data'];\n const isValues = (d: Data): d is PColumnValues => Array.isArray(d);\n const isAccessor = (d: Data): d is TreeNodeAccessor => d instanceof TreeNodeAccessor;\n const isDataInfo = (d: Data): d is DataInfo<TreeNodeAccessor> =>\n typeof d === 'object' && 'type' in d;\n\n return columns\n .map((c) => c.data)\n .every((d): boolean => {\n if (isValues(d)) {\n return true;\n } else if (isAccessor(d)) {\n return d.getIsReadyOrError();\n } else if (isDataInfo(d)) {\n const type = d.type;\n switch (type) {\n case 'Json':\n return true;\n case 'JsonPartitioned':\n return Object.values(d.parts).every((p) => p.getIsReadyOrError());\n case 'BinaryPartitioned':\n return Object.values(d.parts)\n .every((p) => p.index.getIsReadyOrError() && p.values.getIsReadyOrError());\n case 'ParquetPartitioned':\n return Object.values(d.parts)\n .every((p) => p.getIsReadyOrError());\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw Error(`unsupported column data type: ${d satisfies never}`);\n }\n });\n}\n\nfunction createPTableDef(params: {\n columns: PColumn<PColumnDataUniversal>[];\n labelColumns: PColumn<PColumnDataUniversal>[];\n coreJoinType: 'inner' | 'full';\n partitionFilters: PTableRecordSingleValueFilterV2[];\n filters: PTableRecordSingleValueFilterV2[];\n sorting: PTableSorting[];\n coreColumnPredicate?: ((spec: PColumnSpec) => boolean);\n}): PTableDef<PColumn<TreeNodeAccessor | PColumnValues | DataInfo<TreeNodeAccessor>>> {\n let coreColumns = params.columns;\n const secondaryColumns: typeof params.columns = [];\n\n if (params.coreColumnPredicate) {\n coreColumns = [];\n for (const c of params.columns)\n if (params.coreColumnPredicate(c.spec)) coreColumns.push(c);\n else secondaryColumns.push(c);\n }\n\n secondaryColumns.push(...params.labelColumns);\n\n return {\n src: {\n type: 'outer',\n primary: {\n type: params.coreJoinType,\n entries: coreColumns.map((c) => ({ type: 'column', column: c })),\n },\n secondary: secondaryColumns.map((c) => ({ type: 'column', column: c })),\n },\n partitionFilters: params.partitionFilters,\n filters: params.filters,\n sorting: params.sorting,\n };\n}\n\n/** PlAgDataTable model */\nexport type PlDataTableModel = {\n /** DataSource identifier for state management */\n sourceId: string | null;\n /** p-table including all columns, used to show the full specification of the table */\n fullTableHandle: PTableHandle;\n /** p-table including only visible columns, used to get the data */\n visibleTableHandle: PTableHandle;\n};\n\n/** Check if column should be omitted from the table */\nexport function isColumnHidden(spec: { annotations?: Annotation }): boolean {\n return readAnnotation(spec, Annotation.Table.Visibility) === 'hidden';\n}\n\n/** Check if column is hidden by default */\nexport function isColumnOptional(spec: { annotations?: Annotation }): boolean {\n return readAnnotation(spec, Annotation.Table.Visibility) === 'optional';\n}\n\n/**\n * Return unique entries of the array by the provided id\n * For each id, the last entry is kept\n */\nexport function uniqueBy<T>(array: T[], makeId: (entry: T) => string): T[] {\n return [...new Map(array.map((e) => [makeId(e), e])).values()];\n}\n\n/**\n * Create p-table spec and handle given ui table state\n *\n * @param ctx context\n * @param columns column list\n * @param tableState table ui state\n * @returns PlAgDataTableV2 table source\n */\nexport function createPlDataTableV2<A, U>(\n ctx: RenderCtx<A, U>,\n inputColumns: PColumn<TreeNodeAccessor | PColumnValues | DataInfo<TreeNodeAccessor>>[],\n tableState: PlDataTableStateV2,\n ops?: CreatePlDataTableOps,\n): PlDataTableModel | undefined {\n if (inputColumns.length === 0) return undefined;\n const columns = inputColumns.filter((c) => isLinkerColumn(c.spec) || !isColumnHidden(c.spec));\n\n const tableStateNormalized = upgradePlDataTableStateV2(tableState);\n\n const allLabelColumns = getAllLabelColumns(ctx.resultPool);\n if (!allLabelColumns) return undefined;\n\n const fullLabelColumns = getMatchingLabelColumns(columns.map(getColumnIdAndSpec), allLabelColumns);\n const fullColumns = [...columns, ...fullLabelColumns];\n\n const fullColumnsAxes = uniqueBy(\n [...fullColumns.flatMap((c) => c.spec.axesSpec.map((a) => getAxisId(a)))],\n (a) => canonicalizeJson<AxisId>(a),\n );\n const fullColumnsIds: PTableColumnId[] = [\n ...fullColumnsAxes.map((a) => ({ type: 'axis', id: a } satisfies PTableColumnIdAxis)),\n ...fullColumns.map((c) => ({ type: 'column', id: c.id } satisfies PTableColumnIdColumn)),\n ];\n const fullColumnsIdsSet = new Set(fullColumnsIds.map((c) => canonicalizeJson<PTableColumnId>(c)));\n const isValidColumnId = (id: PTableColumnId): boolean => fullColumnsIdsSet.has(canonicalizeJson<PTableColumnId>(id));\n\n const coreJoinType = ops?.coreJoinType ?? 'full';\n const partitionFilters: PTableRecordSingleValueFilterV2[]\n = tableStateNormalized.pTableParams.partitionFilters\n .filter((f) => {\n const valid = isValidColumnId(f.column);\n if (!valid) ctx.logWarn(`Partition filter ${JSON.stringify(f)} does not match provided columns, skipping`);\n return valid;\n });\n const filters: PTableRecordSingleValueFilterV2[]\n = uniqueBy(\n [...(ops?.filters ?? []), ...tableStateNormalized.pTableParams.filters],\n (f) => canonicalizeJson<PTableColumnId>(f.column),\n ).filter((f) => {\n const valid = isValidColumnId(f.column);\n if (!valid) ctx.logWarn(`Filter ${JSON.stringify(f)} does not match provided columns, skipping`);\n return valid;\n });\n const sorting: PTableSorting[]\n = uniqueBy(\n [...(ops?.sorting ?? []), ...tableStateNormalized.pTableParams.sorting],\n (s) => canonicalizeJson<PTableColumnId>(s.column),\n ).filter((s) => {\n const valid = isValidColumnId(s.column);\n if (!valid) ctx.logWarn(`Sorting ${JSON.stringify(s)} does not match provided columns, skipping`);\n return valid;\n });\n\n const fullDef = createPTableDef({\n columns,\n labelColumns: fullLabelColumns,\n coreJoinType,\n partitionFilters,\n filters,\n sorting,\n coreColumnPredicate: ops?.coreColumnPredicate,\n });\n const fullHandle = ctx.createPTable(fullDef);\n\n const hiddenColumns = new Set<PObjectId>(((): PObjectId[] => {\n // Inner join works as a filter - all columns must be present\n if (coreJoinType === 'inner') return [];\n\n const hiddenColIds = tableStateNormalized.pTableParams.hiddenColIds;\n if (hiddenColIds) return hiddenColIds;\n\n return columns\n .filter((c) => isColumnOptional(c.spec))\n .map((c) => c.id);\n })());\n\n // Preserve linker columns\n columns\n .filter((c) => isLinkerColumn(c.spec))\n .forEach((c) => hiddenColumns.delete(c.id));\n\n // Preserve core columns as they change the shape of join.\n if (ops?.coreColumnPredicate) {\n const coreColumns = columns.flatMap((c) => ops?.coreColumnPredicate?.(c.spec) ? [c.id] : []);\n coreColumns.forEach((c) => hiddenColumns.delete(c));\n }\n\n // Filters decrease the number of result rows, sorting changes the order of result rows\n [...partitionFilters.map((f) => f.column), ...filters.map((f) => f.column), ...sorting.map((s) => s.column)]\n .filter((c): c is PTableColumnIdColumn => c.type === 'column')\n .forEach((c) => hiddenColumns.delete(c.id));\n\n const visibleColumns = columns.filter((c) => !hiddenColumns.has(c.id));\n const visibleLabelColumns = getMatchingLabelColumns(visibleColumns.map(getColumnIdAndSpec), allLabelColumns);\n\n // if at least one column is not yet computed, we can't show the table\n if (!allColumnsComputed([...visibleColumns, ...visibleLabelColumns])) return undefined;\n\n const visibleDef = createPTableDef({\n columns: visibleColumns,\n labelColumns: visibleLabelColumns,\n coreJoinType,\n partitionFilters,\n filters,\n sorting,\n coreColumnPredicate: ops?.coreColumnPredicate,\n });\n const visibleHandle = ctx.createPTable(visibleDef);\n\n return {\n sourceId: tableStateNormalized.pTableParams.sourceId,\n fullTableHandle: fullHandle,\n visibleTableHandle: visibleHandle,\n } satisfies PlDataTableModel;\n}\n\n/** Create sheet entries for PlDataTable */\nexport function createPlDataTableSheet<A, U>(\n ctx: RenderCtx<A, U>,\n axis: AxisSpec,\n values: (string | number)[],\n): PlDataTableSheet {\n const labels = ctx.resultPool.findLabels(axis);\n return {\n axis,\n options: values.map((v) => ({\n value: v,\n label: labels?.[v] ?? v.toString(),\n })),\n defaultValue: values[0],\n };\n}\n"],"names":["isLabelColumn","column","PColumnName"],"mappings":";;;;;;AAwdM,SAAUA,EAAcC,GAAmB;AAC/C,SAAOA,EAAO,SAAS,WAAW,KAAKA,EAAO,SAASC,EAAY;AACrE;","x_google_ignoreList":[0]}