@platforma-sdk/model 1.48.12 → 1.48.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/bconfig/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC;AAG/C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,YAAY,EAAE,GACzD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GACxD,KAAK,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/bconfig/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC;AAE/C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,YAAY,EAAE,GACzD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GACxD,KAAK,CAAC"}
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var plModelCommon = require('@milaboratories/pl-model-common');
4
- require('canonicalize');
5
- var column_collection = require('../render/util/column_collection.cjs');
6
- require('../render/util/label.cjs');
4
+ var columns = require('../pframe_utils/columns.cjs');
7
5
 
8
6
  /** Create id for column copy with added keys in axes domains */
9
7
  const colId = (id, domains) => {
@@ -141,70 +139,9 @@ function createPFrameForGraphs(ctx, blockColumns) {
141
139
  const suitableSpec = (spec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);
142
140
  // if current block doesn't produce own columns then use all columns from result pool
143
141
  if (!blockColumns) {
144
- const columns = new column_collection.PColumnCollection();
145
- columns.addColumnProvider(ctx.resultPool);
146
- const allColumns = columns.getUniversalEntries(suitableSpec, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
147
- const allAxes = new Map(allColumns
148
- .flatMap((column) => plModelCommon.getNormalizedAxesList(column.spec.axesSpec))
149
- .map((axisSpec) => {
150
- const axisId = plModelCommon.getAxisId(axisSpec);
151
- return [plModelCommon.canonicalizeJson(axisId), axisSpec];
152
- }));
153
- // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
154
- const extendedColumns = enrichCompatible(allAxes, allColumns);
155
- return ctx.createPFrame(extendedColumns);
142
+ return ctx.createPFrame(columns.getAllRelatedColumns(ctx, suitableSpec));
156
143
  }
157
- // if current block has its own columns then take from result pool only compatible with them
158
- const columns = new column_collection.PColumnCollection();
159
- columns.addColumnProvider(ctx.resultPool);
160
- columns.addColumns(blockColumns);
161
- // all possible axes from block columns
162
- const blockAxes = new Map();
163
- // axes from block columns and compatible result pool columns
164
- const allAxes = new Map();
165
- for (const c of blockColumns) {
166
- for (const spec of plModelCommon.getNormalizedAxesList(c.spec.axesSpec)) {
167
- const aid = plModelCommon.getAxisId(spec);
168
- blockAxes.set(plModelCommon.canonicalizeJson(aid), spec);
169
- allAxes.set(plModelCommon.canonicalizeJson(aid), spec);
170
- }
171
- }
172
- // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
173
- const linkerColumns = columns.getUniversalEntries((spec) => suitableSpec(spec) && plModelCommon.isLinkerColumn(spec)) ?? [];
174
- const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
175
- // all possible axes from connected linkers
176
- for (const item of availableWithLinkersAxes) {
177
- blockAxes.set(...item);
178
- allAxes.set(...item);
179
- }
180
- const blockAxesArr = Array.from(blockAxes.values());
181
- // all compatible with block columns but without label columns
182
- let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {
183
- const axisId = plModelCommon.getAxisId(axisSpec);
184
- return blockAxesArr.some((selectorAxisSpec) => plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId));
185
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !plModelCommon.isLabelColumn(column.spec));
186
- // extend axes set for label columns request
187
- for (const c of compatibleWithoutLabels) {
188
- for (const spec of plModelCommon.getNormalizedAxesList(c.spec.axesSpec)) {
189
- const aid = plModelCommon.getAxisId(spec);
190
- allAxes.set(plModelCommon.canonicalizeJson(aid), spec);
191
- }
192
- }
193
- const allAxesArr = Array.from(allAxes.values());
194
- // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)
195
- compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.every((axisSpec) => {
196
- const axisId = plModelCommon.getAxisId(axisSpec);
197
- return allAxesArr.some((selectorAxisSpec) => plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId));
198
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !plModelCommon.isLabelColumn(column.spec));
199
- // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
200
- const compatibleLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {
201
- const axisId = plModelCommon.getAxisId(axisSpec);
202
- return allAxesArr.some((selectorAxisSpec) => plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId));
203
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => plModelCommon.isLabelColumn(column.spec));
204
- const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
205
- // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
206
- const extendedColumns = enrichCompatible(blockAxes, compatible);
207
- return ctx.createPFrame(extendedColumns);
144
+ return ctx.createPFrame(columns.getRelatedColumns(ctx, { columns: blockColumns, predicate: suitableSpec }));
208
145
  }
209
146
 
210
147
  exports.createPFrameForGraphs = createPFrameForGraphs;
