@platforma-sdk/model 1.42.16 → 1.42.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/dist/bconfig/index.d.ts +0 -1
  2. package/dist/bconfig/lambdas.d.ts +0 -1
  3. package/dist/bconfig/normalization.cjs +19 -0
  4. package/dist/bconfig/normalization.cjs.map +1 -0
  5. package/dist/bconfig/normalization.d.ts +0 -1
  6. package/dist/bconfig/normalization.js +16 -0
  7. package/dist/bconfig/normalization.js.map +1 -0
  8. package/dist/bconfig/types.cjs +8 -0
  9. package/dist/bconfig/types.cjs.map +1 -0
  10. package/dist/bconfig/types.d.ts +0 -1
  11. package/dist/bconfig/types.js +6 -0
  12. package/dist/bconfig/types.js.map +1 -0
  13. package/dist/bconfig/util.d.ts +0 -1
  14. package/dist/bconfig/v3.d.ts +0 -1
  15. package/dist/block_api_v1.d.ts +0 -1
  16. package/dist/block_api_v2.d.ts +0 -1
  17. package/dist/block_state_patch.d.ts +0 -1
  18. package/dist/block_state_util.cjs +28 -0
  19. package/dist/block_state_util.cjs.map +1 -0
  20. package/dist/block_state_util.d.ts +0 -1
  21. package/dist/block_state_util.js +24 -0
  22. package/dist/block_state_util.js.map +1 -0
  23. package/dist/branding.d.ts +0 -1
  24. package/dist/builder.cjs +166 -0
  25. package/dist/builder.cjs.map +1 -0
  26. package/dist/builder.d.ts +0 -1
  27. package/dist/builder.js +164 -0
  28. package/dist/builder.js.map +1 -0
  29. package/dist/components/PFrameForGraphs.cjs +261 -0
  30. package/dist/components/PFrameForGraphs.cjs.map +1 -0
  31. package/dist/components/PFrameForGraphs.d.ts +0 -1
  32. package/dist/components/PFrameForGraphs.js +254 -0
  33. package/dist/components/PFrameForGraphs.js.map +1 -0
  34. package/dist/components/PlAnnotations/filter.d.ts +0 -1
  35. package/dist/components/PlAnnotations/filters_ui.cjs +556 -0
  36. package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -0
  37. package/dist/components/PlAnnotations/filters_ui.d.ts +0 -1
  38. package/dist/components/PlAnnotations/filters_ui.js +548 -0
  39. package/dist/components/PlAnnotations/filters_ui.js.map +1 -0
  40. package/dist/components/PlAnnotations/index.d.ts +0 -1
  41. package/dist/components/PlAnnotations/types.d.ts +0 -1
  42. package/dist/components/PlDataTable.cjs +337 -0
  43. package/dist/components/PlDataTable.cjs.map +1 -0
  44. package/dist/components/PlDataTable.d.ts +0 -1
  45. package/dist/components/PlDataTable.js +324 -0
  46. package/dist/components/PlDataTable.js.map +1 -0
  47. package/dist/components/PlMultiSequenceAlignment.cjs +33 -0
  48. package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -0
  49. package/dist/components/PlMultiSequenceAlignment.d.ts +0 -1
  50. package/dist/components/PlMultiSequenceAlignment.js +31 -0
  51. package/dist/components/PlMultiSequenceAlignment.js.map +1 -0
  52. package/dist/components/PlSelectionModel.cjs +11 -0
  53. package/dist/components/PlSelectionModel.cjs.map +1 -0
  54. package/dist/components/PlSelectionModel.d.ts +0 -1
  55. package/dist/components/PlSelectionModel.js +9 -0
  56. package/dist/components/PlSelectionModel.js.map +1 -0
  57. package/dist/components/index.d.ts +0 -1
  58. package/dist/config/actions.cjs +266 -0
  59. package/dist/config/actions.cjs.map +1 -0
  60. package/dist/config/actions.d.ts +0 -1
  61. package/dist/config/actions.js +233 -0
  62. package/dist/config/actions.js.map +1 -0
  63. package/dist/config/actions_kinds.d.ts +0 -1
  64. package/dist/config/index.d.ts +0 -1
  65. package/dist/config/model.d.ts +0 -1
  66. package/dist/config/model_meta.d.ts +0 -1
  67. package/dist/config/type_engine.d.ts +0 -1
  68. package/dist/config/type_util.d.ts +0 -1
  69. package/dist/env_value.cjs +11 -0
  70. package/dist/env_value.cjs.map +1 -0
  71. package/dist/env_value.d.ts +0 -1
  72. package/dist/env_value.js +9 -0
  73. package/dist/env_value.js.map +1 -0
  74. package/dist/global.d.ts +14 -0
  75. package/dist/index.cjs +138 -0
  76. package/dist/index.cjs.map +1 -0
  77. package/dist/index.d.ts +0 -1
  78. package/dist/index.js +26 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/internal.cjs +56 -0
  81. package/dist/internal.cjs.map +1 -0
  82. package/dist/internal.d.ts +0 -1
  83. package/dist/internal.js +49 -0
  84. package/dist/internal.js.map +1 -0
  85. package/dist/package.json.cjs +6 -0
  86. package/dist/package.json.cjs.map +1 -0
  87. package/dist/package.json.js +4 -0
  88. package/dist/package.json.js.map +1 -0
  89. package/dist/pframe.cjs +34 -0
  90. package/dist/pframe.cjs.map +1 -0
  91. package/dist/pframe.d.ts +0 -1
  92. package/dist/pframe.js +32 -0
  93. package/dist/pframe.js.map +1 -0
  94. package/dist/platforma.d.ts +0 -1
  95. package/dist/raw_globals.cjs +28 -0
  96. package/dist/raw_globals.cjs.map +1 -0
  97. package/dist/raw_globals.d.ts +0 -1
  98. package/dist/raw_globals.js +25 -0
  99. package/dist/raw_globals.js.map +1 -0
  100. package/dist/ref_util.cjs +21 -0
  101. package/dist/ref_util.cjs.map +1 -0
  102. package/dist/ref_util.d.ts +11 -12
  103. package/dist/ref_util.js +18 -0
  104. package/dist/ref_util.js.map +1 -0
  105. package/dist/render/accessor.cjs +233 -0
  106. package/dist/render/accessor.cjs.map +1 -0
  107. package/dist/render/accessor.d.ts +0 -1
  108. package/dist/render/accessor.js +230 -0
  109. package/dist/render/accessor.js.map +1 -0
  110. package/dist/render/api.cjs +514 -0
  111. package/dist/render/api.cjs.map +1 -0
  112. package/dist/render/api.d.ts +0 -1
  113. package/dist/render/api.js +511 -0
  114. package/dist/render/api.js.map +1 -0
  115. package/dist/render/future.cjs +35 -0
  116. package/dist/render/future.cjs.map +1 -0
  117. package/dist/render/future.d.ts +0 -1
  118. package/dist/render/future.js +33 -0
  119. package/dist/render/future.js.map +1 -0
  120. package/dist/render/index.d.ts +0 -1
  121. package/dist/render/internal.cjs +43 -0
  122. package/dist/render/internal.cjs.map +1 -0
  123. package/dist/render/internal.d.ts +0 -1
  124. package/dist/render/internal.js +37 -0
  125. package/dist/render/internal.js.map +1 -0
  126. package/dist/render/traversal_ops.d.ts +0 -1
  127. package/dist/render/util/axis_filtering.cjs +87 -0
  128. package/dist/render/util/axis_filtering.cjs.map +1 -0
  129. package/dist/render/util/axis_filtering.d.ts +0 -1
  130. package/dist/render/util/axis_filtering.js +85 -0
  131. package/dist/render/util/axis_filtering.js.map +1 -0
  132. package/dist/render/util/column_collection.cjs +309 -0
  133. package/dist/render/util/column_collection.cjs.map +1 -0
  134. package/dist/render/util/column_collection.d.ts +0 -1
  135. package/dist/render/util/column_collection.js +307 -0
  136. package/dist/render/util/column_collection.js.map +1 -0
  137. package/dist/render/util/index.d.ts +0 -1
  138. package/dist/render/util/label.cjs +153 -0
  139. package/dist/render/util/label.cjs.map +1 -0
  140. package/dist/render/util/label.d.ts +0 -1
  141. package/dist/render/util/label.js +149 -0
  142. package/dist/render/util/label.js.map +1 -0
  143. package/dist/render/util/pcolumn_data.cjs +342 -0
  144. package/dist/render/util/pcolumn_data.cjs.map +1 -0
  145. package/dist/render/util/pcolumn_data.d.ts +0 -1
  146. package/dist/render/util/pcolumn_data.js +330 -0
  147. package/dist/render/util/pcolumn_data.js.map +1 -0
  148. package/dist/render/util/pframe_upgraders.cjs +47 -0
  149. package/dist/render/util/pframe_upgraders.cjs.map +1 -0
  150. package/dist/render/util/pframe_upgraders.d.ts +0 -1
  151. package/dist/render/util/pframe_upgraders.js +45 -0
  152. package/dist/render/util/pframe_upgraders.js.map +1 -0
  153. package/dist/render/util/split_selectors.d.ts +0 -1
  154. package/dist/sdk_info.cjs +10 -0
  155. package/dist/sdk_info.cjs.map +1 -0
  156. package/dist/sdk_info.d.ts +0 -1
  157. package/dist/sdk_info.js +8 -0
  158. package/dist/sdk_info.js.map +1 -0
  159. package/dist/unionize.d.ts +0 -1
  160. package/dist/version.cjs +8 -0
  161. package/dist/version.cjs.map +1 -0
  162. package/dist/version.d.ts +0 -1
  163. package/dist/version.js +6 -0
  164. package/dist/version.js.map +1 -0
  165. package/package.json +16 -18
  166. package/src/components/PFrameForGraphs.test.ts +2 -2
  167. package/src/components/PlAnnotations/filters_ui.test.ts +1 -1
  168. package/src/render/util/label.test.ts +2 -2
  169. package/src/typing.test.ts +2 -1
  170. package/dist/bconfig/index.d.ts.map +0 -1
  171. package/dist/bconfig/lambdas.d.ts.map +0 -1
  172. package/dist/bconfig/normalization.d.ts.map +0 -1
  173. package/dist/bconfig/types.d.ts.map +0 -1
  174. package/dist/bconfig/util.d.ts.map +0 -1
  175. package/dist/bconfig/v3.d.ts.map +0 -1
  176. package/dist/block_api_v1.d.ts.map +0 -1
  177. package/dist/block_api_v2.d.ts.map +0 -1
  178. package/dist/block_state_patch.d.ts.map +0 -1
  179. package/dist/block_state_util.d.ts.map +0 -1
  180. package/dist/branding.d.ts.map +0 -1
  181. package/dist/builder.d.ts.map +0 -1
  182. package/dist/components/PFrameForGraphs.d.ts.map +0 -1
  183. package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
  184. package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
  185. package/dist/components/PlAnnotations/index.d.ts.map +0 -1
  186. package/dist/components/PlAnnotations/types.d.ts.map +0 -1
  187. package/dist/components/PlDataTable.d.ts.map +0 -1
  188. package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
  189. package/dist/components/PlSelectionModel.d.ts.map +0 -1
  190. package/dist/components/index.d.ts.map +0 -1
  191. package/dist/config/actions.d.ts.map +0 -1
  192. package/dist/config/actions_kinds.d.ts.map +0 -1
  193. package/dist/config/index.d.ts.map +0 -1
  194. package/dist/config/model.d.ts.map +0 -1
  195. package/dist/config/model_meta.d.ts.map +0 -1
  196. package/dist/config/type_engine.d.ts.map +0 -1
  197. package/dist/config/type_util.d.ts.map +0 -1
  198. package/dist/env_value.d.ts.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/index.mjs +0 -2845
  201. package/dist/index.mjs.map +0 -1
  202. package/dist/internal.d.ts.map +0 -1
  203. package/dist/pframe.d.ts.map +0 -1
  204. package/dist/platforma.d.ts.map +0 -1
  205. package/dist/raw_globals.d.ts.map +0 -1
  206. package/dist/ref_util.d.ts.map +0 -1
  207. package/dist/render/accessor.d.ts.map +0 -1
  208. package/dist/render/api.d.ts.map +0 -1
  209. package/dist/render/future.d.ts.map +0 -1
  210. package/dist/render/index.d.ts.map +0 -1
  211. package/dist/render/internal.d.ts.map +0 -1
  212. package/dist/render/traversal_ops.d.ts.map +0 -1
  213. package/dist/render/util/axis_filtering.d.ts.map +0 -1
  214. package/dist/render/util/column_collection.d.ts.map +0 -1
  215. package/dist/render/util/index.d.ts.map +0 -1
  216. package/dist/render/util/label.d.ts.map +0 -1
  217. package/dist/render/util/pcolumn_data.d.ts.map +0 -1
  218. package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
  219. package/dist/render/util/split_selectors.d.ts.map +0 -1
  220. package/dist/sdk_info.d.ts.map +0 -1
  221. package/dist/unionize.d.ts.map +0 -1
  222. package/dist/version.d.ts.map +0 -1
