@platforma-sdk/model 1.86.0 → 1.86.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +2 -3
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/annotations/converter.cjs +1 -2
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +0 -2
- package/dist/annotations/converter.d.ts.map +1 -1
- package/dist/annotations/converter.js +1 -2
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.js +1 -2
- package/dist/annotations/types.d.ts +0 -2
- package/dist/annotations/types.d.ts.map +1 -1
- package/dist/bconfig/lambdas.d.ts +0 -2
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/normalization.cjs +1 -2
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +0 -2
- package/dist/bconfig/normalization.d.ts.map +1 -1
- package/dist/bconfig/normalization.js +1 -2
- package/dist/bconfig/types.cjs +1 -2
- package/dist/bconfig/types.d.ts +0 -2
- package/dist/bconfig/types.d.ts.map +1 -1
- package/dist/bconfig/types.js +1 -2
- package/dist/bconfig/util.d.ts +1 -2
- package/dist/bconfig/util.d.ts.map +1 -1
- package/dist/bconfig/v3.d.ts +0 -2
- package/dist/bconfig/v3.d.ts.map +1 -1
- package/dist/block_api_v1.d.ts +0 -2
- package/dist/block_api_v1.d.ts.map +1 -1
- package/dist/block_api_v2.d.ts +0 -2
- package/dist/block_api_v2.d.ts.map +1 -1
- package/dist/block_api_v3.d.ts +0 -2
- package/dist/block_api_v3.d.ts.map +1 -1
- package/dist/block_migrations.cjs +3 -3
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts +1 -2
- package/dist/block_migrations.d.ts.map +1 -1
- package/dist/block_migrations.js +3 -3
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +1 -2
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +1 -2
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +1 -2
- package/dist/block_state_patch.d.ts +0 -2
- package/dist/block_state_patch.d.ts.map +1 -1
- package/dist/block_state_util.cjs +1 -2
- package/dist/block_state_util.d.ts +1 -2
- package/dist/block_state_util.d.ts.map +1 -1
- package/dist/block_state_util.js +1 -2
- package/dist/block_storage.cjs +1 -2
- package/dist/block_storage.d.ts +0 -2
- package/dist/block_storage.d.ts.map +1 -1
- package/dist/block_storage.js +1 -2
- package/dist/block_storage_callbacks.cjs +9 -7
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js +9 -7
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/block_storage_facade.cjs +1 -2
- package/dist/block_storage_facade.cjs.map +1 -1
- package/dist/block_storage_facade.d.ts +0 -2
- package/dist/block_storage_facade.d.ts.map +1 -1
- package/dist/block_storage_facade.js +1 -2
- package/dist/block_storage_facade.js.map +1 -1
- package/dist/columns/column.cjs +1 -2
- package/dist/columns/column.d.ts +0 -2
- package/dist/columns/column.d.ts.map +1 -1
- package/dist/columns/column.js +1 -2
- package/dist/columns/column_providers/index.cjs +1 -2
- package/dist/columns/column_providers/index.d.ts +0 -2
- package/dist/columns/column_providers/index.d.ts.map +1 -1
- package/dist/columns/column_providers/index.js +1 -2
- package/dist/columns/column_providers/providers.cjs +11 -4
- package/dist/columns/column_providers/providers.cjs.map +1 -1
- package/dist/columns/column_providers/providers.d.ts +0 -2
- package/dist/columns/column_providers/providers.d.ts.map +1 -1
- package/dist/columns/column_providers/providers.js +12 -5
- package/dist/columns/column_providers/providers.js.map +1 -1
- package/dist/columns/column_providers/types.d.ts +0 -2
- package/dist/columns/column_providers/types.d.ts.map +1 -1
- package/dist/columns/column_recipes/column_discovered_recipe.cjs +1 -2
- package/dist/columns/column_recipes/column_discovered_recipe.cjs.map +1 -1
- package/dist/columns/column_recipes/column_discovered_recipe.d.ts +0 -2
- package/dist/columns/column_recipes/column_discovered_recipe.d.ts.map +1 -1
- package/dist/columns/column_recipes/column_discovered_recipe.js +1 -2
- package/dist/columns/column_recipes/column_filtered_recipe.cjs +1 -2
- package/dist/columns/column_recipes/column_filtered_recipe.cjs.map +1 -1
- package/dist/columns/column_recipes/column_filtered_recipe.d.ts +0 -2
- package/dist/columns/column_recipes/column_filtered_recipe.d.ts.map +1 -1
- package/dist/columns/column_recipes/column_filtered_recipe.js +1 -2
- package/dist/columns/column_recipes/column_overrided_recipe.cjs +1 -2
- package/dist/columns/column_recipes/column_overrided_recipe.cjs.map +1 -1
- package/dist/columns/column_recipes/column_overrided_recipe.d.ts +1 -2
- package/dist/columns/column_recipes/column_overrided_recipe.d.ts.map +1 -1
- package/dist/columns/column_recipes/column_overrided_recipe.js +1 -2
- package/dist/columns/column_recipes/index.cjs +1 -2
- package/dist/columns/column_recipes/index.cjs.map +1 -1
- package/dist/columns/column_recipes/index.d.ts +0 -2
- package/dist/columns/column_recipes/index.d.ts.map +1 -1
- package/dist/columns/column_recipes/index.js +1 -2
- package/dist/columns/column_recipes/leaf_rebrand.cjs +1 -2
- package/dist/columns/column_recipes/leaf_rebrand.cjs.map +1 -1
- package/dist/columns/column_recipes/leaf_rebrand.js +1 -2
- package/dist/columns/column_recipes/types.d.ts +0 -2
- package/dist/columns/column_recipes/types.d.ts.map +1 -1
- package/dist/columns/columns_collection.cjs +1 -2
- package/dist/columns/columns_collection.cjs.map +1 -1
- package/dist/columns/columns_collection.d.ts +0 -2
- package/dist/columns/columns_collection.d.ts.map +1 -1
- package/dist/columns/columns_collection.js +1 -2
- package/dist/columns/data_column.cjs +21 -21
- package/dist/columns/data_column.cjs.map +1 -1
- package/dist/columns/data_column.d.ts +8 -6
- package/dist/columns/data_column.d.ts.map +1 -1
- package/dist/columns/data_column.js +22 -22
- package/dist/columns/data_column.js.map +1 -1
- package/dist/columns/derive_axis_values_labels.cjs +1 -2
- package/dist/columns/derive_axis_values_labels.cjs.map +1 -1
- package/dist/columns/derive_axis_values_labels.d.ts +0 -2
- package/dist/columns/derive_axis_values_labels.d.ts.map +1 -1
- package/dist/columns/derive_axis_values_labels.js +1 -2
- package/dist/columns/peer_links.cjs +1 -2
- package/dist/columns/peer_links.cjs.map +1 -1
- package/dist/columns/peer_links.d.ts +0 -2
- package/dist/columns/peer_links.d.ts.map +1 -1
- package/dist/columns/peer_links.js +1 -2
- package/dist/columns/split_by_axes.cjs +1 -2
- package/dist/columns/split_by_axes.cjs.map +1 -1
- package/dist/columns/split_by_axes.d.ts +0 -2
- package/dist/columns/split_by_axes.d.ts.map +1 -1
- package/dist/columns/split_by_axes.js +1 -2
- package/dist/columns/split_by_axes.js.map +1 -1
- package/dist/columns/utils.cjs +4 -4
- package/dist/columns/utils.cjs.map +1 -1
- package/dist/columns/utils.d.ts +0 -2
- package/dist/columns/utils.d.ts.map +1 -1
- package/dist/columns/utils.js +4 -4
- package/dist/columns/utils.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +1 -2
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +0 -2
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.js +1 -2
- package/dist/components/PlAnnotations/filter.d.ts +0 -2
- package/dist/components/PlAnnotations/filter.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.cjs +1 -2
- package/dist/components/PlAnnotations/filters_ui.d.ts +0 -2
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.js +1 -2
- package/dist/components/PlDataTable/columnResolver.cjs +1 -2
- package/dist/components/PlDataTable/columnResolver.cjs.map +1 -1
- package/dist/components/PlDataTable/columnResolver.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts +0 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +0 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.d.ts +0 -2
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/index.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts +0 -2
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/index.js +1 -2
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs +6 -5
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.d.ts +0 -2
- package/dist/components/PlDataTable/createPlDataTable/utils.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.js +6 -5
- package/dist/components/PlDataTable/createPlDataTable/utils.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs +1 -2
- package/dist/components/PlDataTable/createPlDataTableSheet.d.ts +0 -2
- package/dist/components/PlDataTable/createPlDataTableSheet.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTableSheet.js +1 -2
- package/dist/components/PlDataTable/labels.cjs +1 -2
- package/dist/components/PlDataTable/labels.cjs.map +1 -1
- package/dist/components/PlDataTable/labels.js +1 -2
- package/dist/components/PlDataTable/state-migration.cjs +1 -2
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +0 -2
- package/dist/components/PlDataTable/state-migration.d.ts.map +1 -1
- package/dist/components/PlDataTable/state-migration.js +1 -2
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/typesV4.d.ts +0 -2
- package/dist/components/PlDataTable/typesV4.d.ts.map +1 -1
- package/dist/components/PlDataTable/typesV5.d.ts +0 -2
- package/dist/components/PlDataTable/typesV5.d.ts.map +1 -1
- package/dist/components/PlDataTable/typesV6.d.ts +0 -2
- package/dist/components/PlDataTable/typesV6.d.ts.map +1 -1
- package/dist/components/PlDataTable/typesV7.d.ts +0 -2
- package/dist/components/PlDataTable/typesV7.d.ts.map +1 -1
- package/dist/components/PlDataTable/typesV8.d.ts +0 -2
- package/dist/components/PlDataTable/typesV8.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs +2 -3
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.d.ts +1 -2
- package/dist/components/PlDatasetSelector/build_dataset_options.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.js +3 -4
- package/dist/components/PlDatasetSelector/build_dataset_options.js.map +1 -1
- package/dist/components/PlDatasetSelector/dataset_selection.cjs +1 -2
- package/dist/components/PlDatasetSelector/dataset_selection.d.ts +0 -2
- package/dist/components/PlDatasetSelector/dataset_selection.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/dataset_selection.js +1 -2
- package/dist/components/PlDatasetSelector/enrichment_discovery.cjs +4 -4
- package/dist/components/PlDatasetSelector/enrichment_discovery.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/enrichment_discovery.js +4 -4
- package/dist/components/PlDatasetSelector/enrichment_discovery.js.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.cjs +1 -2
- package/dist/components/PlDatasetSelector/filter_discovery.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.d.ts +0 -2
- package/dist/components/PlDatasetSelector/filter_discovery.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.js +1 -2
- package/dist/components/PlMultiSequenceAlignment.cjs +1 -2
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +0 -2
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.js +1 -2
- package/dist/components/PlSelectionModel.cjs +1 -2
- package/dist/components/PlSelectionModel.d.ts +0 -2
- package/dist/components/PlSelectionModel.d.ts.map +1 -1
- package/dist/components/PlSelectionModel.js +1 -2
- package/dist/config/model.d.ts +0 -2
- package/dist/config/model.d.ts.map +1 -1
- package/dist/config/type_engine.d.ts +1 -2
- package/dist/config/type_engine.d.ts.map +1 -1
- package/dist/env_value.cjs +1 -2
- package/dist/env_value.d.ts +0 -2
- package/dist/env_value.d.ts.map +1 -1
- package/dist/env_value.js +1 -2
- package/dist/filters/converters/filterToQuery.cjs +1 -2
- package/dist/filters/converters/filterToQuery.d.ts +0 -2
- package/dist/filters/converters/filterToQuery.d.ts.map +1 -1
- package/dist/filters/converters/filterToQuery.js +1 -2
- package/dist/filters/converters/filterUiToExpressionImpl.cjs +1 -2
- package/dist/filters/converters/filterUiToExpressionImpl.cjs.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts +0 -2
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.js +1 -2
- package/dist/filters/distill.cjs +1 -2
- package/dist/filters/distill.cjs.map +1 -1
- package/dist/filters/distill.d.ts +1 -3
- package/dist/filters/distill.d.ts.map +1 -1
- package/dist/filters/distill.js +1 -2
- package/dist/filters/distill.js.map +1 -1
- package/dist/filters/traverse.cjs +1 -2
- package/dist/filters/traverse.js +1 -2
- package/dist/filters/types.d.ts +0 -2
- package/dist/filters/types.d.ts.map +1 -1
- package/dist/internal.cjs +1 -2
- package/dist/internal.js +1 -2
- package/dist/labels/derive_distinct_labels.cjs +1 -2
- package/dist/labels/derive_distinct_labels.cjs.map +1 -1
- package/dist/labels/derive_distinct_labels.d.ts +0 -2
- package/dist/labels/derive_distinct_labels.d.ts.map +1 -1
- package/dist/labels/derive_distinct_labels.js +1 -2
- package/dist/labels/derive_distinct_labels.js.map +1 -1
- package/dist/labels/derive_distinct_tooltips.cjs +1 -2
- package/dist/labels/derive_distinct_tooltips.cjs.map +1 -1
- package/dist/labels/derive_distinct_tooltips.d.ts +0 -2
- package/dist/labels/derive_distinct_tooltips.d.ts.map +1 -1
- package/dist/labels/derive_distinct_tooltips.js +1 -2
- package/dist/labels/linked_column_postfix.cjs +1 -2
- package/dist/labels/linked_column_postfix.cjs.map +1 -1
- package/dist/labels/linked_column_postfix.d.ts +0 -2
- package/dist/labels/linked_column_postfix.d.ts.map +1 -1
- package/dist/labels/linked_column_postfix.js +1 -2
- package/dist/package.cjs +2 -3
- package/dist/package.js +2 -3
- package/dist/pframe.cjs +1 -2
- package/dist/pframe.d.ts +0 -2
- package/dist/pframe.d.ts.map +1 -1
- package/dist/pframe.js +1 -2
- package/dist/pframe_utils/axes.cjs +3 -3
- package/dist/pframe_utils/axes.cjs.map +1 -1
- package/dist/pframe_utils/axes.d.ts +0 -2
- package/dist/pframe_utils/axes.d.ts.map +1 -1
- package/dist/pframe_utils/axes.js +3 -3
- package/dist/pframe_utils/axes.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +10 -7
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +0 -2
- package/dist/pframe_utils/columns.d.ts.map +1 -1
- package/dist/pframe_utils/columns.js +10 -7
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +1 -2
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +0 -2
- package/dist/pframe_utils/index.d.ts.map +1 -1
- package/dist/pframe_utils/index.js +1 -2
- package/dist/platforma.d.ts +0 -2
- package/dist/platforma.d.ts.map +1 -1
- package/dist/plugin_handle.cjs +1 -2
- package/dist/plugin_handle.d.ts +0 -2
- package/dist/plugin_handle.d.ts.map +1 -1
- package/dist/plugin_handle.js +1 -2
- package/dist/plugin_model.cjs +1 -2
- package/dist/plugin_model.d.ts +1 -2
- package/dist/plugin_model.d.ts.map +1 -1
- package/dist/plugin_model.js +1 -2
- package/dist/raw_globals.cjs +1 -2
- package/dist/raw_globals.d.ts +0 -2
- package/dist/raw_globals.d.ts.map +1 -1
- package/dist/raw_globals.js +1 -2
- package/dist/render/accessor.cjs +1 -2
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +1 -2
- package/dist/render/accessor.d.ts.map +1 -1
- package/dist/render/accessor.js +1 -2
- package/dist/render/api.cjs +10 -8
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +1 -2
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +10 -8
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs +1 -2
- package/dist/render/future.d.ts +0 -2
- package/dist/render/future.d.ts.map +1 -1
- package/dist/render/future.js +1 -2
- package/dist/render/internal.cjs +1 -2
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +0 -1
- package/dist/render/internal.js +1 -2
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +0 -2
- package/dist/render/traversal_ops.d.ts.map +1 -1
- package/dist/render/util/axis_filtering.cjs +1 -2
- package/dist/render/util/axis_filtering.d.ts +0 -2
- package/dist/render/util/axis_filtering.d.ts.map +1 -1
- package/dist/render/util/axis_filtering.js +1 -2
- package/dist/render/util/column_collection.cjs +3 -3
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +1 -2
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/column_collection.js +3 -3
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/label.cjs +3 -3
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +0 -2
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/render/util/label.js +3 -3
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +23 -26
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +1 -2
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js +23 -26
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +1 -2
- package/dist/render/util/pframe_upgraders.js +1 -2
- package/dist/render/util/split_selectors.d.ts +0 -2
- package/dist/render/util/split_selectors.d.ts.map +1 -1
- package/dist/services/block_services.cjs +1 -2
- package/dist/services/block_services.cjs.map +1 -1
- package/dist/services/block_services.d.ts +0 -2
- package/dist/services/block_services.d.ts.map +1 -1
- package/dist/services/block_services.js +1 -2
- package/dist/services/get_services.cjs +1 -2
- package/dist/services/get_services.d.ts +0 -2
- package/dist/services/get_services.d.ts.map +1 -1
- package/dist/services/get_services.js +1 -2
- package/dist/services/service_bridge.cjs +1 -2
- package/dist/services/service_bridge.d.ts +0 -2
- package/dist/services/service_bridge.d.ts.map +1 -1
- package/dist/services/service_bridge.js +1 -2
- package/dist/services/service_resolve.d.ts +0 -2
- package/dist/services/service_resolve.d.ts.map +1 -1
- package/dist/version.cjs +1 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -2
- package/package.json +17 -17
- package/src/annotations/converter.ts +5 -10
- package/src/block_storage_facade.ts +3 -1
- package/src/columns/__test_helpers__/collection_driver.ts +10 -8
- package/src/columns/__test_helpers__/stub_registry.ts +6 -8
- package/src/columns/column_providers/providers.test.ts +45 -0
- package/src/columns/column_providers/providers.ts +20 -7
- package/src/columns/columns_collection.test.ts +39 -0
- package/src/columns/data_column.test.ts +10 -0
- package/src/columns/data_column.ts +23 -19
- package/src/columns/split_by_axes.ts +4 -3
- package/src/components/PlDataTable/state-migration.ts +4 -6
- package/src/components/PlDatasetSelector/build_dataset_options.ts +7 -4
- package/src/filters/distill.ts +2 -2
- package/src/labels/derive_distinct_labels.test.ts +1 -1
- package/src/labels/derive_distinct_labels.ts +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ColumnOverriddenRecipe } from "./column_recipes/column_overrided_recipe.js";
|
|
2
2
|
import { getCtxProviders } from "./column_providers/index.js";
|
|
3
|
-
import { ColumnRegistry, createGlobalPObjectId, isPColumn, isPlRef } from "@milaboratories/pl-model-common";
|
|
3
|
+
import { ColumnRegistry, createGlobalPObjectId, isPColumn, isPColumnSpec, isPlRef } from "@milaboratories/pl-model-common";
|
|
4
4
|
import { isNil } from "es-toolkit";
|
|
5
5
|
import { LRUCache } from "lru-cache";
|
|
6
|
-
|
|
6
|
+
// src/columns/data_column.ts
|
|
7
7
|
/**
|
|
8
8
|
* Thrown by leaf-recipe factories when the requested column is provably
|
|
9
9
|
* absent in the active render ctx — i.e. every relevant accessor reports
|
|
@@ -77,8 +77,9 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
77
77
|
* Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:
|
|
78
78
|
* returns `undefined` if the leaf isn't reachable yet (resolving). Throws
|
|
79
79
|
* {@link ColumnAbsentError} when every relevant accessor is `inputsLocked`
|
|
80
|
-
* and the column did not appear
|
|
81
|
-
*
|
|
80
|
+
* and the column did not appear, or when the id names an export that is not
|
|
81
|
+
* a column (a `kind: "File"` object, for example) — the column will not
|
|
82
|
+
* exist in this ctx. Data and dataStatus stay lazy.
|
|
82
83
|
*/
|
|
83
84
|
static fromId(id, { ctx } = {}) {
|
|
84
85
|
const registry = new ColumnRegistry(getCtxProviders({ ctx }));
|
|
@@ -87,17 +88,7 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
87
88
|
if (registry.isFinal()) throw new ColumnAbsentError(id);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
if (isNil(spec)) {
|
|
92
|
-
if (leaf.accessor.getInputsLocked()) throw new ColumnAbsentError(id);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!spec.hasData()) return void 0;
|
|
96
|
-
return new DataColumnImpl(id, {
|
|
97
|
-
getSpec: () => spec.getDataAsJson(),
|
|
98
|
-
getData: () => readDataAccessor(leaf),
|
|
99
|
-
getDataStatus: () => readDataStatus(leaf)
|
|
100
|
-
});
|
|
91
|
+
return DataColumnImpl.fromAccessor(leaf);
|
|
101
92
|
}
|
|
102
93
|
/** {@link PlRef} wrapper over {@link fromId}. */
|
|
103
94
|
static fromPlRef(ref) {
|
|
@@ -106,17 +97,19 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
106
97
|
/**
|
|
107
98
|
* Bind directly to an accessor-backed {@link LeafEntry} — no registry.
|
|
108
99
|
* Throws {@link ColumnAbsentError} if the leaf has no spec field and its
|
|
109
|
-
* accessor is `inputsLocked
|
|
100
|
+
* accessor is `inputsLocked`, or if it names an export that is not a column.
|
|
101
|
+
* Returns `undefined` while still resolving.
|
|
110
102
|
*/
|
|
111
103
|
static fromAccessor(entry) {
|
|
112
|
-
|
|
113
|
-
if (isNil(spec)) {
|
|
104
|
+
if (isNil(readSpecAccessor(entry))) {
|
|
114
105
|
if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);
|
|
115
106
|
return;
|
|
116
107
|
}
|
|
117
|
-
|
|
108
|
+
const spec = readSpec(entry);
|
|
109
|
+
if (spec === void 0) return void 0;
|
|
110
|
+
if (!isPColumnSpec(spec)) throw new ColumnAbsentError(entry.id);
|
|
118
111
|
return new DataColumnImpl(entry.id, {
|
|
119
|
-
getSpec: () => spec
|
|
112
|
+
getSpec: () => spec,
|
|
120
113
|
getData: () => readDataAccessor(entry),
|
|
121
114
|
getDataStatus: () => readDataStatus(entry)
|
|
122
115
|
});
|
|
@@ -138,7 +131,9 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
138
131
|
* Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}
|
|
139
132
|
* in the active render ctx. Falls back to the registry's `isFinal()`
|
|
140
133
|
* when the id has no entry — only then we can say `absent` instead of
|
|
141
|
-
* `resolving`.
|
|
134
|
+
* `resolving`. The status tells only whether the spec is readable: for an
|
|
135
|
+
* export that is not a column it is `present`, and the factories throw
|
|
136
|
+
* {@link ColumnAbsentError}.
|
|
142
137
|
*/
|
|
143
138
|
static getStatusById(id, { ctx } = {}) {
|
|
144
139
|
const registry = new ColumnRegistry(getCtxProviders({ ctx }));
|
|
@@ -207,6 +202,12 @@ const readSpecAccessor = memoizeByEntry(({ accessor, name }) => accessor.travers
|
|
|
207
202
|
assertFieldType: "Input",
|
|
208
203
|
ignoreError: true
|
|
209
204
|
}));
|
|
205
|
+
/** The leaf's spec, or `undefined` until the spec resource has data. */
|
|
206
|
+
const readSpec = memoizeByEntry((entry) => {
|
|
207
|
+
const spec = readSpecAccessor(entry);
|
|
208
|
+
if (isNil(spec) || !spec.hasData()) return void 0;
|
|
209
|
+
return spec.getDataAsJson();
|
|
210
|
+
});
|
|
210
211
|
/**
|
|
211
212
|
* Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's
|
|
212
213
|
* **spec** can be read in this ctx, and — for the negative cases —
|
|
@@ -242,7 +243,6 @@ function memoizeByEntry(fn) {
|
|
|
242
243
|
return hit.value;
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
|
-
//#endregion
|
|
246
246
|
export { ColumnAbsentError, DataColumn, DataColumnImpl, isDataColumn };
|
|
247
247
|
|
|
248
248
|
//# sourceMappingURL=data_column.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_column.js","names":[],"sources":["../../src/columns/data_column.ts"],"sourcesContent":["import {\n ColumnRegistry,\n createGlobalPObjectId,\n isPColumn,\n isPlRef,\n PlRef,\n PObjectId,\n type ColumnUniversalId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\n type SpecOverrides,\n type SpecQuery,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCtxProviders } from \"./column_providers\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\nimport { TreeNodeAccessor } from \"../render\";\nimport type {\n ColumnFieldStatus,\n ColumnRecipe,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./column_recipes/types\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\n\nexport type DataColumnId = PObjectId;\nexport type ColumnData = undefined | PColumnDataUniversal;\nexport type { ColumnFieldStatus, ColumnResolutionStatus } from \"./column_recipes/types\";\n\n/**\n * A {@link ColumnRecipe} that can be read directly in the sandbox: its\n * {@link getData} is guaranteed to be consistent with {@link getSpec}.\n *\n * This is a *capability*, not a class. Only two recipe shapes carry it — a\n * bare leaf and a spec-override over a bare leaf — because those are the only\n * ones whose data still matches their spec. An axis-filtered recipe drops axes\n * from its spec while the underlying data keeps them, and a discovered recipe\n * only materialises after a join; neither can be read here, so neither\n * implements this interface.\n *\n * Narrow to it with `hasReachableData(recipe)` rather than testing for a concrete\n * class — which recipe classes exist is an implementation detail behind\n * `recipe.id`.\n */\nexport interface DataColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipe<ID> {\n /** Column data, consistent with {@link ColumnRecipe.getSpec}. */\n getData(): ColumnData;\n}\n\n/**\n * Thrown by leaf-recipe factories when the requested column is provably\n * absent in the active render ctx — i.e. every relevant accessor reports\n * `inputsLocked` and the column did not appear. Distinct from the\n * `undefined` return that the factories still use for the \"resolving\" case\n * (the column may still appear later).\n *\n * Catch at the boundary (resolver / filter+sort wiring / data-table assembly)\n * when partial absence should be surfaced to the user rather than silently\n * producing an empty result.\n */\nexport class ColumnAbsentError extends Error {\n constructor(public readonly id: ColumnUniversalId) {\n super(`Column is absent in the active render ctx and will not appear: ${id}`);\n this.name = \"ColumnAbsentError\";\n }\n}\n\n/**\n * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare\n * {@link PObjectId} and whose readers are bound to a single tree-accessor\n * leaf. Layered encodings (Overridden / Discovered / Filtered) are reified\n * through their dedicated recipe classes and reference leaf columns by id.\n *\n * Internal — consumers hold the {@link DataColumnRecipe} interface and construct\n * through the {@link DataColumnRecipe} dispatcher.\n */\nexport class DataColumnImpl implements DataColumnRecipe<PObjectId> {\n private specCache?: { readonly value: PColumnSpec };\n private dataCache?: { readonly value: ColumnData };\n private dataStatusCache?: { readonly value: ColumnFieldStatus };\n\n private constructor(\n public readonly id: PObjectId,\n private readonly options: {\n getSpec: () => PColumnSpec;\n getData: () => ColumnData;\n getDataStatus: () => ColumnFieldStatus;\n },\n ) {}\n\n /** A leaf-recipe references exactly one column — its own id. */\n getReferencedIds(): PObjectId[] {\n return [this.id];\n }\n\n getSpec(): PColumnSpec {\n if (this.specCache === undefined) {\n this.specCache = { value: this.options.getSpec() };\n }\n return this.specCache.value;\n }\n\n /** Leaf-shaped — points straight at `this.id`. */\n getQuery(): SpecQuery {\n return { type: \"column\", column: this.id } as SpecQuery;\n }\n\n getData(): ColumnData {\n if (this.dataCache === undefined) this.dataCache = { value: this.options.getData() };\n return this.dataCache.value;\n }\n\n getDataStatus(): ColumnFieldStatus {\n if (this.dataStatusCache === undefined) {\n this.dataStatusCache = { value: this.options.getDataStatus() };\n }\n return this.dataStatusCache.value;\n }\n\n /**\n * Overlay overrides → produces a {@link ColumnOverriddenRecipe} wrapping\n * this leaf. The leaf itself stays bare (id remains a plain PObjectId);\n * layering lives entirely in the recipe wrappers.\n */\n withSpecs(overrides: SpecOverrides): ColumnRecipe {\n return ColumnOverriddenRecipe.wrap(this, overrides);\n }\n\n /**\n * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:\n * returns `undefined` if the leaf isn't reachable yet (resolving). Throws\n * {@link ColumnAbsentError} when every relevant accessor is `inputsLocked`\n * and the column did not appear — the column will not exist in this ctx.\n * Data and dataStatus stay lazy.\n */\n static fromId(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): undefined | DataColumnRecipe<PObjectId> {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) {\n if (registry.isFinal()) throw new ColumnAbsentError(id);\n return undefined;\n }\n const spec = readSpecAccessor(leaf);\n if (isNil(spec)) {\n if (leaf.accessor.getInputsLocked()) throw new ColumnAbsentError(id);\n return undefined;\n }\n if (!spec.hasData()) return undefined;\n return new DataColumnImpl(id, {\n getSpec: () => spec.getDataAsJson<PColumnSpec>(),\n getData: () => readDataAccessor(leaf),\n getDataStatus: () => readDataStatus(leaf),\n });\n }\n\n /** {@link PlRef} wrapper over {@link fromId}. */\n static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId> {\n return DataColumnImpl.fromId(createGlobalPObjectId(ref.blockId, ref.name));\n }\n\n /**\n * Bind directly to an accessor-backed {@link LeafEntry} — no registry.\n * Throws {@link ColumnAbsentError} if the leaf has no spec field and its\n * accessor is `inputsLocked`. Returns `undefined` while still resolving.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) {\n if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);\n return undefined;\n }\n if (!spec.hasData()) return undefined;\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec.getDataAsJson<PColumnSpec>(),\n getData: () => readDataAccessor(entry),\n getDataStatus: () => readDataStatus(entry),\n });\n }\n\n /**\n * Wrap a materialised {@link PColumn}. If the input is already a\n * {@link DataColumnRecipe} leaf it is returned as-is.\n */\n static fromColumn(\n column: PColumn<ColumnData> | DataColumnRecipe<PObjectId>,\n ): DataColumnRecipe<PObjectId> {\n if (column instanceof DataColumnImpl) return column;\n // `DataColumnRecipe` is an interface, so `instanceof` above does not remove it\n // from the union. The only implementation carrying a bare `PObjectId` is\n // `DataColumnImpl` (wrappers expose `ColumnUniversalId`), so anything\n // reaching here is a materialised `PColumn`.\n const pColumn = column as PColumn<ColumnData>;\n return new DataColumnImpl(pColumn.id, {\n getSpec: () => pColumn.spec,\n getData: () => pColumn.data,\n getDataStatus: () => \"present\",\n });\n }\n\n /**\n * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}\n * in the active render ctx. Falls back to the registry's `isFinal()`\n * when the id has no entry — only then we can say `absent` instead of\n * `resolving`.\n */\n static getStatusById(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) return registry.isFinal() ? \"absent\" : \"resolving\";\n return getLeafEntryStatus(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link getStatusById}. */\n static getStatusByPlRef(\n ref: PlRef,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n return DataColumnImpl.getStatusById(createGlobalPObjectId(ref.blockId, ref.name), opts);\n }\n\n /** No registry — reads straight off the entry's accessor. */\n static getStatusByAccessor(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n return getLeafEntryStatus(entry);\n }\n}\n\n/** Anything the {@link DataColumnRecipe} dispatcher can build a leaf from. */\nexport type DataColumnSource =\n | PObjectId\n | PlRef\n | LeafEntry<TreeNodeAccessor>\n | PColumn<ColumnData>\n | DataColumnRecipe<PObjectId>;\n\n/**\n * Unified dispatcher — picks the right `DataColumnImpl.fromX` by source\n * shape. For ambiguous inputs callers can still use the explicit factories\n * (also attached as properties: `DataColumn.fromId`, `.fromPlRef`,\n * `.fromAccessor`, `.fromColumn`).\n */\nfunction DataColumnDispatch(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | DataColumnRecipe<PObjectId> {\n if (typeof source === \"string\") return DataColumnImpl.fromId(source, opts);\n if (source instanceof DataColumnImpl) return source;\n // `DataColumnRecipe` is an interface — `instanceof` above cannot remove it from\n // the union, and only `DataColumnImpl` implements it with a bare id.\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.fromAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.fromPlRef(rest);\n if (isPColumn(rest)) return DataColumnImpl.fromColumn(rest);\n throw new Error(\"DataColumn: unknown source shape\");\n}\n\n/**\n * Polymorphic counterpart to {@link DataColumnDispatch}: returns the\n * {@link ColumnResolutionStatus} for any factory input without constructing\n * the recipe. For already-materialised sources ({@link PColumn} value,\n * existing {@link DataColumnRecipe}) status is `present` by construction.\n */\nfunction DataColumnGetStatus(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n if (typeof source === \"string\") return DataColumnImpl.getStatusById(source, opts);\n if (source instanceof DataColumnImpl) return \"present\";\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.getStatusByAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.getStatusByPlRef(rest, opts);\n if (isPColumn(rest)) return \"present\";\n throw new Error(\"DataColumn.getStatus: unknown source shape\");\n}\n\nexport const DataColumn = Object.assign(DataColumnDispatch, {\n fromId: DataColumnImpl.fromId,\n fromPlRef: DataColumnImpl.fromPlRef,\n fromAccessor: DataColumnImpl.fromAccessor,\n fromColumn: DataColumnImpl.fromColumn,\n getStatus: DataColumnGetStatus,\n getStatusById: DataColumnImpl.getStatusById,\n getStatusByPlRef: DataColumnImpl.getStatusByPlRef,\n getStatusByAccessor: DataColumnImpl.getStatusByAccessor,\n});\n\n/**\n * Type-guard narrowing to a bare leaf — a {@link DataColumnRecipe} whose `id` is a\n * plain {@link PObjectId}.\n */\nexport function isDataColumn(value: unknown): value is DataColumnRecipe<PObjectId> {\n return value instanceof DataColumnImpl;\n}\n\nconst readSpecAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.spec`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\n/**\n * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's\n * **spec** can be read in this ctx, and — for the negative cases —\n * distinguishes `resolving` from `absent` via `getInputsLocked()`.\n *\n * - spec field not yet on the entry's accessor + inputs locked → `absent`\n * - spec field not yet on the entry's accessor + still resolving → `resolving`\n * - spec resource present but bytes not yet written → `resolving`\n * (transient — the spec resource is connected, just unfilled)\n * - spec resource present and `hasData()` → `present`\n */\nfunction getLeafEntryStatus(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) return entry.accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n if (!spec.hasData()) return \"resolving\";\n return \"present\";\n}\n\nconst readDataAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.data`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\nconst readDataStatus = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): ColumnFieldStatus => {\n if (accessor.listInputFields().includes(`${name}.data`)) return \"present\";\n return accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n },\n);\n\nfunction memoizeByEntry<R>(\n fn: (entry: LeafEntry<TreeNodeAccessor>) => R,\n): (entry: LeafEntry<TreeNodeAccessor>) => R {\n const cache = new LRUCache<string, { value: R }>({ max: 1000 });\n return (entry) => {\n const key = `${entry.accessor.handle}:${entry.name}`;\n let hit = cache.get(key);\n if (!hit) cache.set(key, (hit = { value: fn(entry) }));\n return hit.value;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgEA,IAAa,oBAAb,cAAuC,MAAM;CACf;CAA5B,YAAY,IAAuC;EACjD,MAAM,kEAAkE,IAAI;EADlD,KAAA,KAAA;EAE1B,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,IAAa,iBAAb,MAAa,eAAsD;CAM/C;CACC;CANnB;CACA;CACA;CAEA,YACE,IACA,SAKA;EANgB,KAAA,KAAA;EACC,KAAA,UAAA;CAKhB;;CAGH,mBAAgC;EAC9B,OAAO,CAAC,KAAK,EAAE;CACjB;CAEA,UAAuB;EACrB,IAAI,KAAK,cAAc,KAAA,GACrB,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EAEnD,OAAO,KAAK,UAAU;CACxB;;CAGA,WAAsB;EACpB,OAAO;GAAE,MAAM;GAAU,QAAQ,KAAK;EAAG;CAC3C;CAEA,UAAsB;EACpB,IAAI,KAAK,cAAc,KAAA,GAAW,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EACnF,OAAO,KAAK,UAAU;CACxB;CAEA,gBAAmC;EACjC,IAAI,KAAK,oBAAoB,KAAA,GAC3B,KAAK,kBAAkB,EAAE,OAAO,KAAK,QAAQ,cAAc,EAAE;EAE/D,OAAO,KAAK,gBAAgB;CAC9B;;;;;;CAOA,UAA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,\n createGlobalPObjectId,\n isPColumn,\n isPColumnSpec,\n isPlRef,\n PlRef,\n PObjectId,\n type ColumnUniversalId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\n type PObjectSpec,\n type SpecOverrides,\n type SpecQuery,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCtxProviders } from \"./column_providers\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\nimport { TreeNodeAccessor } from \"../render\";\nimport type {\n ColumnFieldStatus,\n ColumnRecipe,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./column_recipes/types\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\n\nexport type DataColumnId = PObjectId;\nexport type ColumnData = undefined | PColumnDataUniversal;\nexport type { ColumnFieldStatus, ColumnResolutionStatus } from \"./column_recipes/types\";\n\n/**\n * A {@link ColumnRecipe} that can be read directly in the sandbox: its\n * {@link getData} is guaranteed to be consistent with {@link getSpec}.\n *\n * This is a *capability*, not a class. Only two recipe shapes carry it — a\n * bare leaf and a spec-override over a bare leaf — because those are the only\n * ones whose data still matches their spec. An axis-filtered recipe drops axes\n * from its spec while the underlying data keeps them, and a discovered recipe\n * only materialises after a join; neither can be read here, so neither\n * implements this interface.\n *\n * Narrow to it with `hasReachableData(recipe)` rather than testing for a concrete\n * class — which recipe classes exist is an implementation detail behind\n * `recipe.id`.\n */\nexport interface DataColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipe<ID> {\n /** Column data, consistent with {@link ColumnRecipe.getSpec}. */\n getData(): ColumnData;\n}\n\n/**\n * Thrown by leaf-recipe factories when the requested column is provably\n * absent in the active render ctx — i.e. every relevant accessor reports\n * `inputsLocked` and the column did not appear. Distinct from the\n * `undefined` return that the factories still use for the \"resolving\" case\n * (the column may still appear later).\n *\n * Catch at the boundary (resolver / filter+sort wiring / data-table assembly)\n * when partial absence should be surfaced to the user rather than silently\n * producing an empty result.\n */\nexport class ColumnAbsentError extends Error {\n constructor(public readonly id: ColumnUniversalId) {\n super(`Column is absent in the active render ctx and will not appear: ${id}`);\n this.name = \"ColumnAbsentError\";\n }\n}\n\n/**\n * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare\n * {@link PObjectId} and whose readers are bound to a single tree-accessor\n * leaf. Layered encodings (Overridden / Discovered / Filtered) are reified\n * through their dedicated recipe classes and reference leaf columns by id.\n *\n * Internal — consumers hold the {@link DataColumnRecipe} interface and construct\n * through the {@link DataColumnRecipe} dispatcher.\n */\nexport class DataColumnImpl implements DataColumnRecipe<PObjectId> {\n private specCache?: { readonly value: PColumnSpec };\n private dataCache?: { readonly value: ColumnData };\n private dataStatusCache?: { readonly value: ColumnFieldStatus };\n\n private constructor(\n public readonly id: PObjectId,\n private readonly options: {\n getSpec: () => PColumnSpec;\n getData: () => ColumnData;\n getDataStatus: () => ColumnFieldStatus;\n },\n ) {}\n\n /** A leaf-recipe references exactly one column — its own id. */\n getReferencedIds(): PObjectId[] {\n return [this.id];\n }\n\n getSpec(): PColumnSpec {\n if (this.specCache === undefined) {\n this.specCache = { value: this.options.getSpec() };\n }\n return this.specCache.value;\n }\n\n /** Leaf-shaped — points straight at `this.id`. */\n getQuery(): SpecQuery {\n return { type: \"column\", column: this.id } as SpecQuery;\n }\n\n getData(): ColumnData {\n if (this.dataCache === undefined) this.dataCache = { value: this.options.getData() };\n return this.dataCache.value;\n }\n\n getDataStatus(): ColumnFieldStatus {\n if (this.dataStatusCache === undefined) {\n this.dataStatusCache = { value: this.options.getDataStatus() };\n }\n return this.dataStatusCache.value;\n }\n\n /**\n * Overlay overrides → produces a {@link ColumnOverriddenRecipe} wrapping\n * this leaf. The leaf itself stays bare (id remains a plain PObjectId);\n * layering lives entirely in the recipe wrappers.\n */\n withSpecs(overrides: SpecOverrides): ColumnRecipe {\n return ColumnOverriddenRecipe.wrap(this, overrides);\n }\n\n /**\n * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:\n * returns `undefined` if the leaf isn't reachable yet (resolving). Throws\n * {@link ColumnAbsentError} when every relevant accessor is `inputsLocked`\n * and the column did not appear, or when the id names an export that is not\n * a column (a `kind: \"File\"` object, for example) — the column will not\n * exist in this ctx. Data and dataStatus stay lazy.\n */\n static fromId(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): undefined | DataColumnRecipe<PObjectId> {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) {\n if (registry.isFinal()) throw new ColumnAbsentError(id);\n return undefined;\n }\n return DataColumnImpl.fromAccessor(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link fromId}. */\n static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId> {\n return DataColumnImpl.fromId(createGlobalPObjectId(ref.blockId, ref.name));\n }\n\n /**\n * Bind directly to an accessor-backed {@link LeafEntry} — no registry.\n * Throws {@link ColumnAbsentError} if the leaf has no spec field and its\n * accessor is `inputsLocked`, or if it names an export that is not a column.\n * Returns `undefined` while still resolving.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n if (isNil(readSpecAccessor(entry))) {\n if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);\n return undefined;\n }\n const spec = readSpec(entry);\n if (spec === undefined) return undefined;\n if (!isPColumnSpec(spec)) throw new ColumnAbsentError(entry.id);\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec,\n getData: () => readDataAccessor(entry),\n getDataStatus: () => readDataStatus(entry),\n });\n }\n\n /**\n * Wrap a materialised {@link PColumn}. If the input is already a\n * {@link DataColumnRecipe} leaf it is returned as-is.\n */\n static fromColumn(\n column: PColumn<ColumnData> | DataColumnRecipe<PObjectId>,\n ): DataColumnRecipe<PObjectId> {\n if (column instanceof DataColumnImpl) return column;\n // `DataColumnRecipe` is an interface, so `instanceof` above does not remove it\n // from the union. The only implementation carrying a bare `PObjectId` is\n // `DataColumnImpl` (wrappers expose `ColumnUniversalId`), so anything\n // reaching here is a materialised `PColumn`.\n const pColumn = column as PColumn<ColumnData>;\n return new DataColumnImpl(pColumn.id, {\n getSpec: () => pColumn.spec,\n getData: () => pColumn.data,\n getDataStatus: () => \"present\",\n });\n }\n\n /**\n * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}\n * in the active render ctx. Falls back to the registry's `isFinal()`\n * when the id has no entry — only then we can say `absent` instead of\n * `resolving`. The status tells only whether the spec is readable: for an\n * export that is not a column it is `present`, and the factories throw\n * {@link ColumnAbsentError}.\n */\n static getStatusById(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) return registry.isFinal() ? \"absent\" : \"resolving\";\n return getLeafEntryStatus(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link getStatusById}. */\n static getStatusByPlRef(\n ref: PlRef,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n return DataColumnImpl.getStatusById(createGlobalPObjectId(ref.blockId, ref.name), opts);\n }\n\n /** No registry — reads straight off the entry's accessor. */\n static getStatusByAccessor(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n return getLeafEntryStatus(entry);\n }\n}\n\n/** Anything the {@link DataColumnRecipe} dispatcher can build a leaf from. */\nexport type DataColumnSource =\n | PObjectId\n | PlRef\n | LeafEntry<TreeNodeAccessor>\n | PColumn<ColumnData>\n | DataColumnRecipe<PObjectId>;\n\n/**\n * Unified dispatcher — picks the right `DataColumnImpl.fromX` by source\n * shape. For ambiguous inputs callers can still use the explicit factories\n * (also attached as properties: `DataColumn.fromId`, `.fromPlRef`,\n * `.fromAccessor`, `.fromColumn`).\n */\nfunction DataColumnDispatch(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | DataColumnRecipe<PObjectId> {\n if (typeof source === \"string\") return DataColumnImpl.fromId(source, opts);\n if (source instanceof DataColumnImpl) return source;\n // `DataColumnRecipe` is an interface — `instanceof` above cannot remove it from\n // the union, and only `DataColumnImpl` implements it with a bare id.\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.fromAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.fromPlRef(rest);\n if (isPColumn(rest)) return DataColumnImpl.fromColumn(rest);\n throw new Error(\"DataColumn: unknown source shape\");\n}\n\n/**\n * Polymorphic counterpart to {@link DataColumnDispatch}: returns the\n * {@link ColumnResolutionStatus} for any factory input without constructing\n * the recipe. For already-materialised sources ({@link PColumn} value,\n * existing {@link DataColumnRecipe}) status is `present` by construction.\n */\nfunction DataColumnGetStatus(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n if (typeof source === \"string\") return DataColumnImpl.getStatusById(source, opts);\n if (source instanceof DataColumnImpl) return \"present\";\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.getStatusByAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.getStatusByPlRef(rest, opts);\n if (isPColumn(rest)) return \"present\";\n throw new Error(\"DataColumn.getStatus: unknown source shape\");\n}\n\nexport const DataColumn = Object.assign(DataColumnDispatch, {\n fromId: DataColumnImpl.fromId,\n fromPlRef: DataColumnImpl.fromPlRef,\n fromAccessor: DataColumnImpl.fromAccessor,\n fromColumn: DataColumnImpl.fromColumn,\n getStatus: DataColumnGetStatus,\n getStatusById: DataColumnImpl.getStatusById,\n getStatusByPlRef: DataColumnImpl.getStatusByPlRef,\n getStatusByAccessor: DataColumnImpl.getStatusByAccessor,\n});\n\n/**\n * Type-guard narrowing to a bare leaf — a {@link DataColumnRecipe} whose `id` is a\n * plain {@link PObjectId}.\n */\nexport function isDataColumn(value: unknown): value is DataColumnRecipe<PObjectId> {\n return value instanceof DataColumnImpl;\n}\n\nconst readSpecAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.spec`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\n/** The leaf's spec, or `undefined` until the spec resource has data. */\nconst readSpec = memoizeByEntry((entry: LeafEntry<TreeNodeAccessor>): undefined | PObjectSpec => {\n const spec = readSpecAccessor(entry);\n if (isNil(spec) || !spec.hasData()) return undefined;\n return spec.getDataAsJson<PObjectSpec>();\n});\n\n/**\n * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's\n * **spec** can be read in this ctx, and — for the negative cases —\n * distinguishes `resolving` from `absent` via `getInputsLocked()`.\n *\n * - spec field not yet on the entry's accessor + inputs locked → `absent`\n * - spec field not yet on the entry's accessor + still resolving → `resolving`\n * - spec resource present but bytes not yet written → `resolving`\n * (transient — the spec resource is connected, just unfilled)\n * - spec resource present and `hasData()` → `present`\n */\nfunction getLeafEntryStatus(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) return entry.accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n if (!spec.hasData()) return \"resolving\";\n return \"present\";\n}\n\nconst readDataAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.data`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\nconst readDataStatus = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): ColumnFieldStatus => {\n if (accessor.listInputFields().includes(`${name}.data`)) return \"present\";\n return accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n },\n);\n\nfunction memoizeByEntry<R>(\n fn: (entry: LeafEntry<TreeNodeAccessor>) => R,\n): (entry: LeafEntry<TreeNodeAccessor>) => R {\n const cache = new LRUCache<string, { value: R }>({ max: 1000 });\n return (entry) => {\n const key = `${entry.accessor.handle}:${entry.name}`;\n let hit = cache.get(key);\n if (!hit) cache.set(key, (hit = { value: fn(entry) }));\n return hit.value;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,IAAa,oBAAb,cAAuC,MAAM;CACf;CAA5B,YAAY,IAAuC;EACjD,MAAM,kEAAkE,IAAI;EADlD,KAAA,KAAA;EAE1B,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,IAAa,iBAAb,MAAa,eAAsD;CAM/C;CACC;CANnB;CACA;CACA;CAEA,YACE,IACA,SAKA;EANgB,KAAA,KAAA;EACC,KAAA,UAAA;CAKhB;;CAGH,mBAAgC;EAC9B,OAAO,CAAC,KAAK,EAAE;CACjB;CAEA,UAAuB;EACrB,IAAI,KAAK,cAAc,KAAA,GACrB,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EAEnD,OAAO,KAAK,UAAU;CACxB;;CAGA,WAAsB;EACpB,OAAO;GAAE,MAAM;GAAU,QAAQ,KAAK;EAAG;CAC3C;CAEA,UAAsB;EACpB,IAAI,KAAK,cAAc,KAAA,GAAW,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EACnF,OAAO,KAAK,UAAU;CACxB;CAEA,gBAAmC;EACjC,IAAI,KAAK,oBAAoB,KAAA,GAC3B,KAAK,kBAAkB,EAAE,OAAO,KAAK,QAAQ,cAAc,EAAE;EAE/D,OAAO,KAAK,gBAAgB;CAC9B;;;;;;CAOA,UAAU,WAAwC;EAChD,OAAO,uBAAuB,KAAK,MAAM,SAAS;CACpD;;;;;;;;;CAUA,OAAO,OACL,IACA,EAAE,QAAsC,CAAC,GACA;EACzC,MAAM,WAAW,IAAI,eAAe,gBAAgB,EAAE,IAAI,CAAC,CAAC;EAC5D,MAAM,OAAO,SAAS,QAA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AAI,MAAM,IAAI,KAAK,CAAC,KAAK,QAAQ,GAAG,OAAO,KAAA;CAC3C,OAAO,KAAK,cAA2B;AACzC,CAAC;;;;;;;;;;;;AAaD,SAAS,mBAAmB,OAA4D;CACtF,MAAM,OAAO,iBAAiB,KAAK;CACnC,IAAI,MAAM,IAAI,GAAG,OAAO,MAAM,SAAS,gBAAgB,IAAI,WAAW;CACtE,IAAI,CAAC,KAAK,QAAQ,GAAG,OAAO;CAC5B,OAAO;AACT;AAEA,MAAM,mBAAmB,gBACtB,EAAE,UAAU,WACX,SAAS,SAAS;CAAE,OAAO,GAAG,KAAK;CAAQ,iBAAiB;CAAS,aAAa;AAAK,CAAC,CAC5F;AAEA,MAAM,iBAAiB,gBACpB,EAAE,UAAU,WAA2D;CACtE,IAAI,SAAS,gBAAgB,CAAC,CAAC,SAAS,GAAG,KAAK,MAAM,GAAG,OAAO;CAChE,OAAO,SAAS,gBAAgB,IAAI,WAAW;AACjD,CACF;AAEA,SAAS,eACP,IAC2C;CAC3C,MAAM,QAAQ,IAAI,SAA+B,EAAE,KAAK,IAAK,CAAC;CAC9D,QAAQ,UAAU;EAChB,MAAM,MAAM,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM;EAC9C,IAAI,MAAM,MAAM,IAAI,GAAG;EACvB,IAAI,CAAC,KAAK,MAAM,IAAI,KAAM,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,CAAE;EACrD,OAAO,IAAI;CACb;AACF"}
|
|
@@ -3,7 +3,7 @@ require("../render/index.cjs");
|
|
|
3
3
|
const require_columns_collection = require("./columns_collection.cjs");
|
|
4
4
|
const require_utils = require("./utils.cjs");
|
|
5
5
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
6
|
-
|
|
6
|
+
// src/columns/derive_axis_values_labels.ts
|
|
7
7
|
const RT_JSON = "PColumnData/Json";
|
|
8
8
|
const RT_JSON_PARTITIONED = "PColumnData/JsonPartitioned";
|
|
9
9
|
/**
|
|
@@ -70,7 +70,6 @@ function parseLabelKeys(raw) {
|
|
|
70
70
|
return acc;
|
|
71
71
|
}, {});
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
73
|
exports.deriveAxisValuesLabels = deriveAxisValuesLabels;
|
|
75
74
|
|
|
76
75
|
//# sourceMappingURL=derive_axis_values_labels.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive_axis_values_labels.cjs","names":["ColumnsCollection","isColumnsCollection","PColumnName","hasReachableData","TreeNodeAccessor"],"sources":["../../src/columns/derive_axis_values_labels.ts"],"sourcesContent":["import type { AxisId } from \"@milaboratories/pl-model-common\";\nimport { canonicalizeAxisId, getAxisId, PColumnName } from \"@milaboratories/pl-model-common\";\nimport type { ColumnsSource } from \"./column_providers\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { hasReachableData } from \"./utils\";\n\nconst RT_JSON = \"PColumnData/Json\";\nconst RT_JSON_PARTITIONED = \"PColumnData/JsonPartitioned\";\n\n/**\n * Build an `axisValuesLabels` callback by discovering `pl7.app/label` columns\n * from the given source, eagerly materialising their value→label maps, and\n * keying them by canonical axis id.\n *\n * Modern replacement for `ctx.resultPool.findLabels` — uses the new\n * column-access mechanism (filtered {@link ColumnsCollection}) instead of\n * walking the raw result pool.\n *\n * Pair with {@link splitByAxes} (or any consumer expecting the\n * `(axisId) => Record<axisValue, label>` shape).\n *\n * Skips:\n * - recipes whose data is not directly readable (see `hasReachableData`);\n * - label columns whose `axesSpec.length !== 1`;\n * - label columns whose data resource type isn't `PColumnData/Json` /\n * `PColumnData/JsonPartitioned`.\n */\nexport function deriveAxisValuesLabels(\n source?: ColumnsCollection | (ColumnsCollection | ColumnsSource)[],\n opts?: { ctx?: GlobalCfgRenderCtx },\n): (axisId: AxisId) => Record<string | number, string> | undefined {\n const collection =\n source === undefined\n ? ColumnsCollection(undefined, opts)\n : isColumnsCollection(source)\n ? source\n : ColumnsCollection(source, opts);\n\n const labelCols = collection\n .filter({ include: { name: [{ type: \"exact\", value: PColumnName.Label }] } })\n .getColumns();\n\n const byAxis = labelCols.reduce<Map<string, Record<string | number, string>>>((map, col) => {\n if (!hasReachableData(col)) return map;\n const spec = col.getSpec();\n if (spec.axesSpec.length !== 1) return map;\n\n const data = col.getData();\n if (!(data instanceof TreeNodeAccessor)) return map;\n\n const labelMap = readLabelMap(data);\n if (!labelMap) return map;\n\n map.set(canonicalizeAxisId(getAxisId(spec.axesSpec[0])), labelMap);\n return map;\n }, new Map());\n\n return (axisId) => byAxis.get(canonicalizeAxisId(axisId));\n}\n\nfunction readLabelMap(acc: TreeNodeAccessor): undefined | Record<string | number, string> {\n const rt = acc.resourceType.name;\n\n if (rt === RT_JSON) {\n const json = acc.getDataAsJson<{ data?: Record<string, string> }>();\n return json?.data ? parseLabelKeys(json.data) : undefined;\n }\n\n if (rt === RT_JSON_PARTITIONED) {\n return acc.listInputFields().reduce<Record<string | number, string>>((merged, partKey) => {\n const part = acc.resolve({\n field: partKey,\n assertFieldType: \"Input\",\n ignoreError: true,\n });\n if (!part) return merged;\n const json = part.getDataAsJson<{ data?: Record<string, string> }>();\n if (!json?.data) return merged;\n return Object.assign(merged, parseLabelKeys(json.data));\n }, {});\n }\n\n return undefined;\n}\n\nfunction parseLabelKeys(raw: Record<string, string>): Record<string | number, string> {\n return Object.entries(raw).reduce<Record<string | number, string>>((acc, [k, v]) => {\n try {\n const parsed = JSON.parse(k);\n acc[Array.isArray(parsed) ? parsed[0] : parsed] = v;\n } catch {\n acc[k] = v;\n }\n return acc;\n }, {});\n}\n"],"mappings":";;;;;;AAQA,MAAM,UAAU;AAChB,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;AAoB5B,SAAgB,uBACd,QACA,MACiE;CAYjE,MAAM,UAVJ,WAAW,KAAA,IACPA,2BAAAA,kBAAkB,KAAA,GAAW,IAAI,IACjCC,2BAAAA,oBAAoB,MAAM,IACxB,SACAD,2BAAAA,kBAAkB,QAAQ,IAAI,EAAA,CAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC;EAAE,MAAM;EAAS,OAAOE,gCAAAA,YAAY;CAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAC5E,WAEoB,CAAC,CAAC,QAAsD,KAAK,QAAQ;EAC1F,IAAI,CAACC,cAAAA,iBAAiB,GAAG,GAAG,OAAO;EACnC,MAAM,OAAO,IAAI,QAAQ;EACzB,IAAI,KAAK,SAAS,WAAW,GAAG,OAAO;EAEvC,MAAM,OAAO,IAAI,QAAQ;EACzB,IAAI,EAAE,gBAAgBC,iBAAAA,mBAAmB,OAAO;EAEhD,MAAM,WAAW,aAAa,IAAI;EAClC,IAAI,CAAC,UAAU,OAAO;EAEtB,IAAI,KAAA,
|
|
1
|
+
{"version":3,"file":"derive_axis_values_labels.cjs","names":["ColumnsCollection","isColumnsCollection","PColumnName","hasReachableData","TreeNodeAccessor","canonicalizeAxisId","getAxisId"],"sources":["../../src/columns/derive_axis_values_labels.ts"],"sourcesContent":["import type { AxisId } from \"@milaboratories/pl-model-common\";\nimport { canonicalizeAxisId, getAxisId, PColumnName } from \"@milaboratories/pl-model-common\";\nimport type { ColumnsSource } from \"./column_providers\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { hasReachableData } from \"./utils\";\n\nconst RT_JSON = \"PColumnData/Json\";\nconst RT_JSON_PARTITIONED = \"PColumnData/JsonPartitioned\";\n\n/**\n * Build an `axisValuesLabels` callback by discovering `pl7.app/label` columns\n * from the given source, eagerly materialising their value→label maps, and\n * keying them by canonical axis id.\n *\n * Modern replacement for `ctx.resultPool.findLabels` — uses the new\n * column-access mechanism (filtered {@link ColumnsCollection}) instead of\n * walking the raw result pool.\n *\n * Pair with {@link splitByAxes} (or any consumer expecting the\n * `(axisId) => Record<axisValue, label>` shape).\n *\n * Skips:\n * - recipes whose data is not directly readable (see `hasReachableData`);\n * - label columns whose `axesSpec.length !== 1`;\n * - label columns whose data resource type isn't `PColumnData/Json` /\n * `PColumnData/JsonPartitioned`.\n */\nexport function deriveAxisValuesLabels(\n source?: ColumnsCollection | (ColumnsCollection | ColumnsSource)[],\n opts?: { ctx?: GlobalCfgRenderCtx },\n): (axisId: AxisId) => Record<string | number, string> | undefined {\n const collection =\n source === undefined\n ? ColumnsCollection(undefined, opts)\n : isColumnsCollection(source)\n ? source\n : ColumnsCollection(source, opts);\n\n const labelCols = collection\n .filter({ include: { name: [{ type: \"exact\", value: PColumnName.Label }] } })\n .getColumns();\n\n const byAxis = labelCols.reduce<Map<string, Record<string | number, string>>>((map, col) => {\n if (!hasReachableData(col)) return map;\n const spec = col.getSpec();\n if (spec.axesSpec.length !== 1) return map;\n\n const data = col.getData();\n if (!(data instanceof TreeNodeAccessor)) return map;\n\n const labelMap = readLabelMap(data);\n if (!labelMap) return map;\n\n map.set(canonicalizeAxisId(getAxisId(spec.axesSpec[0])), labelMap);\n return map;\n }, new Map());\n\n return (axisId) => byAxis.get(canonicalizeAxisId(axisId));\n}\n\nfunction readLabelMap(acc: TreeNodeAccessor): undefined | Record<string | number, string> {\n const rt = acc.resourceType.name;\n\n if (rt === RT_JSON) {\n const json = acc.getDataAsJson<{ data?: Record<string, string> }>();\n return json?.data ? parseLabelKeys(json.data) : undefined;\n }\n\n if (rt === RT_JSON_PARTITIONED) {\n return acc.listInputFields().reduce<Record<string | number, string>>((merged, partKey) => {\n const part = acc.resolve({\n field: partKey,\n assertFieldType: \"Input\",\n ignoreError: true,\n });\n if (!part) return merged;\n const json = part.getDataAsJson<{ data?: Record<string, string> }>();\n if (!json?.data) return merged;\n return Object.assign(merged, parseLabelKeys(json.data));\n }, {});\n }\n\n return undefined;\n}\n\nfunction parseLabelKeys(raw: Record<string, string>): Record<string | number, string> {\n return Object.entries(raw).reduce<Record<string | number, string>>((ac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A,IAAI,OAAO,qBACT,OAAO,IAAI,gBAAgB,CAAC,CAAC,QAAyC,QAAQ,YAAY;EACxF,MAAM,OAAO,IAAI,QAAQ;GACvB,OAAO;GACP,iBAAiB;GACjB,aAAa;EACf,CAAC;EACD,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,OAAO,KAAK,cAAiD;EACnE,IAAI,CAAC,MAAM,MAAM,OAAO;EACxB,OAAO,OAAO,OAAO,QAAQ,eAAe,KAAK,IAAI,CAAC;CACxD,GAAG,CAAC,CAAC;AAIT;AAEA,SAAS,eAAe,KAA8D;CACpF,OAAO,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAyC,KAAK,CAAC,GAAG,OAAO;EAClF,IAAI;GACF,MAAM,SAAS,KAAK,MAAM,CAAC;GAC3B,IAAI,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAK,UAAU;EACpD,QAAQ;GACN,IAAI,KAAK;EACX;EACA,OAAO;CACT,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -3,7 +3,6 @@ import { ColumnsSource } from "./column_providers/types.js";
|
|
|
3
3
|
import "./column_providers/index.js";
|
|
4
4
|
import { ColumnsCollection } from "./columns_collection.js";
|
|
5
5
|
import { AxisId } from "@milaboratories/pl-model-common";
|
|
6
|
-
//#region src/columns/derive_axis_values_labels.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Build an `axisValuesLabels` callback by discovering `pl7.app/label` columns
|
|
9
8
|
* from the given source, eagerly materialising their value→label maps, and
|
|
@@ -25,5 +24,4 @@ import { AxisId } from "@milaboratories/pl-model-common";
|
|
|
25
24
|
export declare function deriveAxisValuesLabels(source?: ColumnsCollection | (ColumnsCollection | ColumnsSource)[], opts?: {
|
|
26
25
|
ctx?: GlobalCfgRenderCtx;
|
|
27
26
|
}): (axisId: AxisId) => Record<string | number, string> | undefined;
|
|
28
|
-
//#endregion
|
|
29
27
|
//# sourceMappingURL=derive_axis_values_labels.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive_axis_values_labels.d.ts","names":[],"sources":["../../src/columns/derive_axis_values_labels.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"derive_axis_values_labels.d.ts","names":[],"sources":["../../src/columns/derive_axis_values_labels.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBA6BgB,uBACd,SAAS,qBAAqB,oBAAoB,kBAClD;EAAS,MAAM;KACb,QAAQ,WAAW"}
|
|
@@ -3,7 +3,7 @@ import "../render/index.js";
|
|
|
3
3
|
import { ColumnsCollection, isColumnsCollection } from "./columns_collection.js";
|
|
4
4
|
import { hasReachableData } from "./utils.js";
|
|
5
5
|
import { PColumnName, canonicalizeAxisId, getAxisId } from "@milaboratories/pl-model-common";
|
|
6
|
-
|
|
6
|
+
// src/columns/derive_axis_values_labels.ts
|
|
7
7
|
const RT_JSON = "PColumnData/Json";
|
|
8
8
|
const RT_JSON_PARTITIONED = "PColumnData/JsonPartitioned";
|
|
9
9
|
/**
|
|
@@ -70,7 +70,6 @@ function parseLabelKeys(raw) {
|
|
|
70
70
|
return acc;
|
|
71
71
|
}, {});
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
73
|
export { deriveAxisValuesLabels };
|
|
75
74
|
|
|
76
75
|
//# sourceMappingURL=derive_axis_values_labels.js.map
|
|
@@ -2,7 +2,7 @@ const require_providers = require("./column_providers/providers.cjs");
|
|
|
2
2
|
require("./column_providers/index.cjs");
|
|
3
3
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
4
|
let es_toolkit = require("es-toolkit");
|
|
5
|
-
|
|
5
|
+
// src/columns/peer_links.ts
|
|
6
6
|
/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */
|
|
7
7
|
function collectDatasetAxes(specs) {
|
|
8
8
|
return new Set(specs.flatMap((spec) => {
|
|
@@ -33,7 +33,6 @@ function describePeerLinks(links) {
|
|
|
33
33
|
function peerLinkedLast(items, isPeerLinked) {
|
|
34
34
|
return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];
|
|
35
35
|
}
|
|
36
|
-
//#endregion
|
|
37
36
|
exports.collectDatasetAxes = collectDatasetAxes;
|
|
38
37
|
exports.describePeerLinks = describePeerLinks;
|
|
39
38
|
exports.findPeerLinks = findPeerLinks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_links.cjs","names":["Annotation","ResultPoolColumnsProvider"],"sources":["../../src/columns/peer_links.ts"],"sourcesContent":["import {\n Annotation,\n canonicalizeAxisId,\n readAnnotation,\n type AxisId,\n type CanonicalizedJson,\n type PColumnSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { uniq } from \"es-toolkit\";\nimport { ResultPoolColumnsProvider } from \"./column_providers\";\n\nexport type DatasetAxes = Set<CanonicalizedJson<AxisId>>;\n\n/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */\nexport function collectDatasetAxes(specs: PColumnSpec[]): DatasetAxes {\n return new Set(\n specs.flatMap((spec) => {\n const main = spec.axesSpec[1];\n return readAnnotation(spec, Annotation.IsAnchor) === \"true\" && main !== undefined\n ? [canonicalizeAxisId(main)]\n : [];\n }),\n );\n}\n\n/** {@link collectDatasetAxes} over the result pool. */\nexport function getResultPoolDatasetAxes(): DatasetAxes {\n return collectDatasetAxes(\n ResultPoolColumnsProvider()\n .getColumns()\n .map((c) => c.getSpec()),\n );\n}\n\n/**\n * Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one\n * clonotype to another, so the columns behind it describe a different clonotype than the row.\n */\nexport function findPeerLinks(linkers: PColumnSpec[], datasetAxes: DatasetAxes): string[] {\n return uniq(\n linkers.flatMap((l) => {\n const peer = l.axesSpec.every((a) => datasetAxes.has(canonicalizeAxisId(a)));\n const label = readAnnotation(l, Annotation.LinkLabel) ?? readAnnotation(l, Annotation.Label);\n return peer && label ? [label] : [];\n }),\n );\n}\n\n/** Hover text for the link icon. */\nexport function describePeerLinks(links: string[]): string {\n return `Reached via ${links.join(\", then \")}`;\n}\n\n/** Moves peer-linked items after the others, keeping the order within each group. */\nexport function peerLinkedLast<T>(items: T[], isPeerLinked: (item: T) => boolean): T[] {\n return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];\n}\n"],"mappings":";;;;;;AAcA,SAAgB,mBAAmB,OAAmC;CACpE,OAAO,IAAI,IACT,MAAM,SAAS,SAAS;EACtB,MAAM,OAAO,KAAK,SAAS;EAC3B,QAAA,
|
|
1
|
+
{"version":3,"file":"peer_links.cjs","names":["readAnnotation","Annotation","canonicalizeAxisId","ResultPoolColumnsProvider","uniq"],"sources":["../../src/columns/peer_links.ts"],"sourcesContent":["import {\n Annotation,\n canonicalizeAxisId,\n readAnnotation,\n type AxisId,\n type CanonicalizedJson,\n type PColumnSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { uniq } from \"es-toolkit\";\nimport { ResultPoolColumnsProvider } from \"./column_providers\";\n\nexport type DatasetAxes = Set<CanonicalizedJson<AxisId>>;\n\n/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */\nexport function collectDatasetAxes(specs: PColumnSpec[]): DatasetAxes {\n return new Set(\n specs.flatMap((spec) => {\n const main = spec.axesSpec[1];\n return readAnnotation(spec, Annotation.IsAnchor) === \"true\" && main !== undefined\n ? [canonicalizeAxisId(main)]\n : [];\n }),\n );\n}\n\n/** {@link collectDatasetAxes} over the result pool. */\nexport function getResultPoolDatasetAxes(): DatasetAxes {\n return collectDatasetAxes(\n ResultPoolColumnsProvider()\n .getColumns()\n .map((c) => c.getSpec()),\n );\n}\n\n/**\n * Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one\n * clonotype to another, so the columns behind it describe a different clonotype than the row.\n */\nexport function findPeerLinks(linkers: PColumnSpec[], datasetAxes: DatasetAxes): string[] {\n return uniq(\n linkers.flatMap((l) => {\n const peer = l.axesSpec.every((a) => datasetAxes.has(canonicalizeAxisId(a)));\n const label = readAnnotation(l, Annotation.LinkLabel) ?? readAnnotation(l, Annotation.Label);\n return peer && label ? [label] : [];\n }),\n );\n}\n\n/** Hover text for the link icon. */\nexport function describePeerLinks(links: string[]): string {\n return `Reached via ${links.join(\", then \")}`;\n}\n\n/** Moves peer-linked items after the others, keeping the order within each group. */\nexport function peerLinkedLast<T>(items: T[], isPeerLinked: (item: T) => boolean): T[] {\n return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];\n}\n"],"mappings":";;;;;;AAcA,SAAgB,mBAAmB,OAAmC;CACpE,OAAO,IAAI,IACT,MAAM,SAAS,SAAS;EACtB,MAAM,OAAO,KAAK,SAAS;EAC3B,QAAA,GAAOA,gCAAAA,eAAAA,CAAe,MAAMC,gCAAAA,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAA,IACpE,EAAA,GAACC,gCAAAA,mBAAAA,CAAmB,IAAI,CAAC,IACzB,CAAC;CACP,CAAC,CACH;AACF;;AAGA,SAAgB,2BAAwC;CACtD,OAAO,mBACLC,kBAAAA,0BAA0B,CAAC,CACxB,WAAW,CAAC,CACZ,KAAK,MAAM,EAAE,QAAQ,CAAC,CAC3B;AACF;;;;;AAMA,SAAgB,cAAc,SAAwB,aAAoC;CACxF,QAAA,GAAOC,WAAAA,KAAAA,CACL,QAAQ,SAAS,MAAM;EACrB,MAAM,OAAO,EAAE,SAAS,OAAO,MAAM,YAAY,KAAA,GAAIF,gCAAAA,mBAAAA,CAAmB,CAAC,CAAC,CAAC;EAC3E,MAAM,SAAA,GAAQF,gCAAAA,eAAAA,CAAe,GAAGC,gCAAAA,WAAW,SAAS,MAAA,GAAKD,gCAAAA,eAAAA,CAAe,GAAGC,gCAAAA,WAAW,KAAK;EAC3F,OAAO,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC;CACpC,CAAC,CACH;AACF;;AAGA,SAAgB,kBAAkB,OAAyB;CACzD,OAAO,eAAe,MAAM,KAAK,SAAS;AAC5C;;AAGA,SAAgB,eAAkB,OAAY,cAAyC;CACrF,OAAO,CAAC,GAAG,MAAM,QAAQ,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,GAAG,MAAM,OAAO,YAAY,CAAC;AACjF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AxisId, CanonicalizedJson, PColumnSpec } from "@milaboratories/pl-model-common";
|
|
2
|
-
//#region src/columns/peer_links.d.ts
|
|
3
2
|
export type DatasetAxes = Set<CanonicalizedJson<AxisId>>;
|
|
4
3
|
/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */
|
|
5
4
|
export declare function collectDatasetAxes(specs: PColumnSpec[]): DatasetAxes;
|
|
@@ -14,5 +13,4 @@ export declare function findPeerLinks(linkers: PColumnSpec[], datasetAxes: Datas
|
|
|
14
13
|
export declare function describePeerLinks(links: string[]): string;
|
|
15
14
|
/** Moves peer-linked items after the others, keeping the order within each group. */
|
|
16
15
|
export declare function peerLinkedLast<T>(items: T[], isPeerLinked: (item: T) => boolean): T[];
|
|
17
|
-
//#endregion
|
|
18
16
|
//# sourceMappingURL=peer_links.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_links.d.ts","names":[],"sources":["../../src/columns/peer_links.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"peer_links.d.ts","names":[],"sources":["../../src/columns/peer_links.ts"],"mappings":";YAWY,cAAc,IAAI,kBAAkB;;wBAGhC,mBAAmB,OAAO,gBAAgB;;wBAY1C,4BAA4B;;;;;wBAY5B,cAAc,SAAS,eAAe,aAAa;;wBAWnD,kBAAkB;;wBAKlB,eAAe,GAAG,OAAO,KAAK,eAAe,MAAM,gBAAgB"}
|
|
@@ -2,7 +2,7 @@ import { ResultPoolColumnsProvider } from "./column_providers/providers.js";
|
|
|
2
2
|
import "./column_providers/index.js";
|
|
3
3
|
import { Annotation, canonicalizeAxisId, readAnnotation } from "@milaboratories/pl-model-common";
|
|
4
4
|
import { uniq } from "es-toolkit";
|
|
5
|
-
|
|
5
|
+
// src/columns/peer_links.ts
|
|
6
6
|
/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */
|
|
7
7
|
function collectDatasetAxes(specs) {
|
|
8
8
|
return new Set(specs.flatMap((spec) => {
|
|
@@ -33,7 +33,6 @@ function describePeerLinks(links) {
|
|
|
33
33
|
function peerLinkedLast(items, isPeerLinked) {
|
|
34
34
|
return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];
|
|
35
35
|
}
|
|
36
|
-
//#endregion
|
|
37
36
|
export { collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast };
|
|
38
37
|
|
|
39
38
|
//# sourceMappingURL=peer_links.js.map
|
|
@@ -5,7 +5,7 @@ const require_column_overrided_recipe = require("./column_recipes/column_overrid
|
|
|
5
5
|
const require_utils = require("./utils.cjs");
|
|
6
6
|
const require_derive_axis_values_labels = require("./derive_axis_values_labels.cjs");
|
|
7
7
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
8
|
-
|
|
8
|
+
// src/columns/split_by_axes.ts
|
|
9
9
|
const MAX_KEY_COMBINATIONS = 1e4;
|
|
10
10
|
/**
|
|
11
11
|
* Split each input column along the requested axes into one
|
|
@@ -101,7 +101,6 @@ function generateKeyCombinations(uniqueKeys, splitAxisIdxs) {
|
|
|
101
101
|
generate([], 0);
|
|
102
102
|
return combinations;
|
|
103
103
|
}
|
|
104
|
-
//#endregion
|
|
105
104
|
exports.splitByAxes = splitByAxes;
|
|
106
105
|
|
|
107
106
|
//# sourceMappingURL=split_by_axes.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_axes.cjs","names":["deriveAxisValuesLabels","hasReachableData","TreeNodeAccessor","getUniquePartitionKeys","Annotation","ColumnFilteredRecipe","ColumnOverriddenRecipe"],"sources":["../../src/columns/split_by_axes.ts"],"sourcesContent":["import type {\n AxisFilterByIdx,\n AxisFilterValue,\n AxisId,\n TraceEntry,\n} from \"@milaboratories/pl-model-common\";\nimport {\n Annotation,\n canonicalizeAxisId,\n getAxisId,\n isDataInfoEntries,\n readAnnotation,\n} from \"@milaboratories/pl-model-common\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getUniquePartitionKeys } from \"../render/util/pcolumn_data\";\nimport { deriveAxisValuesLabels } from \"./derive_axis_values_labels\";\nimport type { ColumnRecipe } from \"./column_recipes\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\nimport { Column } from \"./column\";\nimport { hasReachableData } from \"./utils\";\n\n// --- Types ---\n\nexport interface SplitAxis {\n /** Index of the axis in the column's axesSpec to split by. */\n readonly idx: number;\n}\n\nexport interface SplitByAxesOpts {\n /**\n * Resolve axis values to human-readable labels.\n *\n * Defaults to {@link deriveAxisValuesLabels} over the ambient render ctx\n * (current block outputs + result pool), resolved lazily on the first\n * lookup. Pass an explicit callback to narrow the label source, or\n * `() => undefined` to keep raw axis values.\n */\n axisValuesLabels?: (axisId: AxisId) => undefined | Record<string | number, string>;\n}\n\n// --- Implementation ---\n\nconst MAX_KEY_COMBINATIONS = 10_000;\n\n/**\n * Split each input column along the requested axes into one\n * {@link ColumnRecipe} per Cartesian combination of the axes' distinct values.\n *\n * The split axes must be partition-key axes of the input's data — the distinct\n * values are read off the partition keys.\n *\n * Each split is produced as `ColumnOverriddenRecipe.wrap(ColumnFilteredRecipe.wrap(inner, axisFilters), { domain, annotations })`:\n * - `ColumnFilteredRecipe` pins all split axes at once (one wrap call with\n * every `[idx, value]` pair) and removes them from `axesSpec`. The\n * engine performs the data slicing via the `sliceAxes` query node.\n * - `ColumnOverriddenRecipe` overlays a `domain[axisName] = String(value)`\n * entry per split axis and appends a `split:<canonicalAxisId>` trace\n * entry per split axis to the existing `pl7.app/trace` annotation.\n *\n * The recipe id is a canonical\n * `ColumnOverriddenId(source: ColumnFilteredId(source: inner.id, axisFilters), specOverrides)`\n * — distinct per split combination, parseable by `extractPObjectId`, and\n * traversable by recipe walkers.\n *\n * Returns `undefined` when any input's `getData()` is not a\n * {@link TreeNodeAccessor} — partition inspection is not yet possible.\n */\nexport function splitByAxes(\n inputs: Column[],\n splitAxes: SplitAxis[],\n opts?: SplitByAxesOpts,\n): ColumnRecipe[] | undefined {\n if (splitAxes.length === 0) {\n return [...inputs];\n }\n\n const axisValuesLabels = opts?.axisValuesLabels ?? deriveAxisValuesLabels();\n\n const splitAxisIdxs = splitAxes.map((a) => a.idx).sort((a, b) => a - b);\n const maxSplitIdx = splitAxisIdxs[splitAxisIdxs.length - 1];\n\n const result: ColumnRecipe[] = [];\n\n for (const inner of inputs) {\n const data = hasReachableData(inner) ? inner.getData() : undefined;\n // Partition inspection requires either a live tree-accessor or already\n // parsed DataInfoEntries. Anything else means the input is not yet ready.\n if (!(data instanceof TreeNodeAccessor) && !isDataInfoEntries(data)) {\n return undefined;\n }\n\n const uniqueKeys = getUniquePartitionKeys(data);\n if (uniqueKeys === undefined) return undefined;\n\n if (maxSplitIdx >= uniqueKeys.length) {\n throw new Error(\n `Not enough partition keys (${uniqueKeys.length}) for requested split axes (max index ${maxSplitIdx}) in column ${inner.getSpec().name}`,\n );\n }\n\n const spec = inner.getSpec();\n const axesSpec = spec.axesSpec;\n const splitAxisSpecs = splitAxisIdxs.map((idx) => axesSpec[idx]);\n const splitAxisIds = splitAxisSpecs.map((axisSpec) => getAxisId(axisSpec));\n const axesLabels = splitAxisIds.map((axisId) => axisValuesLabels(axisId));\n\n const existingTraceRaw = readAnnotation(spec, Annotation.Trace);\n const baseTrace: TraceEntry[] = existingTraceRaw\n ? ((JSON.parse(existingTraceRaw) as TraceEntry[]) ?? [])\n : [];\n\n const keyCombinations = generateKeyCombinations(uniqueKeys, splitAxisIdxs);\n if (keyCombinations.length === 0) continue;\n\n for (const keyCombo of keyCombinations) {\n const axisFilters: AxisFilterByIdx[] = keyCombo.map(
|
|
1
|
+
{"version":3,"file":"split_by_axes.cjs","names":["deriveAxisValuesLabels","hasReachableData","TreeNodeAccessor","isDataInfoEntries","getUniquePartitionKeys","getAxisId","readAnnotation","Annotation","canonicalizeAxisId","ColumnFilteredRecipe","ColumnOverriddenRecipe"],"sources":["../../src/columns/split_by_axes.ts"],"sourcesContent":["import type {\n AxisFilterByIdx,\n AxisFilterValue,\n AxisId,\n TraceEntry,\n} from \"@milaboratories/pl-model-common\";\nimport {\n Annotation,\n canonicalizeAxisId,\n getAxisId,\n isDataInfoEntries,\n readAnnotation,\n} from \"@milaboratories/pl-model-common\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getUniquePartitionKeys } from \"../render/util/pcolumn_data\";\nimport { deriveAxisValuesLabels } from \"./derive_axis_values_labels\";\nimport type { ColumnRecipe } from \"./column_recipes\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\nimport { Column } from \"./column\";\nimport { hasReachableData } from \"./utils\";\n\n// --- Types ---\n\nexport interface SplitAxis {\n /** Index of the axis in the column's axesSpec to split by. */\n readonly idx: number;\n}\n\nexport interface SplitByAxesOpts {\n /**\n * Resolve axis values to human-readable labels.\n *\n * Defaults to {@link deriveAxisValuesLabels} over the ambient render ctx\n * (current block outputs + result pool), resolved lazily on the first\n * lookup. Pass an explicit callback to narrow the label source, or\n * `() => undefined` to keep raw axis values.\n */\n axisValuesLabels?: (axisId: AxisId) => undefined | Record<string | number, string>;\n}\n\n// --- Implementation ---\n\nconst MAX_KEY_COMBINATIONS = 10_000;\n\n/**\n * Split each input column along the requested axes into one\n * {@link ColumnRecipe} per Cartesian combination of the axes' distinct values.\n *\n * The split axes must be partition-key axes of the input's data — the distinct\n * values are read off the partition keys.\n *\n * Each split is produced as `ColumnOverriddenRecipe.wrap(ColumnFilteredRecipe.wrap(inner, axisFilters), { domain, annotations })`:\n * - `ColumnFilteredRecipe` pins all split axes at once (one wrap call with\n * every `[idx, value]` pair) and removes them from `axesSpec`. The\n * engine performs the data slicing via the `sliceAxes` query node.\n * - `ColumnOverriddenRecipe` overlays a `domain[axisName] = String(value)`\n * entry per split axis and appends a `split:<canonicalAxisId>` trace\n * entry per split axis to the existing `pl7.app/trace` annotation.\n *\n * The recipe id is a canonical\n * `ColumnOverriddenId(source: ColumnFilteredId(source: inner.id, axisFilters), specOverrides)`\n * — distinct per split combination, parseable by `extractPObjectId`, and\n * traversable by recipe walkers.\n *\n * Returns `undefined` when any input's `getData()` is not a\n * {@link TreeNodeAccessor} — partition inspection is not yet possible.\n */\nexport function splitByAxes(\n inputs: Column[],\n splitAxes: SplitAxis[],\n opts?: SplitByAxesOpts,\n): ColumnRecipe[] | undefined {\n if (splitAxes.length === 0) {\n return [...inputs];\n }\n\n const axisValuesLabels = opts?.axisValuesLabels ?? deriveAxisValuesLabels();\n\n const splitAxisIdxs = splitAxes.map((a) => a.idx).sort((a, b) => a - b);\n const maxSplitIdx = splitAxisIdxs[splitAxisIdxs.length - 1];\n\n const result: ColumnRecipe[] = [];\n\n for (const inner of inputs) {\n const data = hasReachableData(inner) ? inner.getData() : undefined;\n // Partition inspection requires either a live tree-accessor or already\n // parsed DataInfoEntries. Anything else means the input is not yet ready.\n if (!(data instanceof TreeNodeAccessor) && !isDataInfoEntries(data)) {\n return undefined;\n }\n\n const uniqueKeys = getUniquePartitionKeys(data);\n if (uniqueKeys === undefined) return undefined;\n\n if (maxSplitIdx >= uniqueKeys.length) {\n throw new Error(\n `Not enough partition keys (${uniqueKeys.length}) for requested split axes (max index ${maxSplitIdx}) in column ${inner.getSpec().name}`,\n );\n }\n\n const spec = inner.getSpec();\n const axesSpec = spec.axesSpec;\n const splitAxisSpecs = splitAxisIdxs.map((idx) => axesSpec[idx]);\n const splitAxisIds = splitAxisSpecs.map((axisSpec) => getAxisId(axisSpec));\n const axesLabels = splitAxisIds.map((axisId) => axisValuesLabels(axisId));\n\n const existingTraceRaw = readAnnotation(spec, Annotation.Trace);\n const baseTrace: TraceEntry[] = existingTraceRaw\n ? ((JSON.parse(existingTraceRaw) as TraceEntry[]) ?? [])\n : [];\n\n const keyCombinations = generateKeyCombinations(uniqueKeys, splitAxisIdxs);\n if (keyCombinations.length === 0) continue;\n\n for (const keyCombo of keyCombinations) {\n const axisFilters: AxisFilterByIdx[] = keyCombo.map((value, sAxisIdx): AxisFilterByIdx => [\n splitAxisIdxs[sAxisIdx],\n value as AxisFilterValue,\n ]);\n\n const domain: Record<string, string> = {};\n const traceEntries: TraceEntry[] = [];\n for (let sAxisIdx = 0; sAxisIdx < keyCombo.length; sAxisIdx++) {\n const value = keyCombo[sAxisIdx];\n const axisSpec = splitAxisSpecs[sAxisIdx];\n const axisId = splitAxisIds[sAxisIdx];\n const labelMap = axesLabels[sAxisIdx];\n const label = labelMap?.[value] ?? String(value);\n domain[axisSpec.name] = String(value);\n traceEntries.push({\n type: `split:${canonicalizeAxisId(axisId)}`,\n label,\n importance: 1_000_000,\n });\n }\n\n const filtered = ColumnFilteredRecipe.wrap(inner, axisFilters);\n const overrided = ColumnOverriddenRecipe.wrap(filtered, {\n domain,\n annotations: {\n [Annotation.Trace]: JSON.stringify([...baseTrace, ...traceEntries]),\n },\n });\n\n result.push(overrided);\n }\n }\n\n return result;\n}\n\nfunction generateKeyCombinations(\n uniqueKeys: (string | number)[][],\n splitAxisIdxs: number[],\n): (string | number)[][] {\n const combinations: (string | number)[][] = [];\n\n function generate(currentCombo: (string | number)[], sAxisIdx: number): void {\n if (sAxisIdx >= splitAxisIdxs.length) {\n combinations.push([...currentCombo]);\n if (combinations.length > MAX_KEY_COMBINATIONS) {\n throw new Error(\"Too many key combinations, aborting.\");\n }\n return;\n }\n\n const axisIdx = splitAxisIdxs[sAxisIdx];\n if (axisIdx >= uniqueKeys.length) {\n throw new Error(\n `Axis index ${axisIdx} out of bounds for unique keys array (length ${uniqueKeys.length})`,\n );\n }\n\n const axisValues = uniqueKeys[axisIdx];\n if (!axisValues || axisValues.length === 0) {\n combinations.length = 0;\n return;\n }\n\n for (const val of axisValues) {\n currentCombo.push(val);\n generate(currentCombo, sAxisIdx + 1);\n currentCombo.pop();\n }\n }\n\n generate([], 0);\n return combinations;\n}\n"],"mappings":";;;;;;;;AA2CA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;AAyB7B,SAAgB,YACd,QACA,WACA,MAC4B;CAC5B,IAAI,UAAU,WAAW,GACvB,OAAO,CAAC,GAAG,MAAM;CAGnB,MAAM,mBAAmB,MAAM,oBAAoBA,kCAAAA,uBAAuB;CAE1E,MAAM,gBAAgB,UAAU,KAAK,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;CACtE,MAAM,cAAc,cAAc,cAAc,SAAS;CAEzD,MAAM,SAAyB,CAAC;CAEhC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAOC,cAAAA,iBAAiB,KAAK,IAAI,MAAM,QAAQ,IAAI,KAAA;EAGzD,IAAI,EAAE,gBAAgBC,iBAAAA,qBAAqB,EAAA,GAACC,gCAAAA,kBAAAA,CAAkB,IAAI,GAChE;EAGF,MAAM,aAAaC,qBAAAA,uBAAuB,IAAI;EAC9C,IAAI,eAAe,KAAA,GAAW,OAAO,KAAA;EAErC,IAAI,eAAe,WAAW,QAC5B,MAAM,IAAI,MACR,8BAA8B,WAAW,OAAO,wCAAwC,YAAY,cAAc,MAAM,QAAQ,CAAC,CAAC,MACpI;EAGF,MAAM,OAAO,MAAM,QAAQ;EAC3B,MAAM,WAAW,KAAK;EACtB,MAAM,iBAAiB,cAAc,KAAK,QAAQ,SAAS,IAAI;EAC/D,MAAM,eAAe,eAAe,KAAK,cAAA,GAAaC,gCAAAA,UAAAA,CAAU,QAAQ,CAAC;EACzE,MAAM,aAAa,aAAa,KAAK,WAAW,iBAAiB,MAAM,CAAC;EAExE,MAAM,oBAAA,GAAmBC,gCAAAA,eAAAA,CAAe,MAAMC,gCAAAA,WAAW,KAAK;EAC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AGF,MAAM,aAAa,WAAW;EAC9B,IAAI,CAAC,cAAc,WAAW,WAAW,GAAG;GAC1C,aAAa,SAAS;GACtB;EACF;EAEA,KAAK,MAAM,OAAO,YAAY;GAC5B,aAAa,KAAK,GAAG;GACrB,SAAS,cAAc,WAAW,CAAC;GACnC,aAAa,IAAI;EACnB;CACF;CAEA,SAAS,CAAC,GAAG,CAAC;CACd,OAAO;AACT"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Column } from "./column.js";
|
|
2
2
|
import { ColumnRecipe } from "./column_recipes/index.js";
|
|
3
3
|
import { AxisId } from "@milaboratories/pl-model-common";
|
|
4
|
-
//#region src/columns/split_by_axes.d.ts
|
|
5
4
|
export interface SplitAxis {
|
|
6
5
|
/** Index of the axis in the column's axesSpec to split by. */
|
|
7
6
|
readonly idx: number;
|
|
@@ -41,5 +40,4 @@ export interface SplitByAxesOpts {
|
|
|
41
40
|
* {@link TreeNodeAccessor} — partition inspection is not yet possible.
|
|
42
41
|
*/
|
|
43
42
|
export declare function splitByAxes(inputs: Column[], splitAxes: SplitAxis[], opts?: SplitByAxesOpts): ColumnRecipe[] | undefined;
|
|
44
|
-
//#endregion
|
|
45
43
|
//# sourceMappingURL=split_by_axes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_axes.d.ts","names":[],"sources":["../../src/columns/split_by_axes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"split_by_axes.d.ts","names":[],"sources":["../../src/columns/split_by_axes.ts"],"mappings":";;;iBAwBiB;;WAEN;;iBAGM;;;;;;;;;EASf,oBAAoB,QAAQ,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BrC,YACd,QAAQ,UACR,WAAW,aACX,OAAO,kBACN"}
|
|
@@ -5,7 +5,7 @@ import { ColumnOverriddenRecipe } from "./column_recipes/column_overrided_recipe
|
|
|
5
5
|
import { hasReachableData } from "./utils.js";
|
|
6
6
|
import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
|
|
7
7
|
import { Annotation, canonicalizeAxisId, getAxisId, isDataInfoEntries, readAnnotation } from "@milaboratories/pl-model-common";
|
|
8
|
-
|
|
8
|
+
// src/columns/split_by_axes.ts
|
|
9
9
|
const MAX_KEY_COMBINATIONS = 1e4;
|
|
10
10
|
/**
|
|
11
11
|
* Split each input column along the requested axes into one
|
|
@@ -101,7 +101,6 @@ function generateKeyCombinations(uniqueKeys, splitAxisIdxs) {
|
|
|
101
101
|
generate([], 0);
|
|
102
102
|
return combinations;
|
|
103
103
|
}
|
|
104
|
-
//#endregion
|
|
105
104
|
export { splitByAxes };
|
|
106
105
|
|
|
107
106
|
//# sourceMappingURL=split_by_axes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_axes.js","names":[],"sources":["../../src/columns/split_by_axes.ts"],"sourcesContent":["import type {\n AxisFilterByIdx,\n AxisFilterValue,\n AxisId,\n TraceEntry,\n} from \"@milaboratories/pl-model-common\";\nimport {\n Annotation,\n canonicalizeAxisId,\n getAxisId,\n isDataInfoEntries,\n readAnnotation,\n} from \"@milaboratories/pl-model-common\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getUniquePartitionKeys } from \"../render/util/pcolumn_data\";\nimport { deriveAxisValuesLabels } from \"./derive_axis_values_labels\";\nimport type { ColumnRecipe } from \"./column_recipes\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\nimport { Column } from \"./column\";\nimport { hasReachableData } from \"./utils\";\n\n// --- Types ---\n\nexport interface SplitAxis {\n /** Index of the axis in the column's axesSpec to split by. */\n readonly idx: number;\n}\n\nexport interface SplitByAxesOpts {\n /**\n * Resolve axis values to human-readable labels.\n *\n * Defaults to {@link deriveAxisValuesLabels} over the ambient render ctx\n * (current block outputs + result pool), resolved lazily on the first\n * lookup. Pass an explicit callback to narrow the label source, or\n * `() => undefined` to keep raw axis values.\n */\n axisValuesLabels?: (axisId: AxisId) => undefined | Record<string | number, string>;\n}\n\n// --- Implementation ---\n\nconst MAX_KEY_COMBINATIONS = 10_000;\n\n/**\n * Split each input column along the requested axes into one\n * {@link ColumnRecipe} per Cartesian combination of the axes' distinct values.\n *\n * The split axes must be partition-key axes of the input's data — the distinct\n * values are read off the partition keys.\n *\n * Each split is produced as `ColumnOverriddenRecipe.wrap(ColumnFilteredRecipe.wrap(inner, axisFilters), { domain, annotations })`:\n * - `ColumnFilteredRecipe` pins all split axes at once (one wrap call with\n * every `[idx, value]` pair) and removes them from `axesSpec`. The\n * engine performs the data slicing via the `sliceAxes` query node.\n * - `ColumnOverriddenRecipe` overlays a `domain[axisName] = String(value)`\n * entry per split axis and appends a `split:<canonicalAxisId>` trace\n * entry per split axis to the existing `pl7.app/trace` annotation.\n *\n * The recipe id is a canonical\n * `ColumnOverriddenId(source: ColumnFilteredId(source: inner.id, axisFilters), specOverrides)`\n * — distinct per split combination, parseable by `extractPObjectId`, and\n * traversable by recipe walkers.\n *\n * Returns `undefined` when any input's `getData()` is not a\n * {@link TreeNodeAccessor} — partition inspection is not yet possible.\n */\nexport function splitByAxes(\n inputs: Column[],\n splitAxes: SplitAxis[],\n opts?: SplitByAxesOpts,\n): ColumnRecipe[] | undefined {\n if (splitAxes.length === 0) {\n return [...inputs];\n }\n\n const axisValuesLabels = opts?.axisValuesLabels ?? deriveAxisValuesLabels();\n\n const splitAxisIdxs = splitAxes.map((a) => a.idx).sort((a, b) => a - b);\n const maxSplitIdx = splitAxisIdxs[splitAxisIdxs.length - 1];\n\n const result: ColumnRecipe[] = [];\n\n for (const inner of inputs) {\n const data = hasReachableData(inner) ? inner.getData() : undefined;\n // Partition inspection requires either a live tree-accessor or already\n // parsed DataInfoEntries. Anything else means the input is not yet ready.\n if (!(data instanceof TreeNodeAccessor) && !isDataInfoEntries(data)) {\n return undefined;\n }\n\n const uniqueKeys = getUniquePartitionKeys(data);\n if (uniqueKeys === undefined) return undefined;\n\n if (maxSplitIdx >= uniqueKeys.length) {\n throw new Error(\n `Not enough partition keys (${uniqueKeys.length}) for requested split axes (max index ${maxSplitIdx}) in column ${inner.getSpec().name}`,\n );\n }\n\n const spec = inner.getSpec();\n const axesSpec = spec.axesSpec;\n const splitAxisSpecs = splitAxisIdxs.map((idx) => axesSpec[idx]);\n const splitAxisIds = splitAxisSpecs.map((axisSpec) => getAxisId(axisSpec));\n const axesLabels = splitAxisIds.map((axisId) => axisValuesLabels(axisId));\n\n const existingTraceRaw = readAnnotation(spec, Annotation.Trace);\n const baseTrace: TraceEntry[] = existingTraceRaw\n ? ((JSON.parse(existingTraceRaw) as TraceEntry[]) ?? [])\n : [];\n\n const keyCombinations = generateKeyCombinations(uniqueKeys, splitAxisIdxs);\n if (keyCombinations.length === 0) continue;\n\n for (const keyCombo of keyCombinations) {\n const axisFilters: AxisFilterByIdx[] = keyCombo.map(
|
|
1
|
+
{"version":3,"file":"split_by_axes.js","names":[],"sources":["../../src/columns/split_by_axes.ts"],"sourcesContent":["import type {\n AxisFilterByIdx,\n AxisFilterValue,\n AxisId,\n TraceEntry,\n} from \"@milaboratories/pl-model-common\";\nimport {\n Annotation,\n canonicalizeAxisId,\n getAxisId,\n isDataInfoEntries,\n readAnnotation,\n} from \"@milaboratories/pl-model-common\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getUniquePartitionKeys } from \"../render/util/pcolumn_data\";\nimport { deriveAxisValuesLabels } from \"./derive_axis_values_labels\";\nimport type { ColumnRecipe } from \"./column_recipes\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\nimport { Column } from \"./column\";\nimport { hasReachableData } from \"./utils\";\n\n// --- Types ---\n\nexport interface SplitAxis {\n /** Index of the axis in the column's axesSpec to split by. */\n readonly idx: number;\n}\n\nexport interface SplitByAxesOpts {\n /**\n * Resolve axis values to human-readable labels.\n *\n * Defaults to {@link deriveAxisValuesLabels} over the ambient render ctx\n * (current block outputs + result pool), resolved lazily on the first\n * lookup. Pass an explicit callback to narrow the label source, or\n * `() => undefined` to keep raw axis values.\n */\n axisValuesLabels?: (axisId: AxisId) => undefined | Record<string | number, string>;\n}\n\n// --- Implementation ---\n\nconst MAX_KEY_COMBINATIONS = 10_000;\n\n/**\n * Split each input column along the requested axes into one\n * {@link ColumnRecipe} per Cartesian combination of the axes' distinct values.\n *\n * The split axes must be partition-key axes of the input's data — the distinct\n * values are read off the partition keys.\n *\n * Each split is produced as `ColumnOverriddenRecipe.wrap(ColumnFilteredRecipe.wrap(inner, axisFilters), { domain, annotations })`:\n * - `ColumnFilteredRecipe` pins all split axes at once (one wrap call with\n * every `[idx, value]` pair) and removes them from `axesSpec`. The\n * engine performs the data slicing via the `sliceAxes` query node.\n * - `ColumnOverriddenRecipe` overlays a `domain[axisName] = String(value)`\n * entry per split axis and appends a `split:<canonicalAxisId>` trace\n * entry per split axis to the existing `pl7.app/trace` annotation.\n *\n * The recipe id is a canonical\n * `ColumnOverriddenId(source: ColumnFilteredId(source: inner.id, axisFilters), specOverrides)`\n * — distinct per split combination, parseable by `extractPObjectId`, and\n * traversable by recipe walkers.\n *\n * Returns `undefined` when any input's `getData()` is not a\n * {@link TreeNodeAccessor} — partition inspection is not yet possible.\n */\nexport function splitByAxes(\n inputs: Column[],\n splitAxes: SplitAxis[],\n opts?: SplitByAxesOpts,\n): ColumnRecipe[] | undefined {\n if (splitAxes.length === 0) {\n return [...inputs];\n }\n\n const axisValuesLabels = opts?.axisValuesLabels ?? deriveAxisValuesLabels();\n\n const splitAxisIdxs = splitAxes.map((a) => a.idx).sort((a, b) => a - b);\n const maxSplitIdx = splitAxisIdxs[splitAxisIdxs.length - 1];\n\n const result: ColumnRecipe[] = [];\n\n for (const inner of inputs) {\n const data = hasReachableData(inner) ? inner.getData() : undefined;\n // Partition inspection requires either a live tree-accessor or already\n // parsed DataInfoEntries. Anything else means the input is not yet ready.\n if (!(data instanceof TreeNodeAccessor) && !isDataInfoEntries(data)) {\n return undefined;\n }\n\n const uniqueKeys = getUniquePartitionKeys(data);\n if (uniqueKeys === undefined) return undefined;\n\n if (maxSplitIdx >= uniqueKeys.length) {\n throw new Error(\n `Not enough partition keys (${uniqueKeys.length}) for requested split axes (max index ${maxSplitIdx}) in column ${inner.getSpec().name}`,\n );\n }\n\n const spec = inner.getSpec();\n const axesSpec = spec.axesSpec;\n const splitAxisSpecs = splitAxisIdxs.map((idx) => axesSpec[idx]);\n const splitAxisIds = splitAxisSpecs.map((axisSpec) => getAxisId(axisSpec));\n const axesLabels = splitAxisIds.map((axisId) => axisValuesLabels(axisId));\n\n const existingTraceRaw = readAnnotation(spec, Annotation.Trace);\n const baseTrace: TraceEntry[] = existingTraceRaw\n ? ((JSON.parse(existingTraceRaw) as TraceEntry[]) ?? [])\n : [];\n\n const keyCombinations = generateKeyCombinations(uniqueKeys, splitAxisIdxs);\n if (keyCombinations.length === 0) continue;\n\n for (const keyCombo of keyCombinations) {\n const axisFilters: AxisFilterByIdx[] = keyCombo.map((value, sAxisIdx): AxisFilterByIdx => [\n splitAxisIdxs[sAxisIdx],\n value as AxisFilterValue,\n ]);\n\n const domain: Record<string, string> = {};\n const traceEntries: TraceEntry[] = [];\n for (let sAxisIdx = 0; sAxisIdx < keyCombo.length; sAxisIdx++) {\n const value = keyCombo[sAxisIdx];\n const axisSpec = splitAxisSpecs[sAxisIdx];\n const axisId = splitAxisIds[sAxisIdx];\n const labelMap = axesLabels[sAxisIdx];\n const label = labelMap?.[value] ?? String(value);\n domain[axisSpec.name] = String(value);\n traceEntries.push({\n type: `split:${canonicalizeAxisId(axisId)}`,\n label,\n importance: 1_000_000,\n });\n }\n\n const filtered = ColumnFilteredRecipe.wrap(inner, axisFilters);\n const overrided = ColumnOverriddenRecipe.wrap(filtered, {\n domain,\n annotations: {\n [Annotation.Trace]: JSON.stringify([...baseTrace, ...traceEntries]),\n },\n });\n\n result.push(overrided);\n }\n }\n\n return result;\n}\n\nfunction generateKeyCombinations(\n uniqueKeys: (string | number)[][],\n splitAxisIdxs: number[],\n): (string | number)[][] {\n const combinations: (string | number)[][] = [];\n\n function generate(currentCombo: (string | number)[], sAxisIdx: number): void {\n if (sAxisIdx >= splitAxisIdxs.length) {\n combinations.push([...currentCombo]);\n if (combinations.length > MAX_KEY_COMBINATIONS) {\n throw new Error(\"Too many key combinations, aborting.\");\n }\n return;\n }\n\n const axisIdx = splitAxisIdxs[sAxisIdx];\n if (axisIdx >= uniqueKeys.length) {\n throw new Error(\n `Axis index ${axisIdx} out of bounds for unique keys array (length ${uniqueKeys.length})`,\n );\n }\n\n const axisValues = uniqueKeys[axisIdx];\n if (!axisValues || axisValues.length === 0) {\n combinations.length = 0;\n return;\n }\n\n for (const val of axisValues) {\n currentCombo.push(val);\n generate(currentCombo, sAxisIdx + 1);\n currentCombo.pop();\n }\n }\n\n generate([], 0);\n return combinations;\n}\n"],"mappings":";;;;;;;;AA2CA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;AAyB7B,SAAgB,YACd,QACA,WACA,MAC4B;CAC5B,IAAI,UAAU,WAAW,GACvB,OAAO,CAAC,GAAG,MAAM;CAGnB,MAAM,mBAAmB,MAAM,oBAAoB,uBAAuB;CAE1E,MAAM,gBAAgB,UAAU,KAAK,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;CACtE,MAAM,cAAc,cAAc,cAAc,SAAS;CAEzD,MAAM,SAAyB,CAAC;CAEhC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,iBAAiB,KAAK,IAAI,MAAM,QAAQ,IAAI,KAAA;EAGzD,IAAI,EAAE,gBAAgB,qBAAqB,CAAC,kBAAkB,IAAI,GAChE;EAGF,MAAM,aAAa,uBAAuB,IAAI;EAC9C,IAAI,eAAe,KAAA,GAAW,OAAO,KAAA;EAErC,IAAI,eAAe,WAAW,QAC5B,MAAM,IAA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C,CAAC;CAE7C,SAAS,SAAS,cAAmC,UAAwB;EAC3E,IAAI,YAAY,cAAc,QAAQ;GACpC,aAAa,KAAK,CAAC,GAAG,YAAY,CAAC;GACnC,IAAI,aAAa,SAAS,sBACxB,MAAM,IAAI,MAAM,sCAAsC;GAExD;EACF;EAEA,MAAM,UAAU,cAAc;EAC9B,IAAI,WAAW,WAAW,QACxB,MAAM,IAAI,MACR,cAAc,QAAQ,+CAA+C,WAAW,OAAO,EACzF;EAGF,MAAM,aAAa,WAAW;EAC9B,IAAI,CAAC,cAAc,WAAW,WAAW,GAAG;GAC1C,aAAa,SAAS;GACtB;EACF;EAEA,KAAK,MAAM,OAAO,YAAY;GAC5B,aAAa,KAAK,GAAG;GACrB,SAAS,cAAc,WAAW,CAAC;GACnC,aAAa,IAAI;EACnB;CACF;CAEA,SAAS,CAAC,GAAG,CAAC;CACd,OAAO;AACT"}
|
package/dist/columns/utils.cjs
CHANGED
|
@@ -9,7 +9,7 @@ const require_columns_collection = require("./columns_collection.cjs");
|
|
|
9
9
|
const require_peer_links = require("./peer_links.cjs");
|
|
10
10
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
11
11
|
let _milaboratories_helpers = require("@milaboratories/helpers");
|
|
12
|
-
|
|
12
|
+
// src/columns/utils.ts
|
|
13
13
|
/**
|
|
14
14
|
* PObjectIds of every non-hit column referenced by `recipe.getQuery()`,
|
|
15
15
|
* deduped in traversal order. The hit column is
|
|
@@ -191,7 +191,7 @@ function deriveColumnOptions(source, labelOptions = {}) {
|
|
|
191
191
|
function deriveRecipeOptions(recipes, labelOptions = {}) {
|
|
192
192
|
const labels = require_derive_distinct_labels.deriveDistinctLabels(recipes.map((r) => r.getSpec()), labelOptions);
|
|
193
193
|
const findPeerLinks = createPeerLinkFinder();
|
|
194
|
-
|
|
194
|
+
const options = recipes.map((recipe, i) => {
|
|
195
195
|
const links = findPeerLinks(recipe);
|
|
196
196
|
return {
|
|
197
197
|
id: recipe.id,
|
|
@@ -199,9 +199,9 @@ function deriveRecipeOptions(recipes, labelOptions = {}) {
|
|
|
199
199
|
linkHint: links.length > 0 ? require_peer_links.describePeerLinks(links) : void 0,
|
|
200
200
|
recipe
|
|
201
201
|
};
|
|
202
|
-
})
|
|
202
|
+
});
|
|
203
|
+
return require_peer_links.peerLinkedLast(options, (o) => o.linkHint !== void 0);
|
|
203
204
|
}
|
|
204
|
-
//#endregion
|
|
205
205
|
exports.collectLinkerColumns = collectLinkerColumns;
|
|
206
206
|
exports.collectLinkerIds = collectLinkerIds;
|
|
207
207
|
exports.createPeerLinkFinder = createPeerLinkFinder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["DataColumnImpl","getResultPoolDatasetAxes","findPeerLinks","TreeNodeAccessor","ColumnDiscoveredRecipe","ColumnOverriddenRecipe","ColumnFilteredRecipe","DataColumnOverriddenRecipe","isColumnsCollection","ColumnsCollection","deriveDistinctLabels","peerLinkedLast","describePeerLinks"],"sources":["../../src/columns/utils.ts"],"sourcesContent":["import {\n collectSpecQueryColumns,\n extractPObjectId,\n isDataInfo,\n visitDataInfo,\n type AxisQualification,\n type ColumnUniversalId,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { DataColumnRecipe, DataColumnImpl, type ColumnData } from \"./data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_recipes/column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport {\n ColumnOverriddenRecipe,\n DataColumnOverriddenRecipe,\n} from \"./column_recipes/column_overrided_recipe\";\nimport type { ColumnRecipe } from \"./column_recipes/types\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { ColumnsSource } from \"./column_providers/types\";\nimport {\n describePeerLinks,\n findPeerLinks,\n getResultPoolDatasetAxes,\n peerLinkedLast,\n} from \"./peer_links\";\n\n/**\n * PObjectIds of every non-hit column referenced by `recipe.getQuery()`,\n * deduped in traversal order. The hit column is\n * `extractPObjectId(recipe.id)`; anything else in the query is a linker or\n * other engine-consumed column.\n *\n * Pure query walk — no registry access. Use {@link collectLinkerColumns} for\n * the resolved {@link DataColumnRecipe} variant.\n */\nexport function collectLinkerIds(recipe: ColumnRecipe): PObjectId[] {\n const hit = extractPObjectId(recipe.id);\n const seen = new Set<PObjectId>();\n const out: PObjectId[] = [];\n for (const id of collectSpecQueryColumns(recipe.getQuery())) {\n // Leaf ids in SpecQuery may be rich (e.g. ColumnDiscoveredId) — drop to\n // bare PObjectId before comparing/registering so we hand the ambient\n // ColumnRegistry physical ids it can resolve.\n const bare = extractPObjectId(id);\n if (bare === hit) continue;\n if (seen.has(bare)) continue;\n seen.add(bare);\n out.push(bare);\n }\n return out;\n}\n\n/**\n * {@link collectLinkerIds} resolved against the ambient context as\n * {@link DataColumnRecipe} leaves. Throws if any id fails to resolve —\n * matches the contract of the legacy `resolveLinkers` it replaces.\n */\nexport function collectLinkerColumns(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): DataColumnRecipe<PObjectId>[] {\n return collectLinkerIds(recipe).map(\n (id) =>\n DataColumnImpl.fromId(id, opts) ??\n throwError(`materializeLinkers: linker ${id} not resolvable`),\n );\n}\n\n/** Peer link labels for a column, checked against the result pool's datasets. */\nexport function createPeerLinkFinder(): (recipe: ColumnRecipe) => string[] {\n const datasetAxes = getResultPoolDatasetAxes();\n return (recipe) =>\n findPeerLinks(\n collectLinkerColumns(recipe).map((l) => l.getSpec()),\n datasetAxes,\n );\n}\n\n/**\n * Hit-side axis qualifications for the recipe — the ones that should land on\n * the outer-join entry wrapping this column at the consumer boundary.\n *\n * Descends {@link ColumnOverriddenRecipe} / {@link ColumnFilteredRecipe} via\n * `getInner()` until it finds a {@link ColumnDiscoveredRecipe}; otherwise\n * returns `[]`. Pure recipe walk — no query-tree introspection.\n */\nexport function hitQualifications(recipe: ColumnRecipe): readonly AxisQualification[] {\n const discovered = findDiscovered(recipe);\n return discovered?.getColumnQualifications() ?? [];\n}\n\n/**\n * Per-primary-column axis qualifications for the recipe — applied to the\n * outer primary anchors on this recipe's group side. Keyed by the external\n * primary column id (NOT by columns inside this recipe's own query).\n *\n * Same walk strategy as {@link hitQualifications}.\n */\nexport function queriesQualifications(\n recipe: ColumnRecipe,\n): Readonly<Record<PObjectId, AxisQualification[]>> {\n const discovered = findDiscovered(recipe);\n return discovered?.getQueriesQualifications() ?? {};\n}\n\n/**\n * Whether the recipe's underlying data resources actually carry bytes —\n * strictly stronger than `getDataStatus() === \"present\"`, which only tells\n * that the `.data` field is wired onto the accessor.\n *\n * Walks every physical leaf the recipe depends on via\n * {@link ColumnRecipe.getReferencedIds} (resolves each id back to a\n * {@link DataColumnRecipe} through the ambient ctx) and ANDs `hasData()` across\n * all of them. Inline {@link PColumnValues} payloads count as present.\n *\n * Returns `false` if any leaf cannot be re-resolved in `opts.ctx` (treat as\n * \"not yet ready\") rather than throwing — this is a UI-facing predicate, not\n * a contract assertion.\n */\nexport function hasColumnData(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): boolean {\n for (const id of recipe.getReferencedIds()) {\n const leaf = DataColumnImpl.fromId(id, opts);\n if (leaf === undefined) return false;\n if (leaf.getDataStatus() !== \"present\") return false;\n if (!isLeafDataPresent(leaf.getData())) return false;\n }\n return true;\n}\n\nfunction isLeafDataPresent(data: ColumnData): boolean {\n if (data === undefined) return false;\n if (Array.isArray(data)) return true;\n if (data instanceof TreeNodeAccessor) return data.hasData();\n if (isDataInfo(data)) {\n let ok = true;\n visitDataInfo(data, (blob) => {\n ok &&= blob.hasData();\n });\n return ok;\n }\n return false;\n}\n\n/**\n * Walk wrapper layers (Overridden, Filtered) until a {@link\n * ColumnDiscoveredRecipe} is found. Returns `undefined` if the recipe chain\n * has no Discovered layer (bare leaves and Overridden-over-leaf cases).\n *\n * Invariant from the wrapper classes themselves: there is at most one\n * Discovered layer in any recipe chain — Discovered is constructed only via\n * its own factory and is never re-wrapped by Discovered.\n */\nfunction findDiscovered(recipe: ColumnRecipe): undefined | ColumnDiscoveredRecipe {\n let current: ColumnRecipe = recipe;\n while (true) {\n if (current instanceof ColumnDiscoveredRecipe) return current;\n if (current instanceof ColumnOverriddenRecipe || current instanceof ColumnFilteredRecipe) {\n current = current.getInner();\n continue;\n }\n return undefined;\n }\n}\n\n/**\n * Whether the recipe reads exactly one data column — its own — rather than\n * reaching through others.\n *\n * True for a bare leaf and for projections over one (spec overrides, axis\n * slicing): those add layers but no new columns. False when the recipe gets at\n * its data through further columns, which happens when discovery reached it via\n * a linker chain.\n *\n * **Why callers care.** A recipe over a single data column is co-indexed by its\n * own axes, so its spec is the whole truth about them. One that needs other\n * columns only lines up after they are joined in, and therefore drags axes into\n * the join that its own spec never mentions — which is why it cannot serve as a\n * primary column, and why `createPlDataTableV3` splits on this.\n *\n * The count comes from {@link ColumnRecipe.getReferencedIds}, which resolves\n * through the whole wrapper chain, so no class walk is involved and foreign\n * `ColumnRecipe` implementations are handled too.\n */\nexport function hasSingleDataColumn(recipe: ColumnRecipe): boolean {\n return recipe.getReferencedIds().length === 1;\n}\n\n/**\n * @deprecated Renamed to {@link hasSingleDataColumn} — \"leaf\" read as \"you can\n * get data out of it\", which is a different question (see\n * {@link hasReachableData}). Same semantics.\n */\nexport const isLeafColumn = hasSingleDataColumn;\n\n/**\n * Whether the column's data can be read here and now, consistent with its\n * spec — narrows to {@link DataColumnRecipe}, which exposes `getData()`.\n *\n * True for a bare leaf and for a spec-override over a bare leaf. False for an\n * axis-filtered recipe (its spec has dropped axes the underlying data still\n * carries, so the two no longer line up) and for anything reached through\n * other columns (nothing to read until the engine joins them). In both of\n * those cases the data exists only engine-side: pass `recipe.id` to\n * `createPFrame` / `createPTable` instead of trying to read it.\n *\n * The distinction is settled when the recipe is built, not here — recipes that\n * carry data are instances of a class that declares `getData`. So a `true`\n * result narrows to a value that really has the method, and there is no\n * throwing path behind the guard.\n */\nexport function hasReachableData(recipe: ColumnRecipe): recipe is DataColumnRecipe {\n return recipe instanceof DataColumnImpl || recipe instanceof DataColumnOverriddenRecipe;\n}\n\n/** Drop-down option built over a {@link ColumnsCollection} — universal-id valued. */\nexport type ColumnOption = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n /** Set for columns reached through a peer link; the dropdown shows it beside a link icon. */\n readonly linkHint?: string;\n};\n\n/**\n * Enumerates every column already in `source` and renders distinct labels\n * from each recipe's spec. Filtering is the caller's job — pass a\n * {@link ColumnsCollection} that was already narrowed via `.filter(...)` /\n * `.discover(...)`, or hand over a raw {@link ColumnsSource} (provider,\n * accessor, column array, or `\"result_pool\"` / `\"current_block\"` shorthand)\n * to be wrapped on the fly.\n */\nexport function deriveColumnOptions(\n source: ColumnsCollection | ColumnsSource[],\n labelOptions: DeriveLabelsOptions = {},\n): ColumnOption[] {\n const collection = isColumnsCollection(source) ? source : ColumnsCollection(source);\n return deriveRecipeOptions(collection.getColumns(), labelOptions).map(\n ({ id, label, linkHint }) => ({ id, label, linkHint }),\n );\n}\n\n/**\n * {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest\n * keep their order.\n */\nexport function deriveRecipeOptions<R extends ColumnRecipe>(\n recipes: R[],\n labelOptions: DeriveLabelsOptions = {},\n): (ColumnOption & { readonly recipe: R })[] {\n const labels = deriveDistinctLabels(\n recipes.map((r) => r.getSpec()),\n labelOptions,\n );\n const findPeerLinks = createPeerLinkFinder();\n const options = recipes.map((recipe, i) => {\n const links = findPeerLinks(recipe);\n return {\n id: recipe.id,\n label: labels[i],\n linkHint: links.length > 0 ? describePeerLinks(links) : undefined,\n recipe,\n };\n });\n return peerLinkedLast(options, (o) => o.linkHint !== undefined);\n}\n"],"mappings":";;;;;;;;;;;;;;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M,EAAE,QAAQ,CAAC,GAC9B,YACF;CACA,MAAM,gBAAgB,qBAAqB;CAU3C,OAAOC,mBAAAA,eATS,QAAQ,KAAK,QAAQ,MAAM;EACzC,MAAM,QAAQ,cAAc,MAAM;EAClC,OAAO;GACL,IAAI,OAAO;GACX,OAAO,OAAO;GACd,UAAU,MAAM,SAAS,IAAIC,mBAAAA,kBAAkB,KAAK,IAAI,KAAA;GACxD;EACF;CACF,CAC4B,IAAI,MAAM,EAAE,aAAa,KAAA,CAAS;AAChE"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["extractPObjectId","collectSpecQueryColumns","DataColumnImpl","throwError","getResultPoolDatasetAxes","findPeerLinks","TreeNodeAccessor","isDataInfo","ColumnDiscoveredRecipe","ColumnOverriddenRecipe","ColumnFilteredRecipe","DataColumnOverriddenRecipe","isColumnsCollection","ColumnsCollection","deriveDistinctLabels","describePeerLinks","peerLinkedLast"],"sources":["../../src/columns/utils.ts"],"sourcesContent":["import {\n collectSpecQueryColumns,\n extractPObjectId,\n isDataInfo,\n visitDataInfo,\n type AxisQualification,\n type ColumnUniversalId,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { DataColumnRecipe, DataColumnImpl, type ColumnData } from \"./data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_recipes/column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport {\n ColumnOverriddenRecipe,\n DataColumnOverriddenRecipe,\n} from \"./column_recipes/column_overrided_recipe\";\nimport type { ColumnRecipe } from \"./column_recipes/types\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { ColumnsSource } from \"./column_providers/types\";\nimport {\n describePeerLinks,\n findPeerLinks,\n getResultPoolDatasetAxes,\n peerLinkedLast,\n} from \"./peer_links\";\n\n/**\n * PObjectIds of every non-hit column referenced by `recipe.getQuery()`,\n * deduped in traversal order. The hit column is\n * `extractPObjectId(recipe.id)`; anything else in the query is a linker or\n * other engine-consumed column.\n *\n * Pure query walk — no registry access. Use {@link collectLinkerColumns} for\n * the resolved {@link DataColumnRecipe} variant.\n */\nexport function collectLinkerIds(recipe: ColumnRecipe): PObjectId[] {\n const hit = extractPObjectId(recipe.id);\n const seen = new Set<PObjectId>();\n const out: PObjectId[] = [];\n for (const id of collectSpecQueryColumns(recipe.getQuery())) {\n // Leaf ids in SpecQuery may be rich (e.g. ColumnDiscoveredId) — drop to\n // bare PObjectId before comparing/registering so we hand the ambient\n // ColumnRegistry physical ids it can resolve.\n const bare = extractPObjectId(id);\n if (bare === hit) continue;\n if (seen.has(bare)) continue;\n seen.add(bare);\n out.push(bare);\n }\n return out;\n}\n\n/**\n * {@link collectLinkerIds} resolved against the ambient context as\n * {@link DataColumnRecipe} leaves. Throws if any id fails to resolve —\n * matches the contract of the legacy `resolveLinkers` it replaces.\n */\nexport function collectLinkerColumns(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): DataColumnRecipe<PObjectId>[] {\n return collectLinkerIds(recipe).map(\n (id) =>\n DataColumnImpl.fromId(id, opts) ??\n throwError(`materializeLinkers: linker ${id} not resolvable`),\n );\n}\n\n/** Peer link labels for a column, checked against the result pool's datasets. */\nexport function createPeerLinkFinder(): (recipe: ColumnRecipe) => string[] {\n const datasetAxes = getResultPoolDatasetAxes();\n return (recipe) =>\n findPeerLinks(\n collectLinkerColumns(recipe).map((l) => l.getSpec()),\n datasetAxes,\n );\n}\n\n/**\n * Hit-side axis qualifications for the recipe — the ones that should land on\n * the outer-join entry wrapping this column at the consumer boundary.\n *\n * Descends {@link ColumnOverriddenRecipe} / {@link ColumnFilteredRecipe} via\n * `getInner()` until it finds a {@link ColumnDiscoveredRecipe}; otherwise\n * returns `[]`. Pure recipe walk — no query-tree introspection.\n */\nexport function hitQualifications(recipe: ColumnRecipe): readonly AxisQualification[] {\n const discovered = findDiscovered(recipe);\n return discovered?.getColumnQualifications() ?? [];\n}\n\n/**\n * Per-primary-column axis qualifications for the recipe — applied to the\n * outer primary anchors on this recipe's group side. Keyed by the external\n * primary column id (NOT by columns inside this recipe's own query).\n *\n * Same walk strategy as {@link hitQualifications}.\n */\nexport function queriesQualifications(\n recipe: ColumnRecipe,\n): Readonly<Record<PObjectId, AxisQualification[]>> {\n const discovered = findDiscovered(recipe);\n return discovered?.getQueriesQualifications() ?? {};\n}\n\n/**\n * Whether the recipe's underlying data resources actually carry bytes —\n * strictly stronger than `getDataStatus() === \"present\"`, which only tells\n * that the `.data` field is wired onto the accessor.\n *\n * Walks every physical leaf the recipe depends on via\n * {@link ColumnRecipe.getReferencedIds} (resolves each id back to a\n * {@link DataColumnRecipe} through the ambient ctx) and ANDs `hasData()` across\n * all of them. Inline {@link PColumnValues} payloads count as present.\n *\n * Returns `false` if any leaf cannot be re-resolved in `opts.ctx` (treat as\n * \"not yet ready\") rather than throwing — this is a UI-facing predicate, not\n * a contract assertion.\n */\nexport function hasColumnData(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): boolean {\n for (const id of recipe.getReferencedIds()) {\n const leaf = DataColumnImpl.fromId(id, opts);\n if (leaf === undefined) return false;\n if (leaf.getDataStatus() !== \"present\") return false;\n if (!isLeafDataPresent(leaf.getData())) return false;\n }\n return true;\n}\n\nfunction isLeafDataPresent(data: ColumnData): boolean {\n if (data === undefined) return false;\n if (Array.isArray(data)) return true;\n if (data instanceof TreeNodeAccessor) return data.hasData();\n if (isDataInfo(data)) {\n let ok = true;\n visitDataInfo(data, (blob) => {\n ok &&= blob.hasData();\n });\n return ok;\n }\n return false;\n}\n\n/**\n * Walk wrapper layers (Overridden, Filtered) until a {@link\n * ColumnDiscoveredRecipe} is found. Returns `undefined` if the recipe chain\n * has no Discovered layer (bare leaves and Overridden-over-leaf cases).\n *\n * Invariant from the wrapper classes themselves: there is at most one\n * Discovered layer in any recipe chain — Discovered is constructed only via\n * its own factory and is never re-wrapped by Discovered.\n */\nfunction findDiscovered(recipe: ColumnRecipe): undefined | ColumnDiscoveredRecipe {\n let current: ColumnRecipe = recipe;\n while (true) {\n if (current instanceof ColumnDiscoveredRecipe) return current;\n if (current instanceof ColumnOverriddenRecipe || current instanceof ColumnFilteredRecipe) {\n current = current.getInner();\n continue;\n }\n return undefined;\n }\n}\n\n/**\n * Whether the recipe reads exactly one data column — its own — rather than\n * reaching through others.\n *\n * True for a bare leaf and for projections over one (spec overrides, axis\n * slicing): those add layers but no new columns. False when the recipe gets at\n * its data through further columns, which happens when discovery reached it via\n * a linker chain.\n *\n * **Why callers care.** A recipe over a single data column is co-indexed by its\n * own axes, so its spec is the whole truth about them. One that needs other\n * columns only lines up after they are joined in, and therefore drags axes into\n * the join that its own spec never mentions — which is why it cannot serve as a\n * primary column, and why `createPlDataTableV3` splits on this.\n *\n * The count comes from {@link ColumnRecipe.getReferencedIds}, which resolves\n * through the whole wrapper chain, so no class walk is involved and foreign\n * `ColumnRecipe` implementations are handled too.\n */\nexport function hasSingleDataColumn(recipe: ColumnRecipe): boolean {\n return recipe.getReferencedIds().length === 1;\n}\n\n/**\n * @deprecated Renamed to {@link hasSingleDataColumn} — \"leaf\" read as \"you can\n * get data out of it\", which is a different question (see\n * {@link hasReachableData}). Same semantics.\n */\nexport const isLeafColumn = hasSingleDataColumn;\n\n/**\n * Whether the column's data can be read here and now, consistent with its\n * spec — narrows to {@link DataColumnRecipe}, which exposes `getData()`.\n *\n * True for a bare leaf and for a spec-override over a bare leaf. False for an\n * axis-filtered recipe (its spec has dropped axes the underlying data still\n * carries, so the two no longer line up) and for anything reached through\n * other columns (nothing to read until the engine joins them). In both of\n * those cases the data exists only engine-side: pass `recipe.id` to\n * `createPFrame` / `createPTable` instead of trying to read it.\n *\n * The distinction is settled when the recipe is built, not here — recipes that\n * carry data are instances of a class that declares `getData`. So a `true`\n * result narrows to a value that really has the method, and there is no\n * throwing path behind the guard.\n */\nexport function hasReachableData(recipe: ColumnRecipe): recipe is DataColumnRecipe {\n return recipe instanceof DataColumnImpl || recipe instanceof DataColumnOverriddenRecipe;\n}\n\n/** Drop-down option built over a {@link ColumnsCollection} — universal-id valued. */\nexport type ColumnOption = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n /** Set for columns reached through a peer link; the dropdown shows it beside a link icon. */\n readonly linkHint?: string;\n};\n\n/**\n * Enumerates every column already in `source` and renders distinct labels\n * from each recipe's spec. Filtering is the caller's job — pass a\n * {@link ColumnsCollection} that was already narrowed via `.filter(...)` /\n * `.discover(...)`, or hand over a raw {@link ColumnsSource} (provider,\n * accessor, column array, or `\"result_pool\"` / `\"current_block\"` shorthand)\n * to be wrapped on the fly.\n */\nexport function deriveColumnOptions(\n source: ColumnsCollection | ColumnsSource[],\n labelOptions: DeriveLabelsOptions = {},\n): ColumnOption[] {\n const collection = isColumnsCollection(source) ? source : ColumnsCollection(source);\n return deriveRecipeOptions(collection.getColumns(), labelOptions).map(\n ({ id, label, linkHint }) => ({ id, label, linkHint }),\n );\n}\n\n/**\n * {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest\n * keep their order.\n */\nexport function deriveRecipeOptions<R extends ColumnRecipe>(\n recipes: R[],\n labelOptions: DeriveLabelsOptions = {},\n): (ColumnOption & { readonly recipe: R })[] {\n const labels = deriveDistinctLabels(\n recipes.map((r) => r.getSpec()),\n labelOptions,\n );\n const findPeerLinks = createPeerLinkFinder();\n const options = recipes.map((recipe, i) => {\n const links = findPeerLinks(recipe);\n return {\n id: recipe.id,\n label: labels[i],\n linkHint: links.length > 0 ? describePeerLinks(links) : undefined,\n recipe,\n };\n });\n return peerLinkedLast(options, (o) => o.linkHint !== undefined);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,iBAAiB,QAAmC;CAClE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