@@ -1 +1 @@
1
- {"version":3,"file":"PFrameForGraphs.cjs","sources":["../../src/components/PFrameForGraphs.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpecNormalized,\n CanonicalizedJson,\n PColumn,\n PColumnSpec,\n PFrameHandle,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n Annotation,\n canonicalizeJson,\n getAxisId,\n getColumnIdAndSpec,\n getNormalizedAxesList,\n isLabelColumn,\n isLinkerColumn,\n LinkerMap,\n matchAxisId,\n readAnnotation,\n readAnnotationJson,\n stringifyJson,\n} from '@milaboratories/pl-model-common';\nimport type { PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, RenderCtx } from '../render';\nimport { PColumnCollection } from '../render';\n\n/** Create id for column copy with added keys in axes domains */\nconst colId = (id: PObjectId, domains: (Record<string, string> | undefined)[]) => {\n let wid = id.toString();\n domains?.forEach((domain) => {\n if (domain) {\n for (const [k, v] of Object.entries(domain)) {\n wid += k;\n wid += v;\n }\n }\n });\n return wid;\n};\n\n/** All combinations with 1 key from each list */\nfunction getKeysCombinations(idsLists: AxisId[][]) {\n if (!idsLists.length) {\n return [];\n }\n let result: AxisId[][] = [[]];\n idsLists.forEach((list) => {\n const nextResult: AxisId[][] = [];\n list.forEach((key) => {\n nextResult.push(...result.map((resultItem) => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\nexport function isHiddenFromGraphColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromGraphs);\n}\n\nexport function isHiddenFromUIColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromUi);\n}\n\ntype AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;\n\nexport function getAvailableWithLinkersAxes(\n linkerColumns: (PColumnEntryWithLabel | PColumnEntryUniversal)[],\n blockAxes: AxesVault,\n): AxesVault {\n const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));\n const availableAxes = linkerMap.getReachableByLinkersAxesFromAxesNormalized(\n [...blockAxes.values()],\n (linkerKeyId, sourceAxisId) => matchAxisId(sourceAxisId, linkerKeyId),\n );\n\n return new Map(availableAxes.map((axisSpec) => {\n const id = getAxisId(axisSpec);\n return [canonicalizeJson(id), axisSpec];\n }));\n}\n/** Add columns with fully compatible axes created from partial compatible ones */\nexport function enrichCompatible<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(blockAxes: AxesVault, columns: T[]): T[] {\n return columns.flatMap((column) => getAdditionalColumnsForColumn(blockAxes, column));\n}\n\nfunction getAdditionalColumnsForColumn<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(\n blockAxes: AxesVault,\n column: T,\n): T[] {\n const columnAxesIds = column.spec.axesSpec.map(getAxisId);\n\n if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) {\n return [column]; // the column is compatible with its own domains without modifications\n }\n\n // options with different possible domains for every axis of secondary column\n const secondaryIdsOptions = columnAxesIds.map((id) => {\n const result = [];\n for (const [_, mainId] of blockAxes) {\n if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) {\n result.push(mainId);\n }\n }\n return result;\n });\n // all possible combinations of axes with added domains\n const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);\n\n // sets of added to column domain fields\n const allAddedDomainValues = new Set<string>();\n const addedNotToAllVariantsDomainValues = new Set<string>();\n const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {\n const addedSet = new Set<string>();\n idsList.map((axisId, idx) => {\n const d1 = column.spec.axesSpec[idx].domain;\n const d2 = axisId.domain;\n Object.entries(d2 ?? {}).forEach(([key, value]) => {\n if (d1?.[key] === undefined) {\n const item = JSON.stringify([key, value]);\n addedSet.add(item);\n allAddedDomainValues.add(item);\n }\n });\n return ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n });\n });\n return addedSet;\n });\n [...allAddedDomainValues].forEach((addedPart) => {\n if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {\n addedNotToAllVariantsDomainValues.add(addedPart);\n }\n });\n\n const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {\n const id = colId(column.id, idsList.map((id) => id.domain));\n\n const label = readAnnotation(column.spec, Annotation.Label) ?? '';\n const labelDomainPart = ([...addedByVariantsDomainValues[idx]])\n .filter((str) => addedNotToAllVariantsDomainValues.has(str))\n .sort()\n .map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants\n .join(' / ');\n\n const annotations: Annotation = {\n ...column.spec.annotations,\n [Annotation.Graph.IsVirtual]: stringifyJson(true),\n };\n if (label || labelDomainPart) {\n annotations[Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;\n }\n\n return {\n ...column,\n id: id as PObjectId,\n spec: {\n ...column.spec,\n axesSpec: idsList.map((axisId, idx) => ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n })),\n annotations,\n },\n };\n });\n\n return [column, ...additionalColumns];\n}\n\n/**\n The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool\n (including linker columns and all label columns).\n Block’s columns are added to pframe as is.\n Other columns are added basing on set of axes of block’s columns, considering available with linker columns.\n Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from\n result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values\n among existing ones).\n In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case\n of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)\n and modified label (with added domain values in case if more than one copy with different domains exist).\n */\nexport function createPFrameForGraphs<A, U>(\n ctx: RenderCtx<A, U>,\n blockColumns?: PColumn<PColumnDataUniversal>[],\n): PFrameHandle | undefined {\n const suitableSpec = (spec: PColumnSpec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);\n // if current block doesn't produce own columns then use all columns from result pool\n if (!blockColumns) {\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n const allColumns = columns.getUniversalEntries(suitableSpec, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return ctx.createPFrame(extendedColumns);\n };\n\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(blockColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of blockColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getUniversalEntries((spec) => suitableSpec(spec) && isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n const blockAxesArr = Array.from(blockAxes.values());\n // all compatible with block columns but without label columns\n let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n const allAxesArr = Array.from(allAxes.values());\n // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)\n compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.every((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return ctx.createPFrame(extendedColumns);\n}\n"],"names":["readAnnotationJson","Annotation","LinkerMap","getColumnIdAndSpec","matchAxisId","getAxisId","canonicalizeJson","readAnnotation","stringifyJson","PColumnCollection","getNormalizedAxesList","isLinkerColumn","isLabelColumn"],"mappings":";;;;;;;AA0BA;AACA,MAAM,KAAK,GAAG,CAAC,EAAa,EAAE,OAA+C,KAAI;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,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,CAACO,2BAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;IAGrH,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACpH,QAAA,MAAM,MAAM,GAAGP,uBAAS,CAAC,QAAQ,CAAC;AAClC,QAAA,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAKD,yBAAW,CAACC,uBAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAKO,2BAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpH,MAAM,UAAU,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,CAAC;;IAGpE,MAAM,eAAe,GAAG,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC;AAE/D,IAAA,OAAO,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC;AAC1C;;;;;;;;"}
1
+ {"version":3,"file":"PFrameForGraphs.cjs","sources":["../../src/components/PFrameForGraphs.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpecNormalized,\n CanonicalizedJson,\n PColumn,\n PColumnSpec,\n PFrameHandle,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n Annotation,\n canonicalizeJson,\n getAxisId,\n getColumnIdAndSpec, LinkerMap,\n matchAxisId,\n readAnnotation,\n readAnnotationJson,\n stringifyJson,\n} from '@milaboratories/pl-model-common';\nimport type { PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, RenderCtx } from '../render';\nimport { getAllRelatedColumns, getRelatedColumns } from '../pframe_utils/columns';\n\n/** Create id for column copy with added keys in axes domains */\nconst colId = (id: PObjectId, domains: (Record<string, string> | undefined)[]) => {\n let wid = id.toString();\n domains?.forEach((domain) => {\n if (domain) {\n for (const [k, v] of Object.entries(domain)) {\n wid += k;\n wid += v;\n }\n }\n });\n return wid;\n};\n\n/** All combinations with 1 key from each list */\nfunction getKeysCombinations(idsLists: AxisId[][]) {\n if (!idsLists.length) {\n return [];\n }\n let result: AxisId[][] = [[]];\n idsLists.forEach((list) => {\n const nextResult: AxisId[][] = [];\n list.forEach((key) => {\n nextResult.push(...result.map((resultItem) => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\nexport function isHiddenFromGraphColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromGraphs);\n}\n\nexport function isHiddenFromUIColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromUi);\n}\n\nexport type AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;\n\nexport function getAvailableWithLinkersAxes(\n linkerColumns: (PColumnEntryWithLabel | PColumnEntryUniversal)[],\n blockAxes: AxesVault,\n): AxesVault {\n const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));\n const availableAxes = linkerMap.getReachableByLinkersAxesFromAxesNormalized(\n [...blockAxes.values()],\n (linkerKeyId, sourceAxisId) => matchAxisId(sourceAxisId, linkerKeyId),\n );\n\n return new Map(availableAxes.map((axisSpec) => {\n const id = getAxisId(axisSpec);\n return [canonicalizeJson(id), axisSpec];\n }));\n}\n/** Add columns with fully compatible axes created from partial compatible ones */\nexport function enrichCompatible<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(blockAxes: AxesVault, columns: T[]): T[] {\n return columns.flatMap((column) => getAdditionalColumnsForColumn(blockAxes, column));\n}\n\nfunction getAdditionalColumnsForColumn<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(\n blockAxes: AxesVault,\n column: T,\n): T[] {\n const columnAxesIds = column.spec.axesSpec.map(getAxisId);\n\n if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) {\n return [column]; // the column is compatible with its own domains without modifications\n }\n\n // options with different possible domains for every axis of secondary column\n const secondaryIdsOptions = columnAxesIds.map((id) => {\n const result = [];\n for (const [_, mainId] of blockAxes) {\n if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) {\n result.push(mainId);\n }\n }\n return result;\n });\n // all possible combinations of axes with added domains\n const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);\n\n // sets of added to column domain fields\n const allAddedDomainValues = new Set<string>();\n const addedNotToAllVariantsDomainValues = new Set<string>();\n const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {\n const addedSet = new Set<string>();\n idsList.map((axisId, idx) => {\n const d1 = column.spec.axesSpec[idx].domain;\n const d2 = axisId.domain;\n Object.entries(d2 ?? {}).forEach(([key, value]) => {\n if (d1?.[key] === undefined) {\n const item = JSON.stringify([key, value]);\n addedSet.add(item);\n allAddedDomainValues.add(item);\n }\n });\n return ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n });\n });\n return addedSet;\n });\n [...allAddedDomainValues].forEach((addedPart) => {\n if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {\n addedNotToAllVariantsDomainValues.add(addedPart);\n }\n });\n\n const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {\n const id = colId(column.id, idsList.map((id) => id.domain));\n\n const label = readAnnotation(column.spec, Annotation.Label) ?? '';\n const labelDomainPart = ([...addedByVariantsDomainValues[idx]])\n .filter((str) => addedNotToAllVariantsDomainValues.has(str))\n .sort()\n .map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants\n .join(' / ');\n\n const annotations: Annotation = {\n ...column.spec.annotations,\n [Annotation.Graph.IsVirtual]: stringifyJson(true),\n };\n if (label || labelDomainPart) {\n annotations[Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;\n }\n\n return {\n ...column,\n id: id as PObjectId,\n spec: {\n ...column.spec,\n axesSpec: idsList.map((axisId, idx) => ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n })),\n annotations,\n },\n };\n });\n\n return [column, ...additionalColumns];\n}\n\n/**\n The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool\n (including linker columns and all label columns).\n Block’s columns are added to pframe as is.\n Other columns are added basing on set of axes of block’s columns, considering available with linker columns.\n Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from\n result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values\n among existing ones).\n In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case\n of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)\n and modified label (with added domain values in case if more than one copy with different domains exist).\n */\nexport function createPFrameForGraphs<A, U>(\n ctx: RenderCtx<A, U>,\n blockColumns?: PColumn<PColumnDataUniversal>[],\n): PFrameHandle | undefined {\n const suitableSpec = (spec: PColumnSpec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);\n // if current block doesn't produce own columns then use all columns from result pool\n if (!blockColumns) {\n return ctx.createPFrame(getAllRelatedColumns(ctx, suitableSpec));\n };\n\n return ctx.createPFrame(getRelatedColumns(ctx, { columns: blockColumns, predicate: suitableSpec }));\n}\n"],"names":["readAnnotationJson","Annotation","LinkerMap","getColumnIdAndSpec","matchAxisId","getAxisId","canonicalizeJson","readAnnotation","stringifyJson","getAllRelatedColumns","getRelatedColumns"],"mappings":";;;;;AAsBA;AACA,MAAM,KAAK,GAAG,CAAC,EAAa,EAAE,OAA+C,KAAI;AAC/E,IAAA,IAAI,GAAG,GAAG,EAAE,CAAC,QAAQ,EAAE;AACvB,IAAA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AG,MAAM,CAAC,IAAI;AACd,gBAAA,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM;AACtC,oBAAA,GAAG,MAAM;oBACT,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW;AACnD,iBAAA,CAAC,CAAC;gBACH,WAAW;AACZ,aAAA;SACF;AACH,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC;AACvC;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,qBAAqB,CACnC,GAAoB,EACpB,YAA8C,EAAA;AAE9C,IAAA,MAAM,YAAY,GAAG,CAAC,IAAiB,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC;;IAEzG,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,GAAG,CAAC,YAAY,CAACQ,4BAAoB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClE;AAEA,IAAA,OAAO,GAAG,CAAC,YAAY,CAACC,yBAAiB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;AACrG;;;;;;;;"}
@@ -2,7 +2,7 @@ import type { AxisId, AxisSpecNormalized, CanonicalizedJson, PColumn, PColumnSpe
2
2
  import type { PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, RenderCtx } from '../render';
3
3
  export declare function isHiddenFromGraphColumn(column: PColumnSpec): boolean;
4
4
  export declare function isHiddenFromUIColumn(column: PColumnSpec): boolean;
5
- type AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;
5
+ export type AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;
6
6
  export declare function getAvailableWithLinkersAxes(linkerColumns: (PColumnEntryWithLabel | PColumnEntryUniversal)[], blockAxes: AxesVault): AxesVault;
7
7
  /** Add columns with fully compatible axes created from partial compatible ones */
8
8
  export declare function enrichCompatible<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(blockAxes: AxesVault, columns: T[]): T[];
@@ -19,5 +19,4 @@ export declare function enrichCompatible<T extends Omit<PColumn<PColumnDataUnive
19
19
  and modified label (with added domain values in case if more than one copy with different domains exist).
20
20
  */
21
21
  export declare function createPFrameForGraphs<A, U>(ctx: RenderCtx<A, U>, blockColumns?: PColumn<PColumnDataUniversal>[]): PFrameHandle | undefined;
22
- export {};
23
22
  //# sourceMappingURL=PFrameForGraphs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PFrameForGraphs.d.ts","sourceRoot":"","sources":["../../src/components/PFrameForGraphs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,YAAY,EAEb,MAAM,iCAAiC,CAAC;AAezC,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAiC/G,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAEpE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAEjE;AAED,KAAK,SAAS,GAAG,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAEpE,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,EAAE,EAChE,SAAS,EAAE,SAAS,GACnB,SAAS,CAWX;AACD,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE/H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B,CAAC,EAAE,GAC7C,YAAY,GAAG,SAAS,CAQ1B"}
@@ -1,7 +1,5 @@
1
- import { readAnnotationJson, Annotation, LinkerMap, getColumnIdAndSpec, matchAxisId, getAxisId, canonicalizeJson, getNormalizedAxesList, isLinkerColumn, isLabelColumn, readAnnotation, stringifyJson } from '@milaboratories/pl-model-common';
2
- import 'canonicalize';
3
- import { PColumnCollection } from '../render/util/column_collection.js';
4
- import '../render/util/label.js';
1
+ import { readAnnotationJson, Annotation, LinkerMap, getColumnIdAndSpec, matchAxisId, getAxisId, canonicalizeJson, readAnnotation, stringifyJson } from '@milaboratories/pl-model-common';
2
+ import { getAllRelatedColumns, getRelatedColumns } from '../pframe_utils/columns.js';
5
3
 
6
4
  /** Create id for column copy with added keys in axes domains */
7
5
  const colId = (id, domains) => {
@@ -139,70 +137,9 @@ function createPFrameForGraphs(ctx, blockColumns) {
139
137
  const suitableSpec = (spec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);
140
138
  // if current block doesn't produce own columns then use all columns from result pool
141
139
  if (!blockColumns) {
142
- const columns = new PColumnCollection();
143
- columns.addColumnProvider(ctx.resultPool);
144
- const allColumns = columns.getUniversalEntries(suitableSpec, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
145
- const allAxes = new Map(allColumns
146
- .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))
147
- .map((axisSpec) => {
148
- const axisId = getAxisId(axisSpec);
149
- return [canonicalizeJson(axisId), axisSpec];
150
- }));
151
- // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
152
- const extendedColumns = enrichCompatible(allAxes, allColumns);
153
- return ctx.createPFrame(extendedColumns);
140
+ return ctx.createPFrame(getAllRelatedColumns(ctx, suitableSpec));
154
141
  }
155
- // if current block has its own columns then take from result pool only compatible with them
156
- const columns = new PColumnCollection();
157
- columns.addColumnProvider(ctx.resultPool);
158
- columns.addColumns(blockColumns);
159
- // all possible axes from block columns
160
- const blockAxes = new Map();
161
- // axes from block columns and compatible result pool columns
162
- const allAxes = new Map();
163
- for (const c of blockColumns) {
164
- for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
165
- const aid = getAxisId(spec);
166
- blockAxes.set(canonicalizeJson(aid), spec);
167
- allAxes.set(canonicalizeJson(aid), spec);
168
- }
169
- }
170
- // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
171
- const linkerColumns = columns.getUniversalEntries((spec) => suitableSpec(spec) && isLinkerColumn(spec)) ?? [];
172
- const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
173
- // all possible axes from connected linkers
174
- for (const item of availableWithLinkersAxes) {
175
- blockAxes.set(...item);
176
- allAxes.set(...item);
177
- }
178
- const blockAxesArr = Array.from(blockAxes.values());
179
- // all compatible with block columns but without label columns
180
- let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {
181
- const axisId = getAxisId(axisSpec);
182
- return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
183
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
184
- // extend axes set for label columns request
185
- for (const c of compatibleWithoutLabels) {
186
- for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
187
- const aid = getAxisId(spec);
188
- allAxes.set(canonicalizeJson(aid), spec);
189
- }
190
- }
191
- const allAxesArr = Array.from(allAxes.values());
192
- // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)
193
- compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.every((axisSpec) => {
194
- const axisId = getAxisId(axisSpec);
195
- return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
196
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
197
- // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
198
- const compatibleLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {
199
- const axisId = getAxisId(axisSpec);
200
- return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
201
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));
202
- const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
203
- // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
204
- const extendedColumns = enrichCompatible(blockAxes, compatible);
205
- return ctx.createPFrame(extendedColumns);
142
+ return ctx.createPFrame(getRelatedColumns(ctx, { columns: blockColumns, predicate: suitableSpec }));
206
143
  }
207
144
 
208
145
  export { createPFrameForGraphs, enrichCompatible, getAvailableWithLinkersAxes, isHiddenFromGraphColumn, isHiddenFromUIColumn };
@@ -1 +1 @@
1
- {"version":3,"file":"PFrameForGraphs.js","sources":["../../src/components/PFrameForGraphs.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpecNormalized,\n CanonicalizedJson,\n PColumn,\n PColumnSpec,\n PFrameHandle,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n Annotation,\n canonicalizeJson,\n getAxisId,\n getColumnIdAndSpec,\n getNormalizedAxesList,\n isLabelColumn,\n isLinkerColumn,\n LinkerMap,\n matchAxisId,\n readAnnotation,\n readAnnotationJson,\n stringifyJson,\n} from '@milaboratories/pl-model-common';\nimport type { PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, RenderCtx } from '../render';\nimport { PColumnCollection } from '../render';\n\n/** Create id for column copy with added keys in axes domains */\nconst colId = (id: PObjectId, domains: (Record<string, string> | undefined)[]) => {\n let wid = id.toString();\n domains?.forEach((domain) => {\n if (domain) {\n for (const [k, v] of Object.entries(domain)) {\n wid += k;\n wid += v;\n }\n }\n });\n return wid;\n};\n\n/** All combinations with 1 key from each list */\nfunction getKeysCombinations(idsLists: AxisId[][]) {\n if (!idsLists.length) {\n return [];\n }\n let result: AxisId[][] = [[]];\n idsLists.forEach((list) => {\n const nextResult: AxisId[][] = [];\n list.forEach((key) => {\n nextResult.push(...result.map((resultItem) => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\nexport function isHiddenFromGraphColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromGraphs);\n}\n\nexport function isHiddenFromUIColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromUi);\n}\n\ntype AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;\n\nexport function getAvailableWithLinkersAxes(\n linkerColumns: (PColumnEntryWithLabel | PColumnEntryUniversal)[],\n blockAxes: AxesVault,\n): AxesVault {\n const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));\n const availableAxes = linkerMap.getReachableByLinkersAxesFromAxesNormalized(\n [...blockAxes.values()],\n (linkerKeyId, sourceAxisId) => matchAxisId(sourceAxisId, linkerKeyId),\n );\n\n return new Map(availableAxes.map((axisSpec) => {\n const id = getAxisId(axisSpec);\n return [canonicalizeJson(id), axisSpec];\n }));\n}\n/** Add columns with fully compatible axes created from partial compatible ones */\nexport function enrichCompatible<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(blockAxes: AxesVault, columns: T[]): T[] {\n return columns.flatMap((column) => getAdditionalColumnsForColumn(blockAxes, column));\n}\n\nfunction getAdditionalColumnsForColumn<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(\n blockAxes: AxesVault,\n column: T,\n): T[] {\n const columnAxesIds = column.spec.axesSpec.map(getAxisId);\n\n if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) {\n return [column]; // the column is compatible with its own domains without modifications\n }\n\n // options with different possible domains for every axis of secondary column\n const secondaryIdsOptions = columnAxesIds.map((id) => {\n const result = [];\n for (const [_, mainId] of blockAxes) {\n if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) {\n result.push(mainId);\n }\n }\n return result;\n });\n // all possible combinations of axes with added domains\n const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);\n\n // sets of added to column domain fields\n const allAddedDomainValues = new Set<string>();\n const addedNotToAllVariantsDomainValues = new Set<string>();\n const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {\n const addedSet = new Set<string>();\n idsList.map((axisId, idx) => {\n const d1 = column.spec.axesSpec[idx].domain;\n const d2 = axisId.domain;\n Object.entries(d2 ?? {}).forEach(([key, value]) => {\n if (d1?.[key] === undefined) {\n const item = JSON.stringify([key, value]);\n addedSet.add(item);\n allAddedDomainValues.add(item);\n }\n });\n return ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n });\n });\n return addedSet;\n });\n [...allAddedDomainValues].forEach((addedPart) => {\n if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {\n addedNotToAllVariantsDomainValues.add(addedPart);\n }\n });\n\n const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {\n const id = colId(column.id, idsList.map((id) => id.domain));\n\n const label = readAnnotation(column.spec, Annotation.Label) ?? '';\n const labelDomainPart = ([...addedByVariantsDomainValues[idx]])\n .filter((str) => addedNotToAllVariantsDomainValues.has(str))\n .sort()\n .map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants\n .join(' / ');\n\n const annotations: Annotation = {\n ...column.spec.annotations,\n [Annotation.Graph.IsVirtual]: stringifyJson(true),\n };\n if (label || labelDomainPart) {\n annotations[Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;\n }\n\n return {\n ...column,\n id: id as PObjectId,\n spec: {\n ...column.spec,\n axesSpec: idsList.map((axisId, idx) => ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n })),\n annotations,\n },\n };\n });\n\n return [column, ...additionalColumns];\n}\n\n/**\n The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool\n (including linker columns and all label columns).\n Block’s columns are added to pframe as is.\n Other columns are added basing on set of axes of block’s columns, considering available with linker columns.\n Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from\n result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values\n among existing ones).\n In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case\n of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)\n and modified label (with added domain values in case if more than one copy with different domains exist).\n */\nexport function createPFrameForGraphs<A, U>(\n ctx: RenderCtx<A, U>,\n blockColumns?: PColumn<PColumnDataUniversal>[],\n): PFrameHandle | undefined {\n const suitableSpec = (spec: PColumnSpec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);\n // if current block doesn't produce own columns then use all columns from result pool\n if (!blockColumns) {\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n const allColumns = columns.getUniversalEntries(suitableSpec, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return ctx.createPFrame(extendedColumns);\n };\n\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(blockColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of blockColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getUniversalEntries((spec) => suitableSpec(spec) && isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n const blockAxesArr = Array.from(blockAxes.values());\n // all compatible with block columns but without label columns\n let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n const allAxesArr = Array.from(allAxes.values());\n // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)\n compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.every((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return ctx.createPFrame(extendedColumns);\n}\n"],"names":[],"mappings":";;;;;AA0BA;AACA,MAAM,KAAK,GAAG,CAAC,EAAa,EAAE,OAA+C,KAAI;AAC/E,IAAA,IAAI,GAAG,GAAG,EAAE,CAAC,QAAQ,EAAE;AACvB,IAAA,OAAO,EAAE,OAAO,CAAC,CAAC,MAAM,KAAI;QAC1B,IAAI,MAAM,EAAE;AACV,YAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBAC3C,GAAG,IAAI,CAAC;gBACR,GAAG,IAAI,CAAC;YACV;QACF;AACF,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,GAAG;AACZ,CAAC;AAED;AACA,SAAS,mBAAmB,CAAC,QAAoB,EAAA;AAC/C,IAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;AACpB,QAAA,OAAO,EAAE;IACX;AACA,IAAA,IAAI,MAAM,GAAe,CAAC,EAAE,CAAC;AAC7B,IAAA,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;QACxB,MAAM,UAAU,GAAe,EAAE;AACjC,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;YACnB,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,KAAK,CAAC,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;AACtE,QAAA,CAAC,CAAC;QACF,MAAM,GAAG,UAAU;AACrB,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,MAAM;AACf;AAEM,SAAU,uBAAuB,CAAC,MAAmB,EAAA;IACzD,OAAO,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,kBAAkB,CAAC;AACpE;AAEM,SAAU,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,GAAG,SAAS,CAAC,QAAQ,CAAC;AAClC,QAAA,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAK,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;IAGrH,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACpH,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;AAClC,QAAA,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAK,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpH,MAAM,UAAU,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,CAAC;;IAGpE,MAAM,eAAe,GAAG,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC;AAE/D,IAAA,OAAO,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC;AAC1C;;;;"}
1
+ {"version":3,"file":"PFrameForGraphs.js","sources":["../../src/components/PFrameForGraphs.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpecNormalized,\n CanonicalizedJson,\n PColumn,\n PColumnSpec,\n PFrameHandle,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n Annotation,\n canonicalizeJson,\n getAxisId,\n getColumnIdAndSpec, LinkerMap,\n matchAxisId,\n readAnnotation,\n readAnnotationJson,\n stringifyJson,\n} from '@milaboratories/pl-model-common';\nimport type { PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, RenderCtx } from '../render';\nimport { getAllRelatedColumns, getRelatedColumns } from '../pframe_utils/columns';\n\n/** Create id for column copy with added keys in axes domains */\nconst colId = (id: PObjectId, domains: (Record<string, string> | undefined)[]) => {\n let wid = id.toString();\n domains?.forEach((domain) => {\n if (domain) {\n for (const [k, v] of Object.entries(domain)) {\n wid += k;\n wid += v;\n }\n }\n });\n return wid;\n};\n\n/** All combinations with 1 key from each list */\nfunction getKeysCombinations(idsLists: AxisId[][]) {\n if (!idsLists.length) {\n return [];\n }\n let result: AxisId[][] = [[]];\n idsLists.forEach((list) => {\n const nextResult: AxisId[][] = [];\n list.forEach((key) => {\n nextResult.push(...result.map((resultItem) => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\nexport function isHiddenFromGraphColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromGraphs);\n}\n\nexport function isHiddenFromUIColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.HideDataFromUi);\n}\n\nexport type AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;\n\nexport function getAvailableWithLinkersAxes(\n linkerColumns: (PColumnEntryWithLabel | PColumnEntryUniversal)[],\n blockAxes: AxesVault,\n): AxesVault {\n const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));\n const availableAxes = linkerMap.getReachableByLinkersAxesFromAxesNormalized(\n [...blockAxes.values()],\n (linkerKeyId, sourceAxisId) => matchAxisId(sourceAxisId, linkerKeyId),\n );\n\n return new Map(availableAxes.map((axisSpec) => {\n const id = getAxisId(axisSpec);\n return [canonicalizeJson(id), axisSpec];\n }));\n}\n/** Add columns with fully compatible axes created from partial compatible ones */\nexport function enrichCompatible<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(blockAxes: AxesVault, columns: T[]): T[] {\n return columns.flatMap((column) => getAdditionalColumnsForColumn(blockAxes, column));\n}\n\nfunction getAdditionalColumnsForColumn<T extends Omit<PColumn<PColumnDataUniversal>, 'data'>>(\n blockAxes: AxesVault,\n column: T,\n): T[] {\n const columnAxesIds = column.spec.axesSpec.map(getAxisId);\n\n if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) {\n return [column]; // the column is compatible with its own domains without modifications\n }\n\n // options with different possible domains for every axis of secondary column\n const secondaryIdsOptions = columnAxesIds.map((id) => {\n const result = [];\n for (const [_, mainId] of blockAxes) {\n if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) {\n result.push(mainId);\n }\n }\n return result;\n });\n // all possible combinations of axes with added domains\n const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);\n\n // sets of added to column domain fields\n const allAddedDomainValues = new Set<string>();\n const addedNotToAllVariantsDomainValues = new Set<string>();\n const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {\n const addedSet = new Set<string>();\n idsList.map((axisId, idx) => {\n const d1 = column.spec.axesSpec[idx].domain;\n const d2 = axisId.domain;\n Object.entries(d2 ?? {}).forEach(([key, value]) => {\n if (d1?.[key] === undefined) {\n const item = JSON.stringify([key, value]);\n addedSet.add(item);\n allAddedDomainValues.add(item);\n }\n });\n return ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n });\n });\n return addedSet;\n });\n [...allAddedDomainValues].forEach((addedPart) => {\n if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {\n addedNotToAllVariantsDomainValues.add(addedPart);\n }\n });\n\n const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {\n const id = colId(column.id, idsList.map((id) => id.domain));\n\n const label = readAnnotation(column.spec, Annotation.Label) ?? '';\n const labelDomainPart = ([...addedByVariantsDomainValues[idx]])\n .filter((str) => addedNotToAllVariantsDomainValues.has(str))\n .sort()\n .map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants\n .join(' / ');\n\n const annotations: Annotation = {\n ...column.spec.annotations,\n [Annotation.Graph.IsVirtual]: stringifyJson(true),\n };\n if (label || labelDomainPart) {\n annotations[Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;\n }\n\n return {\n ...column,\n id: id as PObjectId,\n spec: {\n ...column.spec,\n axesSpec: idsList.map((axisId, idx) => ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n })),\n annotations,\n },\n };\n });\n\n return [column, ...additionalColumns];\n}\n\n/**\n The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool\n (including linker columns and all label columns).\n Block’s columns are added to pframe as is.\n Other columns are added basing on set of axes of block’s columns, considering available with linker columns.\n Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from\n result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values\n among existing ones).\n In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case\n of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)\n and modified label (with added domain values in case if more than one copy with different domains exist).\n */\nexport function createPFrameForGraphs<A, U>(\n ctx: RenderCtx<A, U>,\n blockColumns?: PColumn<PColumnDataUniversal>[],\n): PFrameHandle | undefined {\n const suitableSpec = (spec: PColumnSpec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);\n // if current block doesn't produce own columns then use all columns from result pool\n if (!blockColumns) {\n return ctx.createPFrame(getAllRelatedColumns(ctx, suitableSpec));\n };\n\n return ctx.createPFrame(getRelatedColumns(ctx, { columns: blockColumns, predicate: suitableSpec }));\n}\n"],"names":[],"mappings":";;;AAsBA;AACA,MAAM,KAAK,GAAG,CAAC,EAAa,EAAE,OAA+C,KAAI;AAC/E,IAAA,IAAI,GAAG,GAAG,EAAE,CAAC,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,MAAM,CAAC,IAAI;AACd,gBAAA,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM;AACtC,oBAAA,GAAG,MAAM;oBACT,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW;AACnD,iBAAA,CAAC,CAAC;gBACH,WAAW;AACZ,aAAA;SACF;AACH,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC;AACvC;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,qBAAqB,CACnC,GAAoB,EACpB,YAA8C,EAAA;AAE9C,IAAA,MAAM,YAAY,GAAG,CAAC,IAAiB,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC;;IAEzG,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,GAAG,CAAC,YAAY,CAAC,oBAAoB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClE;AAEA,IAAA,OAAO,GAAG,CAAC,YAAY,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;AACrG;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.48.12";
3
+ var version = "1.48.13";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- var version = "1.48.12";
1
+ var version = "1.48.13";
2
2
 
3
3
  export { version };
4
4
  //# sourceMappingURL=package.json.js.map
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var plModelCommon = require('@milaboratories/pl-model-common');
4
+ var PFrameForGraphs = require('../components/PFrameForGraphs.cjs');
5
+ require('canonicalize');
6
+ var column_collection = require('../render/util/column_collection.cjs');
7
+ require('../render/util/label.cjs');
8
+
9
+ function getAllRelatedColumns(ctx, predicate) {
10
+ // if current block doesn't produce own columns then use all columns from result pool
11
+ const columns = new column_collection.PColumnCollection();
12
+ columns.addColumnProvider(ctx.resultPool);
13
+ const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
14
+ const allAxes = new Map(allColumns
15
+ .flatMap((column) => plModelCommon.getNormalizedAxesList(column.spec.axesSpec))
16
+ .map((axisSpec) => {
17
+ const axisId = plModelCommon.getAxisId(axisSpec);
18
+ return [plModelCommon.canonicalizeJson(axisId), axisSpec];
19
+ }));
20
+ // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
21
+ const extendedColumns = PFrameForGraphs.enrichCompatible(allAxes, allColumns);
22
+ return extendedColumns;
23
+ }
24
+ function getRelatedColumns(ctx, { columns: rootColumns, predicate }) {
25
+ // if current block has its own columns then take from result pool only compatible with them
26
+ const columns = new column_collection.PColumnCollection();
27
+ columns.addColumnProvider(ctx.resultPool);
28
+ columns.addColumns(rootColumns);
29
+ // all possible axes from block columns
30
+ const blockAxes = new Map();
31
+ // axes from block columns and compatible result pool columns
32
+ const allAxes = new Map();
33
+ for (const c of rootColumns) {
34
+ for (const spec of plModelCommon.getNormalizedAxesList(c.spec.axesSpec)) {
35
+ const aid = plModelCommon.getAxisId(spec);
36
+ blockAxes.set(plModelCommon.canonicalizeJson(aid), spec);
37
+ allAxes.set(plModelCommon.canonicalizeJson(aid), spec);
38
+ }
39
+ }
40
+ // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
41
+ const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && plModelCommon.isLinkerColumn(spec)) ?? [];
42
+ const availableWithLinkersAxes = PFrameForGraphs.getAvailableWithLinkersAxes(linkerColumns, blockAxes);
43
+ // all possible axes from connected linkers
44
+ for (const item of availableWithLinkersAxes) {
45
+ blockAxes.set(...item);
46
+ allAxes.set(...item);
47
+ }
48
+ const blockAxesArr = Array.from(blockAxes.values());
49
+ // all compatible with block columns but without label columns
50
+ let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
51
+ const axisId = plModelCommon.getAxisId(axisSpec);
52
+ return blockAxesArr.some((selectorAxisSpec) => plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId));
53
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !plModelCommon.isLabelColumn(column.spec));
54
+ // extend axes set for label columns request
55
+ for (const c of compatibleWithoutLabels) {
56
+ for (const spec of plModelCommon.getNormalizedAxesList(c.spec.axesSpec)) {
57
+ const aid = plModelCommon.getAxisId(spec);
58
+ allAxes.set(plModelCommon.canonicalizeJson(aid), spec);
59
+ }
60
+ }
61
+ const allAxesArr = Array.from(allAxes.values());
62
+ // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)
63
+ compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {
64
+ const axisId = plModelCommon.getAxisId(axisSpec);
65
+ return allAxesArr.some((selectorAxisSpec) => plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId));
66
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !plModelCommon.isLabelColumn(column.spec));
67
+ // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
68
+ const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
69
+ const axisId = plModelCommon.getAxisId(axisSpec);
70
+ return allAxesArr.some((selectorAxisSpec) => plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId));
71
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => plModelCommon.isLabelColumn(column.spec));
72
+ const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
73
+ // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
74
+ const extendedColumns = PFrameForGraphs.enrichCompatible(blockAxes, compatible);
75
+ return extendedColumns;
76
+ }
77
+
78
+ exports.getAllRelatedColumns = getAllRelatedColumns;
79
+ exports.getRelatedColumns = getRelatedColumns;
80
+ //# sourceMappingURL=columns.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.cjs","sources":["../../src/pframe_utils/columns.ts"],"sourcesContent":["import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratories/pl-model-common';\nimport { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';\nimport type { AxesVault } from '../components';\nimport { enrichCompatible, getAvailableWithLinkersAxes } from '../components';\nimport type { RenderCtx, PColumnDataUniversal } from '../render';\nimport { PColumnCollection } from '../render';\n\nexport function getAllRelatedColumns<A, U>(\n ctx: RenderCtx<A, U>, predicate: (spec: PColumnSpec) => boolean,\n): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block doesn't produce own columns then use all columns from result pool\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return extendedColumns;\n}\n\nexport function getRelatedColumns<A, U>(ctx: RenderCtx<A, U>, { columns: rootColumns, predicate }: {\n columns: PColumn<PColumnDataUniversal>[];\n predicate: (spec: PColumnSpec) => boolean;\n}): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(rootColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of rootColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n const blockAxesArr = Array.from(blockAxes.values());\n // all compatible with block columns but without label columns\n let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n const allAxesArr = Array.from(allAxes.values());\n // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)\n compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return extendedColumns;\n}\n"],"names":["PColumnCollection","getNormalizedAxesList","getAxisId","canonicalizeJson","enrichCompatible","isLinkerColumn","getAvailableWithLinkersAxes","matchAxisId","isLabelColumn"],"mappings":";;;;;;;;AAOM,SAAU,oBAAoB,CAClC,GAAoB,EAAE,SAAyC,EAAA;;AAG/D,IAAA,MAAM,OAAO,GAAG,IAAIA,mCAAiB,EAAE;AACvC,IAAA,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE;AAE1H,IAAA,MAAM,OAAO,GAAc,IAAI,GAAG,CAAC;AAChC,SAAA,OAAO,CAAC,CAAC,MAAM,KAAKC,mCAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC/D,SAAA,GAAG,CAAC,CAAC,QAAQ,KAAI;AAChB,QAAA,MAAM,MAAM,GAAGC,uBAAS,CAAC,QAAQ,CAAC;QAClC,OAAO,CAACC,8BAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC7C,CAAC,CAAC,CAAC;;IAGL,MAAM,eAAe,GAAGC,gCAAgB,C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AgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,CAACM,2BAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;IAGrH,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACjH,QAAA,MAAM,MAAM,GAAGN,uBAAS,CAAC,QAAQ,CAAC;AAClC,QAAA,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAKK,yBAAW,CAACL,uBAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAKM,2BAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpH,MAAM,UAAU,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,CAAC;;IAGpE,MAAM,eAAe,GAAGJ,gCAAgB,CAAC,SAAS,EAAE,UAAU,CAAC;AAE/D,IAAA,OAAO,eAAe;AACxB;;;;;"}
@@ -0,0 +1,8 @@
1
+ import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratories/pl-model-common';
2
+ import type { RenderCtx, PColumnDataUniversal } from '../render';
3
+ export declare function getAllRelatedColumns<A, U>(ctx: RenderCtx<A, U>, predicate: (spec: PColumnSpec) => boolean): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>>;
4
+ export declare function getRelatedColumns<A, U>(ctx: RenderCtx<A, U>, { columns: rootColumns, predicate }: {
5
+ columns: PColumn<PColumnDataUniversal>[];
6
+ predicate: (spec: PColumnSpec) => boolean;
7
+ }): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>>;
8
+ //# sourceMappingURL=columns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../src/pframe_utils/columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAIpG,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EACvC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,GAC9D,SAAS,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,WAAW,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAiB1F;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;IACjG,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;IACzC,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;CAC3C,GAAG,SAAS,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,WAAW,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAC,CA8D3F"}
@@ -0,0 +1,77 @@
1
+ import { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';
2
+ import { enrichCompatible, getAvailableWithLinkersAxes } from '../components/PFrameForGraphs.js';
3
+ import 'canonicalize';
4
+ import { PColumnCollection } from '../render/util/column_collection.js';
5
+ import '../render/util/label.js';
6
+
7
+ function getAllRelatedColumns(ctx, predicate) {
8
+ // if current block doesn't produce own columns then use all columns from result pool
9
+ const columns = new PColumnCollection();
10
+ columns.addColumnProvider(ctx.resultPool);
11
+ const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
12
+ const allAxes = new Map(allColumns
13
+ .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))
14
+ .map((axisSpec) => {
15
+ const axisId = getAxisId(axisSpec);
16
+ return [canonicalizeJson(axisId), axisSpec];
17
+ }));
18
+ // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
19
+ const extendedColumns = enrichCompatible(allAxes, allColumns);
20
+ return extendedColumns;
21
+ }
22
+ function getRelatedColumns(ctx, { columns: rootColumns, predicate }) {
23
+ // if current block has its own columns then take from result pool only compatible with them
24
+ const columns = new PColumnCollection();
25
+ columns.addColumnProvider(ctx.resultPool);
26
+ columns.addColumns(rootColumns);
27
+ // all possible axes from block columns
28
+ const blockAxes = new Map();
29
+ // axes from block columns and compatible result pool columns
30
+ const allAxes = new Map();
31
+ for (const c of rootColumns) {
32
+ for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
33
+ const aid = getAxisId(spec);
34
+ blockAxes.set(canonicalizeJson(aid), spec);
35
+ allAxes.set(canonicalizeJson(aid), spec);
36
+ }
37
+ }
38
+ // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
39
+ const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && isLinkerColumn(spec)) ?? [];
40
+ const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
41
+ // all possible axes from connected linkers
42
+ for (const item of availableWithLinkersAxes) {
43
+ blockAxes.set(...item);
44
+ allAxes.set(...item);
45
+ }
46
+ const blockAxesArr = Array.from(blockAxes.values());
47
+ // all compatible with block columns but without label columns
48
+ let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
49
+ const axisId = getAxisId(axisSpec);
50
+ return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
51
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
52
+ // extend axes set for label columns request
53
+ for (const c of compatibleWithoutLabels) {
54
+ for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
55
+ const aid = getAxisId(spec);
56
+ allAxes.set(canonicalizeJson(aid), spec);
57
+ }
58
+ }
59
+ const allAxesArr = Array.from(allAxes.values());
60
+ // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)
61
+ compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {
62
+ const axisId = getAxisId(axisSpec);
63
+ return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
64
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
65
+ // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
66
+ const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
67
+ const axisId = getAxisId(axisSpec);
68
+ return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
69
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));
70
+ const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
71
+ // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
72
+ const extendedColumns = enrichCompatible(blockAxes, compatible);
73
+ return extendedColumns;
74
+ }
75
+
76
+ export { getAllRelatedColumns, getRelatedColumns };
77
+ //# sourceMappingURL=columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.js","sources":["../../src/pframe_utils/columns.ts"],"sourcesContent":["import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratories/pl-model-common';\nimport { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';\nimport type { AxesVault } from '../components';\nimport { enrichCompatible, getAvailableWithLinkersAxes } from '../components';\nimport type { RenderCtx, PColumnDataUniversal } from '../render';\nimport { PColumnCollection } from '../render';\n\nexport function getAllRelatedColumns<A, U>(\n ctx: RenderCtx<A, U>, predicate: (spec: PColumnSpec) => boolean,\n): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block doesn't produce own columns then use all columns from result pool\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return extendedColumns;\n}\n\nexport function getRelatedColumns<A, U>(ctx: RenderCtx<A, U>, { columns: rootColumns, predicate }: {\n columns: PColumn<PColumnDataUniversal>[];\n predicate: (spec: PColumnSpec) => boolean;\n}): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(rootColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of rootColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n const blockAxesArr = Array.from(blockAxes.values());\n // all compatible with block columns but without label columns\n let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n const allAxesArr = Array.from(allAxes.values());\n // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)\n compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return extendedColumns;\n}\n"],"names":[],"mappings":";;;;;;AAOM,SAAU,oBAAoB,CAClC,GAAoB,EAAE,SAAyC,EAAA;;AAG/D,IAAA,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAE;AACvC,IAAA,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE;AAE1H,IAAA,MAAM,OAAO,GAAc,IAAI,GAAG,CAAC;AAChC,SAAA,OAAO,CAAC,CAAC,MAAM,KAAK,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC/D,SAAA,GAAG,CAAC,CAAC,QAAQ,KAAI;AAChB,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;QAClC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC7C,CAAC,CAAC,CAAC;;IAGL,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;AAE7D,IAAA,OAAO,eAAe;AACxB;AAEM,SAAU,iBAAiB,CAAO,GAAoB,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAG9F,EAAA;;AAEC,IAAA,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAE;AACvC,IAAA,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC;AACzC,IAAA,OAAO,CAA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C,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACjH,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;AAClC,QAAA,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAK,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpH,MAAM,UAAU,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,CAAC;;IAGpE,MAAM,eAAe,GAAG,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC;AAE/D,IAAA,OAAO,eAAe;AACxB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/model",
3
- "version": "1.48.12",
3
+ "version": "1.48.13",
4
4
  "description": "Platforma.bio SDK / Block Model",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -23,26 +23,27 @@