@@ -0,0 +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 canonicalizeJson,\n getAxisId,\n isDataInfo,\n matchAxisId,\n visitDataInfo,\n getColumnIdAndSpec,\n Annotation,\n readAnnotation,\n getNormalizedAxesList,\n stringifyJson,\n readAnnotationJson,\n LinkerMap,\n getArrayFromAxisTree,\n getAxesTree,\n} from '@milaboratories/pl-model-common';\nimport type { PColumnDataUniversal, RenderCtx } from '../render';\nimport { PColumnCollection, TreeNodeAccessor } from '../render';\nimport { isLabelColumn } from './PlDataTable';\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\n/** Check if column is a linker column */\nexport function isLinkerColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.IsLinkerColumn);\n}\n\ntype AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;\n\nexport function getAvailableWithLinkersAxes(\n linkerColumns: PColumn<PColumnDataUniversal>[],\n blockAxes: AxesVault,\n): AxesVault {\n const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));\n const startKeys: CanonicalizedJson<AxisId[]>[] = [];\n const blockAxesGrouped: AxisId[][] = [...blockAxes.values()].map((axis) => getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));\n\n for (const axesGroupBlock of blockAxesGrouped) {\n const matched = linkerMap.keyAxesIds.find(\n (keyIds: AxisId[]) => keyIds.every(\n (keySourceAxis) => axesGroupBlock.find((axisSpecFromBlock) => matchAxisId(axisSpecFromBlock, keySourceAxis)),\n ),\n );\n if (matched) {\n startKeys.push(canonicalizeJson(matched)); // linker column can contain fewer domains than in block's columns, it's fixed on next step in enrichCompatible\n }\n }\n\n const availableKeys = linkerMap.searchAvailableAxesKeys(startKeys);\n const availableAxes = linkerMap.getAxesListFromKeysList([...availableKeys]);\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(blockAxes: AxesVault, columns: PColumn<PColumnDataUniversal>[]) {\n const result: PColumn<PColumnDataUniversal>[] = [];\n columns.forEach((column) => {\n result.push(...getAdditionalColumnsForColumn(blockAxes, column));\n });\n return result;\n}\n\nfunction getAdditionalColumnsForColumn(\n blockAxes: AxesVault,\n column: PColumn<PColumnDataUniversal>,\n): PColumn<PColumnDataUniversal>[] {\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 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 data: column.data,\n };\n });\n\n return [column, ...additionalColumns];\n}\n\nexport function isColumnReady(c: PColumn<PColumnDataUniversal>) {\n let ready = true;\n if (c.data instanceof TreeNodeAccessor) {\n ready = ready && c.data.getIsReadyOrError();\n } else if (isDataInfo(c.data)) {\n visitDataInfo(c.data, (v) => {\n ready = ready && v.getIsReadyOrError();\n });\n }\n return ready;\n}\n\nexport function allColumnsReady(columns: PColumn<PColumnDataUniversal>[]): boolean {\n return columns.every(isColumnReady);\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 // 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\n const allColumns = columns.getColumns(() => true, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n // if at least one column is not yet ready, we can't show the graph\n if (!allColumnsReady(allColumns)) {\n return undefined;\n }\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 (!allColumnsReady(blockColumns)) {\n return undefined;\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.getColumns((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 // all compatible with block columns but without label columns\n const compatibleWithoutLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n for (const selectorAxisSpec of blockAxes.values()) {\n if (matchAxisId(getAxisId(selectorAxisSpec), axisId)) {\n return true;\n }\n }\n return false;\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // if at least one column is not yet ready, we can't show the graph\n if (!allColumnsReady(compatibleWithoutLabels)) {\n return undefined;\n }\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 // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n for (const selectorAxisSpec of allAxes.values()) {\n if (matchAxisId(getAxisId(selectorAxisSpec), axisId)) {\n return true;\n }\n }\n return false;\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n // if at least one column is not yet ready, we can't show the graph\n if (!allColumnsReady(compatibleLabels)) {\n return undefined;\n }\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":";;;;;;;AA6BA;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,CAA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C,IAAI,CAAC,QAAQ,CAAC,EAAE;AACzD,YAAA,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;QAC1C;IACF;;IAGA,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACrF,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;QAClC,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;YAC/C,IAAI,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,EAAE;AACpD,gBAAA,OAAO,IAAI;YACb;QACF;AACA,QAAA,OAAO,KAAK;AACd,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;;AAGpH,IAAA,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE;AACtC,QAAA,OAAO,SAAS;IAClB;IAEA,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;;;;"}
@@ -210,4 +210,3 @@ export type AnnotationScript2<S extends AnnotationStep> = {
210
210
  /** Ordered list of annotation steps to apply */
211
211
  steps: S[];
212
212
  };
213
- //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1,556 @@
1
+ 'use strict';
2
+
3
+ function unreachable(x) {
4
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
5
+ throw new Error('Unexpected object: ' + x);
6
+ }
7
+ function isNumericValueType(spec) {
8
+ return spec.valueType === 'Int' || spec.valueType === 'Long' || spec.valueType === 'Float' || spec.valueType === 'Double';
9
+ }
10
+ function isStringValueType(spec) {
11
+ return spec.valueType === 'String';
12
+ }
13
+ const filterUiMetadata = {
14
+ lessThan: {
15
+ label: 'Col < X (Less Than)',
16
+ form: {
17
+ column: {
18
+ label: 'Column',
19
+ fieldType: 'SUniversalPColumnId',
20
+ defaultValue: () => undefined,
21
+ },
22
+ type: {
23
+ label: 'Predicate',
24
+ fieldType: 'FilterUiType',
25
+ defaultValue: () => 'lessThan',
26
+ },
27
+ x: {
28
+ label: 'X',
29
+ fieldType: 'number',
30
+ defaultValue: () => 0,
31
+ },
32
+ },
33
+ supportedFor: isNumericValueType,
34
+ },
35
+ greaterThan: {
36
+ label: 'Col > X (Greater Than)',
37
+ form: {
38
+ column: {
39
+ label: 'Column',
40
+ fieldType: 'SUniversalPColumnId',
41
+ defaultValue: () => undefined,
42
+ },
43
+ type: {
44
+ label: 'Predicate',
45
+ fieldType: 'FilterUiType',
46
+ defaultValue: () => 'greaterThan',
47
+ },
48
+ x: {
49
+ label: 'X',
50
+ fieldType: 'number',
51
+ defaultValue: () => 0,
52
+ },
53
+ },
54
+ supportedFor: isNumericValueType,
55
+ },
56
+ lessThanOrEqual: {
57
+ label: 'Col ≤ X (Less Than or Equal)',
58
+ form: {
59
+ column: {
60
+ label: 'Column',
61
+ fieldType: 'SUniversalPColumnId',
62
+ defaultValue: () => undefined,
63
+ },
64
+ type: {
65
+ label: 'Predicate',
66
+ fieldType: 'FilterUiType',
67
+ defaultValue: () => 'lessThanOrEqual',
68
+ },
69
+ x: {
70
+ label: 'X',
71
+ fieldType: 'number',
72
+ defaultValue: () => 0,
73
+ },
74
+ },
75
+ supportedFor: isNumericValueType,
76
+ },
77
+ greaterThanOrEqual: {
78
+ label: 'Col ≥ X (Greater Than or Equal)',
79
+ form: {
80
+ column: {
81
+ label: 'Column',
82
+ fieldType: 'SUniversalPColumnId',
83
+ defaultValue: () => undefined,
84
+ },
85
+ type: {
86
+ label: 'Predicate',
87
+ fieldType: 'FilterUiType',
88
+ defaultValue: () => 'greaterThanOrEqual',
89
+ },
90
+ x: {
91
+ label: 'X',
92
+ fieldType: 'number',
93
+ defaultValue: () => 0,
94
+ },
95
+ },
96
+ supportedFor: isNumericValueType,
97
+ },
98
+ lessThanColumn: {
99
+ label: 'Col₁ < Col₂ (Compare Columns)',
100
+ form: {
101
+ column: {
102
+ label: 'Col₁',
103
+ fieldType: 'SUniversalPColumnId',
104
+ defaultValue: () => undefined,
105
+ },
106
+ type: {
107
+ label: 'Predicate',
108
+ fieldType: 'FilterUiType',
109
+ defaultValue: () => 'lessThanColumn',
110
+ },
111
+ rhs: {
112
+ label: 'Col₂',
113
+ fieldType: 'SUniversalPColumnId',
114
+ defaultValue: () => undefined,
115
+ },
116
+ minDiff: {
117
+ label: 'Margin (positive)',
118
+ fieldType: 'number?',
119
+ defaultValue: () => undefined,
120
+ },
121
+ },
122
+ supportedFor: (spec1, spec2) => {
123
+ return isNumericValueType(spec1) && (spec2 === undefined || isNumericValueType(spec2));
124
+ },
125
+ },
126
+ lessThanColumnOrEqual: {
127
+ label: 'Col₁ ≤ Col₂ (Compare Columns)',
128
+ form: {
129
+ column: {
130
+ label: 'Col₁',
131
+ fieldType: 'SUniversalPColumnId',
132
+ defaultValue: () => undefined,
133
+ },
134
+ type: {
135
+ label: 'Predicate',
136
+ fieldType: 'FilterUiType',
137
+ defaultValue: () => 'lessThanColumnOrEqual',
138
+ },
139
+ rhs: {
140
+ label: 'Col₂',
141
+ fieldType: 'SUniversalPColumnId',
142
+ defaultValue: () => undefined,
143
+ },
144
+ minDiff: {
145
+ label: 'Margin (positive)',
146
+ fieldType: 'number?',
147
+ defaultValue: () => undefined,
148
+ },
149
+ },
150
+ supportedFor: (spec1, spec2) => {
151
+ return isNumericValueType(spec1) && (spec2 === undefined || isNumericValueType(spec2));
152
+ },
153
+ },
154
+ topN: {
155
+ label: 'Top N',
156
+ form: {
157
+ column: {
158
+ label: 'Rank By Column',
159
+ fieldType: 'SUniversalPColumnId',
160
+ defaultValue: () => undefined,
161
+ },
162
+ type: {
163
+ label: 'Predicate',
164
+ fieldType: 'FilterUiType',
165
+ defaultValue: () => 'topN',
166
+ },
167
+ n: {
168
+ label: 'N',
169
+ fieldType: 'number',
170
+ defaultValue: () => 10,
171
+ },
172
+ },
173
+ supportedFor: isNumericValueType,
174
+ },
175
+ bottomN: {
176
+ label: 'Bottom N',
177
+ form: {
178
+ column: {
179
+ label: 'Rank By Column',
180
+ fieldType: 'SUniversalPColumnId',
181
+ defaultValue: () => undefined,
182
+ },
183
+ type: {
184
+ label: 'Predicate',
185
+ fieldType: 'FilterUiType',
186
+ defaultValue: () => 'bottomN',
187
+ },
188
+ n: {
189
+ label: 'N',
190
+ fieldType: 'number',
191
+ defaultValue: () => 10,
192
+ },
193
+ },
194
+ supportedFor: isNumericValueType,
195
+ },
196
+ patternContainSubsequence: {
197
+ label: 'Col ~ Seq (Contain Subsequence)',
198
+ form: {
199
+ column: {
200
+ label: 'Column',
201
+ fieldType: 'SUniversalPColumnId',
202
+ defaultValue: () => undefined,
203
+ },
204
+ type: {
205
+ label: 'Predicate',
206
+ fieldType: 'FilterUiType',
207
+ defaultValue: () => 'patternContainSubsequence',
208
+ },
209
+ value: {
210
+ label: 'Seq',
211
+ fieldType: 'string',
212
+ defaultValue: () => '',
213
+ },
214
+ },
215
+ supportedFor: isStringValueType,
216
+ },
217
+ patternNotContainSubsequence: {
218
+ label: 'Col ≁ Seq (Not Contain Subsequence)',
219
+ form: {
220
+ column: {
221
+ label: 'Column',
222
+ fieldType: 'SUniversalPColumnId',
223
+ defaultValue: () => undefined,
224
+ },
225
+ type: {
226
+ label: 'Predicate',
227
+ fieldType: 'FilterUiType',
228
+ defaultValue: () => 'patternNotContainSubsequence',
229
+ },
230
+ value: {
231
+ label: 'Seq',
232
+ fieldType: 'string',
233
+ defaultValue: () => '',
234
+ },
235
+ },
236
+ supportedFor: isStringValueType,
237
+ },
238
+ patternEquals: {
239
+ label: 'Col = Seq (Equals)',
240
+ form: {
241
+ column: {
242
+ label: 'Column',
243
+ fieldType: 'SUniversalPColumnId',
244
+ defaultValue: () => undefined,
245
+ },
246
+ type: {
247
+ label: 'Predicate',
248
+ fieldType: 'FilterUiType',
249
+ defaultValue: () => 'patternEquals',
250
+ },
251
+ value: {
252
+ label: 'Seq',
253
+ fieldType: 'string',
254
+ defaultValue: () => '',
255
+ },
256
+ },
257
+ supportedFor: isStringValueType,
258
+ },
259
+ patternNotEquals: {
260
+ label: 'Col ≠ Seq (Not Equal)',
261
+ form: {
262
+ column: {
263
+ label: 'Column',
264
+ fieldType: 'SUniversalPColumnId',
265
+ defaultValue: () => undefined,
266
+ },
267
+ type: {
268
+ label: 'Predicate',
269
+ fieldType: 'FilterUiType',
270
+ defaultValue: () => 'patternNotEquals',
271
+ },
272
+ value: {
273
+ label: 'Seq',
274
+ fieldType: 'string',
275
+ defaultValue: () => '',
276
+ },
277
+ },
278
+ supportedFor: isStringValueType,
279
+ },
280
+ isNA: {
281
+ label: 'Is NA',
282
+ form: {
283
+ column: {
284
+ label: 'Column',
285
+ fieldType: 'SUniversalPColumnId',
286
+ defaultValue: () => undefined,
287
+ },
288
+ type: {
289
+ label: 'Predicate',
290
+ fieldType: 'FilterUiType',
291
+ defaultValue: () => 'isNA',
292
+ },
293
+ },
294
+ supportedFor: () => true,
295
+ },
296
+ isNotNA: {
297
+ label: 'Is Not NA',
298
+ form: {
299
+ column: {
300
+ label: 'Column',
301
+ fieldType: 'SUniversalPColumnId',
302
+ defaultValue: () => undefined,
303
+ },
304
+ type: {
305
+ label: 'Predicate',
306
+ fieldType: 'FilterUiType',
307
+ defaultValue: () => 'isNotNA',
308
+ },
309
+ },
310
+ supportedFor: () => true,
311
+ },
312
+ or: {
313
+ label: 'Or',
314
+ form: {
315
+ type: {
316
+ fieldType: 'FilterUiType',
317
+ label: 'Predicate',
318
+ defaultValue: () => 'or',
319
+ },
320
+ filters: {
321
+ fieldType: 'unknown[]',
322
+ label: 'Filters',
323
+ defaultValue: () => [],
324
+ },
325
+ },
326
+ supportedFor: () => false,
327
+ },
328
+ and: {
329
+ label: 'And',
330
+ form: {
331
+ type: {
332
+ fieldType: 'FilterUiType',
333
+ label: 'Predicate',
334
+ defaultValue: () => 'and',
335
+ },
336
+ filters: {
337
+ fieldType: 'unknown[]',
338
+ label: 'Filters',
339
+ defaultValue: () => [],
340
+ },
341
+ },
342
+ supportedFor: () => false,
343
+ },
344
+ not: {
345
+ label: 'Not',
346
+ form: {
347
+ type: {
348
+ fieldType: 'FilterUiType',
349
+ label: 'Predicate',
350
+ defaultValue: () => 'not',
351
+ },
352
+ filter: {
353
+ fieldType: 'form',
354
+ label: 'Filter',
355
+ defaultValue: () => undefined, // TODO:
356
+ },
357
+ },
358
+ supportedFor: () => false,
359
+ },
360
+ };
361
+ function getFilterUiTypeOptions(columnSpec) {
362
+ if (!columnSpec) {
363
+ return [];
364
+ }
365
+ return Object.entries(filterUiMetadata).filter(([_, metadata]) => metadata.supportedFor(columnSpec)).map(([type, metadata]) => ({
366
+ label: metadata.label,
367
+ value: type,
368
+ }));
369
+ }
370
+ function getFilterUiMetadata(type) {
371
+ return filterUiMetadata[type];
372
+ }
373
+ function compileFilter(ui) {
374
+ if (ui.type === 'or') {
375
+ return {
376
+ type: 'or',
377
+ filters: compileFilters(ui.filters),
378
+ };
379
+ }
380
+ if (ui.type === 'and') {
381
+ return {
382
+ type: 'and',
383
+ filters: compileFilters(ui.filters),
384
+ };
385
+ }
386
+ if (ui.type === 'not') {
387
+ return {
388
+ type: 'not',
389
+ filter: compileFilter(ui.filter),
390
+ };
391
+ }
392
+ if (ui.type === 'isNA') {
393
+ return {
394
+ type: 'isNA',
395
+ column: ui.column,
396
+ };
397
+ }
398
+ if (ui.type === 'isNotNA') {
399
+ const isNAFilter = { type: 'isNA', column: ui.column };
400
+ const notFilter = { type: 'not', filter: isNAFilter };
401
+ return notFilter;
402
+ }
403
+ if (ui.type === 'patternEquals') {
404
+ return {
405
+ type: 'pattern',
406
+ column: ui.column,
407
+ predicate: {
408
+ type: 'equals',
409
+ value: ui.value,
410
+ },
411
+ };
412
+ }
413
+ if (ui.type === 'patternNotEquals') {
414
+ const patternFilter = {
415
+ type: 'pattern',
416
+ column: ui.column,
417
+ predicate: { type: 'equals', value: ui.value },
418
+ };
419
+ const notFilter = { type: 'not', filter: patternFilter };
420
+ return notFilter;
421
+ }
422
+ if (ui.type === 'patternContainSubsequence') {
423
+ return {
424
+ type: 'pattern',
425
+ column: ui.column,
426
+ predicate: {
427
+ type: 'containSubsequence',
428
+ value: ui.value,
429
+ },
430
+ };
431
+ }
432
+ if (ui.type === 'patternNotContainSubsequence') {
433
+ const patternFilter = {
434
+ type: 'pattern',
435
+ column: ui.column,
436
+ predicate: { type: 'containSubsequence', value: ui.value },
437
+ };
438
+ const notFilter = { type: 'not', filter: patternFilter };
439
+ return notFilter;
440
+ }
441
+ if (ui.type === 'topN') {
442
+ const rankTransform = {
443
+ transformer: 'rank',
444
+ column: ui.column,
445
+ descending: true,
446
+ };
447
+ const comparisonFilter = {
448
+ type: 'numericalComparison',
449
+ lhs: rankTransform,
450
+ rhs: ui.n,
451
+ allowEqual: true,
452
+ };
453
+ return comparisonFilter;
454
+ }
455
+ if (ui.type === 'bottomN') {
456
+ const rankTransform = {
457
+ transformer: 'rank',
458
+ column: ui.column,
459
+ };
460
+ const comparisonFilter = {
461
+ type: 'numericalComparison',
462
+ lhs: rankTransform,
463
+ rhs: ui.n,
464
+ allowEqual: true,
465
+ };
466
+ return comparisonFilter;
467
+ }
468
+ if (ui.type === 'lessThan') {
469
+ return {
470
+ type: 'numericalComparison',
471
+ lhs: ui.column,
472
+ rhs: ui.x,
473
+ };
474
+ }
475
+ if (ui.type === 'greaterThan') {
476
+ return {
477
+ type: 'numericalComparison',
478
+ rhs: ui.column,
479
+ lhs: ui.x,
480
+ };
481
+ }
482
+ if (ui.type === 'greaterThanOrEqual') {
483
+ return {
484
+ type: 'numericalComparison',
485
+ rhs: ui.column,
486
+ lhs: ui.x,
487
+ allowEqual: true,
488
+ };
489
+ }
490
+ if (ui.type === 'lessThanOrEqual') {
491
+ return {
492
+ type: 'numericalComparison',
493
+ lhs: ui.column,
494
+ rhs: ui.x,
495
+ allowEqual: true,
496
+ };
497
+ }
498
+ if (ui.type === 'lessThanColumn') {
499
+ return {
500
+ type: 'numericalComparison',
501
+ lhs: ui.column,
502
+ rhs: ui.rhs,
503
+ minDiff: ui.minDiff,
504
+ allowEqual: undefined,
505
+ };
506
+ }
507
+ if (ui.type === 'lessThanColumnOrEqual') {
508
+ return {
509
+ type: 'numericalComparison',
510
+ lhs: ui.column,
511
+ rhs: ui.rhs,
512
+ minDiff: ui.minDiff,
513
+ allowEqual: true,
514
+ };
515
+ }
516
+ if (ui.type === undefined) {
517
+ throw new Error('Filter type is undefined, this should not happen');
518
+ }
519
+ unreachable(ui);
520
+ }
521
+ function compileFilters(uiFilters) {
522
+ return uiFilters.filter((f) => f.type !== undefined).map(compileFilter);
523
+ }
524
+ function compileAnnotationScript(uiScript) {
525
+ return {
526
+ title: uiScript.title,
527
+ mode: uiScript.mode,
528
+ steps: uiScript.steps
529
+ .filter((step) => {
530
+ // No need to compile empty steps
531
+ if (step.filter.type == null) {
532
+ return false;
533
+ }
534
+ if (step.filter.type === 'or') {
535
+ return step.filter.filters.length > 0;
536
+ }
537
+ if (step.filter.type === 'and') {
538
+ return step.filter.filters.length > 0;
539
+ }
540
+ return false;
541
+ })
542
+ .map((step) => ({
543
+ label: step.label.trim(),
544
+ filter: compileFilter(step.filter),
545
+ })),
546
+ };
547
+ }
548
+
549
+ exports.compileAnnotationScript = compileAnnotationScript;
550
+ exports.compileFilter = compileFilter;
551
+ exports.compileFilters = compileFilters;
552
+ exports.filterUiMetadata = filterUiMetadata;
553
+ exports.getFilterUiMetadata = getFilterUiMetadata;
554
+ exports.getFilterUiTypeOptions = getFilterUiTypeOptions;
555
+ exports.unreachable = unreachable;
556
+ //# sourceMappingURL=filters_ui.cjs.map