23
23
  "canonicalize": "~2.1.0",
24
24
  "es-toolkit": "^1.39.10",
25
25
  "zod": "~3.23.8",
26
+ "@milaboratories/ptabler-expression-js": "1.1.7",
26
27
  "@milaboratories/pl-model-common": "1.21.10",
27
- "@milaboratories/pl-error-like": "1.12.5",
28
- "@milaboratories/ptabler-expression-js": "1.1.7"
28
+ "@milaboratories/pl-error-like": "1.12.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "~5.6.3",
32
- "vitest": "^4.0.7",
32
+ "vitest": "^4.0.16",
33
+ "@vitest/coverage-istanbul": "^4.0.16",
33
34
  "fast-json-patch": "^3.1.1",
34
35
  "@milaboratories/build-configs": "1.2.1",
35
- "@platforma-sdk/eslint-config": "1.2.0",
36
- "@milaboratories/ts-configs": "1.2.0",
36
+ "@milaboratories/eslint-config": "1.0.5",
37
37
  "@milaboratories/helpers": "1.12.1",
38
- "@milaboratories/ts-builder": "1.2.1"
38
+ "@milaboratories/ts-builder": "1.2.1",
39
+ "@milaboratories/ts-configs": "1.2.0"
39
40
  },
40
41
  "scripts": {
41
42
  "type-check": "ts-builder types --target node",
42
43
  "build": "ts-builder build --target node",
43
44
  "watch": "ts-builder build --target node --watch",
44
45
  "lint": "eslint .",
45
- "test": "vitest run",
46
+ "test": "vitest run --coverage",
46
47
  "do-pack": "rm -f *.tgz && pnpm pack && mv *.tgz package.tgz"
47
48
  }
48
49
  }
@@ -2,7 +2,6 @@ import type { BlockSection } from '@milaboratories/pl-model-common';
2
2
 
3
3
  type OnlyString<S> = S extends string ? S : '';
4
4
 
5
- // prettier-ignore
6
5
  export type DeriveHref<S> = S extends readonly BlockSection[]
7
6
  ? OnlyString<Extract<S[number], { type: 'link' }>['href']>
8
7
  : never;
@@ -11,18 +11,14 @@ import {
11
11
  Annotation,
12
12
  canonicalizeJson,
13
13
  getAxisId,
14
- getColumnIdAndSpec,
15
- getNormalizedAxesList,
16
- isLabelColumn,
17
- isLinkerColumn,
18
- LinkerMap,
14
+ getColumnIdAndSpec, LinkerMap,
19
15
  matchAxisId,
20
16
  readAnnotation,
21
17
  readAnnotationJson,
22
18
  stringifyJson,
23
19
  } from '@milaboratories/pl-model-common';
24
20
  import type { PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, RenderCtx } from '../render';
25
- import { PColumnCollection } from '../render';
21
+ import { getAllRelatedColumns, getRelatedColumns } from '../pframe_utils/columns';
26
22
 
27
23
  /** Create id for column copy with added keys in axes domains */
28
24
  const colId = (id: PObjectId, domains: (Record<string, string> | undefined)[]) => {
@@ -62,7 +58,7 @@ export function isHiddenFromUIColumn(column: PColumnSpec): boolean {
62
58
  return !!readAnnotationJson(column, Annotation.HideDataFromUi);
63
59
  }
64
60
 
65
- type AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;
61
+ export type AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;
66
62
 
67
63
  export function getAvailableWithLinkersAxes(
68
64
  linkerColumns: (PColumnEntryWithLabel | PColumnEntryUniversal)[],
@@ -189,82 +185,8 @@ export function createPFrameForGraphs<A, U>(
189
185
  const suitableSpec = (spec: PColumnSpec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);
190
186
  // if current block doesn't produce own columns then use all columns from result pool
191
187
  if (!blockColumns) {
192
- const columns = new PColumnCollection();
193
- columns.addColumnProvider(ctx.resultPool);
194
- const allColumns = columns.getUniversalEntries(suitableSpec, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
195
-
196
- const allAxes: AxesVault = new Map(allColumns
197
- .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))
198
- .map((axisSpec) => {
199
- const axisId = getAxisId(axisSpec);
200
- return [canonicalizeJson(axisId), axisSpec];
201
- }));
202
-
203
- // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
204
- const extendedColumns = enrichCompatible(allAxes, allColumns);
205
-
206
- return ctx.createPFrame(extendedColumns);
188
+ return ctx.createPFrame(getAllRelatedColumns(ctx, suitableSpec));
207
189
  };
208
190
 
209
- // if current block has its own columns then take from result pool only compatible with them
210
- const columns = new PColumnCollection();
211
- columns.addColumnProvider(ctx.resultPool);
212
- columns.addColumns(blockColumns);
213
-
214
- // all possible axes from block columns
215
- const blockAxes: AxesVault = new Map();
216
- // axes from block columns and compatible result pool columns
217
- const allAxes: AxesVault = new Map();
218
- for (const c of blockColumns) {
219
- for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
220
- const aid = getAxisId(spec);
221
- blockAxes.set(canonicalizeJson(aid), spec);
222
- allAxes.set(canonicalizeJson(aid), spec);
223
- }
224
- }
225
-
226
- // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
227
- const linkerColumns = columns.getUniversalEntries((spec) => suitableSpec(spec) && isLinkerColumn(spec)) ?? [];
228
- const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
229
-
230
- // all possible axes from connected linkers
231
- for (const item of availableWithLinkersAxes) {
232
- blockAxes.set(...item);
233
- allAxes.set(...item);
234
- }
235
-
236
- const blockAxesArr = Array.from(blockAxes.values());
237
- // all compatible with block columns but without label columns
238
- let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {
239
- const axisId = getAxisId(axisSpec);
240
- return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
241
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
242
-
243
- // extend axes set for label columns request
244
- for (const c of compatibleWithoutLabels) {
245
- for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
246
- const aid = getAxisId(spec);
247
- allAxes.set(canonicalizeJson(aid), spec);
248
- }
249
- }
250
-
251
- const allAxesArr = Array.from(allAxes.values());
252
- // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)
253
- compatibleWithoutLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.every((axisSpec) => {
254
- const axisId = getAxisId(axisSpec);
255
- return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
256
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
257
-
258
- // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
259
- const compatibleLabels = (columns.getUniversalEntries((spec) => suitableSpec(spec) && spec.axesSpec.some((axisSpec) => {
260
- const axisId = getAxisId(axisSpec);
261
- return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
262
- }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));
263
-
264
- const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
265
-
266
- // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
267
- const extendedColumns = enrichCompatible(blockAxes, compatible);
268
-
269
- return ctx.createPFrame(extendedColumns);
191
+ return ctx.createPFrame(getRelatedColumns(ctx, { columns: blockColumns, predicate: suitableSpec }));
270
192
  }
@@ -0,0 +1,94 @@
1
+ import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratories/pl-model-common';
2
+ import { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';
3
+ import type { AxesVault } from '../components';
4
+ import { enrichCompatible, getAvailableWithLinkersAxes } from '../components';
5
+ import type { RenderCtx, PColumnDataUniversal } from '../render';
6
+ import { PColumnCollection } from '../render';
7
+
8
+ export function getAllRelatedColumns<A, U>(
9
+ ctx: RenderCtx<A, U>, predicate: (spec: PColumnSpec) => boolean,
10
+ ): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {
11
+ // if current block doesn't produce own columns then use all columns from result pool
12
+ const columns = new PColumnCollection();
13
+ columns.addColumnProvider(ctx.resultPool);
14
+ const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
15
+
16
+ const allAxes: AxesVault = new Map(allColumns
17
+ .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))
18
+ .map((axisSpec) => {
19
+ const axisId = getAxisId(axisSpec);
20
+ return [canonicalizeJson(axisId), axisSpec];
21
+ }));
22
+
23
+ // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
24
+ const extendedColumns = enrichCompatible(allAxes, allColumns);
25
+
26
+ return extendedColumns;
27
+ }
28
+
29
+ export function getRelatedColumns<A, U>(ctx: RenderCtx<A, U>, { columns: rootColumns, predicate }: {
30
+ columns: PColumn<PColumnDataUniversal>[];
31
+ predicate: (spec: PColumnSpec) => boolean;
32
+ }): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {
33
+ // if current block has its own columns then take from result pool only compatible with them
34
+ const columns = new PColumnCollection();
35
+ columns.addColumnProvider(ctx.resultPool);
36
+ columns.addColumns(rootColumns);
37
+
38
+ // all possible axes from block columns
39
+ const blockAxes: AxesVault = new Map();
40
+ // axes from block columns and compatible result pool columns
41
+ const allAxes: AxesVault = new Map();
42
+ for (const c of rootColumns) {
43
+ for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
44
+ const aid = getAxisId(spec);
45
+ blockAxes.set(canonicalizeJson(aid), spec);
46
+ allAxes.set(canonicalizeJson(aid), spec);
47
+ }
48
+ }
49
+
50
+ // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
51
+ const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && isLinkerColumn(spec)) ?? [];
52
+ const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
53
+
54
+ // all possible axes from connected linkers
55
+ for (const item of availableWithLinkersAxes) {
56
+ blockAxes.set(...item);
57
+ allAxes.set(...item);
58
+ }
59
+
60
+ const blockAxesArr = Array.from(blockAxes.values());
61
+ // all compatible with block columns but without label columns
62
+ let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
63
+ const axisId = getAxisId(axisSpec);
64
+ return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
65
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
66
+
67
+ // extend axes set for label columns request
68
+ for (const c of compatibleWithoutLabels) {
69
+ for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
70
+ const aid = getAxisId(spec);
71
+ allAxes.set(canonicalizeJson(aid), spec);
72
+ }
73
+ }
74
+
75
+ const allAxesArr = Array.from(allAxes.values());
76
+ // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)
77
+ compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {
78
+ const axisId = getAxisId(axisSpec);
79
+ return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
80
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
81
+
82
+ // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
83
+ const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
84
+ const axisId = getAxisId(axisSpec);
85
+ return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
86
+ }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));
87
+
88
+ const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
89
+
90
+ // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
91
+ const extendedColumns = enrichCompatible(blockAxes, compatible);
92
+
93
+ return extendedColumns;
94
+ }