@platforma-sdk/model 1.42.16 → 1.42.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bconfig/index.d.ts +0 -1
- package/dist/bconfig/lambdas.d.ts +0 -1
- package/dist/bconfig/normalization.cjs +19 -0
- package/dist/bconfig/normalization.cjs.map +1 -0
- package/dist/bconfig/normalization.d.ts +0 -1
- package/dist/bconfig/normalization.js +16 -0
- package/dist/bconfig/normalization.js.map +1 -0
- package/dist/bconfig/types.cjs +8 -0
- package/dist/bconfig/types.cjs.map +1 -0
- package/dist/bconfig/types.d.ts +0 -1
- package/dist/bconfig/types.js +6 -0
- package/dist/bconfig/types.js.map +1 -0
- package/dist/bconfig/util.d.ts +0 -1
- package/dist/bconfig/v3.d.ts +0 -1
- package/dist/block_api_v1.d.ts +0 -1
- package/dist/block_api_v2.d.ts +0 -1
- package/dist/block_state_patch.d.ts +0 -1
- package/dist/block_state_util.cjs +28 -0
- package/dist/block_state_util.cjs.map +1 -0
- package/dist/block_state_util.d.ts +0 -1
- package/dist/block_state_util.js +24 -0
- package/dist/block_state_util.js.map +1 -0
- package/dist/branding.d.ts +0 -1
- package/dist/builder.cjs +166 -0
- package/dist/builder.cjs.map +1 -0
- package/dist/builder.d.ts +0 -1
- package/dist/builder.js +164 -0
- package/dist/builder.js.map +1 -0
- package/dist/components/PFrameForGraphs.cjs +261 -0
- package/dist/components/PFrameForGraphs.cjs.map +1 -0
- package/dist/components/PFrameForGraphs.d.ts +0 -1
- package/dist/components/PFrameForGraphs.js +254 -0
- package/dist/components/PFrameForGraphs.js.map +1 -0
- package/dist/components/PlAnnotations/filter.d.ts +0 -1
- package/dist/components/PlAnnotations/filters_ui.cjs +556 -0
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -0
- package/dist/components/PlAnnotations/filters_ui.d.ts +0 -1
- package/dist/components/PlAnnotations/filters_ui.js +548 -0
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -0
- package/dist/components/PlAnnotations/index.d.ts +0 -1
- package/dist/components/PlAnnotations/types.d.ts +0 -1
- package/dist/components/PlDataTable.cjs +337 -0
- package/dist/components/PlDataTable.cjs.map +1 -0
- package/dist/components/PlDataTable.d.ts +0 -1
- package/dist/components/PlDataTable.js +324 -0
- package/dist/components/PlDataTable.js.map +1 -0
- package/dist/components/PlMultiSequenceAlignment.cjs +33 -0
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -0
- package/dist/components/PlMultiSequenceAlignment.d.ts +0 -1
- package/dist/components/PlMultiSequenceAlignment.js +31 -0
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -0
- package/dist/components/PlSelectionModel.cjs +11 -0
- package/dist/components/PlSelectionModel.cjs.map +1 -0
- package/dist/components/PlSelectionModel.d.ts +0 -1
- package/dist/components/PlSelectionModel.js +9 -0
- package/dist/components/PlSelectionModel.js.map +1 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/config/actions.cjs +266 -0
- package/dist/config/actions.cjs.map +1 -0
- package/dist/config/actions.d.ts +0 -1
- package/dist/config/actions.js +233 -0
- package/dist/config/actions.js.map +1 -0
- package/dist/config/actions_kinds.d.ts +0 -1
- package/dist/config/index.d.ts +0 -1
- package/dist/config/model.d.ts +0 -1
- package/dist/config/model_meta.d.ts +0 -1
- package/dist/config/type_engine.d.ts +0 -1
- package/dist/config/type_util.d.ts +0 -1
- package/dist/env_value.cjs +11 -0
- package/dist/env_value.cjs.map +1 -0
- package/dist/env_value.d.ts +0 -1
- package/dist/env_value.js +9 -0
- package/dist/env_value.js.map +1 -0
- package/dist/global.d.ts +14 -0
- package/dist/index.cjs +138 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +56 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.ts +0 -1
- package/dist/internal.js +49 -0
- package/dist/internal.js.map +1 -0
- package/dist/package.json.cjs +6 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +4 -0
- package/dist/package.json.js.map +1 -0
- package/dist/pframe.cjs +34 -0
- package/dist/pframe.cjs.map +1 -0
- package/dist/pframe.d.ts +0 -1
- package/dist/pframe.js +32 -0
- package/dist/pframe.js.map +1 -0
- package/dist/platforma.d.ts +0 -1
- package/dist/raw_globals.cjs +28 -0
- package/dist/raw_globals.cjs.map +1 -0
- package/dist/raw_globals.d.ts +0 -1
- package/dist/raw_globals.js +25 -0
- package/dist/raw_globals.js.map +1 -0
- package/dist/ref_util.cjs +21 -0
- package/dist/ref_util.cjs.map +1 -0
- package/dist/ref_util.d.ts +11 -12
- package/dist/ref_util.js +18 -0
- package/dist/ref_util.js.map +1 -0
- package/dist/render/accessor.cjs +233 -0
- package/dist/render/accessor.cjs.map +1 -0
- package/dist/render/accessor.d.ts +0 -1
- package/dist/render/accessor.js +230 -0
- package/dist/render/accessor.js.map +1 -0
- package/dist/render/api.cjs +514 -0
- package/dist/render/api.cjs.map +1 -0
- package/dist/render/api.d.ts +0 -1
- package/dist/render/api.js +511 -0
- package/dist/render/api.js.map +1 -0
- package/dist/render/future.cjs +35 -0
- package/dist/render/future.cjs.map +1 -0
- package/dist/render/future.d.ts +0 -1
- package/dist/render/future.js +33 -0
- package/dist/render/future.js.map +1 -0
- package/dist/render/index.d.ts +0 -1
- package/dist/render/internal.cjs +43 -0
- package/dist/render/internal.cjs.map +1 -0
- package/dist/render/internal.d.ts +0 -1
- package/dist/render/internal.js +37 -0
- package/dist/render/internal.js.map +1 -0
- package/dist/render/traversal_ops.d.ts +0 -1
- package/dist/render/util/axis_filtering.cjs +87 -0
- package/dist/render/util/axis_filtering.cjs.map +1 -0
- package/dist/render/util/axis_filtering.d.ts +0 -1
- package/dist/render/util/axis_filtering.js +85 -0
- package/dist/render/util/axis_filtering.js.map +1 -0
- package/dist/render/util/column_collection.cjs +309 -0
- package/dist/render/util/column_collection.cjs.map +1 -0
- package/dist/render/util/column_collection.d.ts +0 -1
- package/dist/render/util/column_collection.js +307 -0
- package/dist/render/util/column_collection.js.map +1 -0
- package/dist/render/util/index.d.ts +0 -1
- package/dist/render/util/label.cjs +153 -0
- package/dist/render/util/label.cjs.map +1 -0
- package/dist/render/util/label.d.ts +0 -1
- package/dist/render/util/label.js +149 -0
- package/dist/render/util/label.js.map +1 -0
- package/dist/render/util/pcolumn_data.cjs +342 -0
- package/dist/render/util/pcolumn_data.cjs.map +1 -0
- package/dist/render/util/pcolumn_data.d.ts +0 -1
- package/dist/render/util/pcolumn_data.js +330 -0
- package/dist/render/util/pcolumn_data.js.map +1 -0
- package/dist/render/util/pframe_upgraders.cjs +47 -0
- package/dist/render/util/pframe_upgraders.cjs.map +1 -0
- package/dist/render/util/pframe_upgraders.d.ts +0 -1
- package/dist/render/util/pframe_upgraders.js +45 -0
- package/dist/render/util/pframe_upgraders.js.map +1 -0
- package/dist/render/util/split_selectors.d.ts +0 -1
- package/dist/sdk_info.cjs +10 -0
- package/dist/sdk_info.cjs.map +1 -0
- package/dist/sdk_info.d.ts +0 -1
- package/dist/sdk_info.js +8 -0
- package/dist/sdk_info.js.map +1 -0
- package/dist/unionize.d.ts +0 -1
- package/dist/version.cjs +8 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.ts +0 -1
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +16 -18
- package/src/components/PFrameForGraphs.test.ts +2 -2
- package/src/components/PlAnnotations/filters_ui.test.ts +1 -1
- package/src/render/util/label.test.ts +2 -2
- package/src/typing.test.ts +2 -1
- package/dist/bconfig/index.d.ts.map +0 -1
- package/dist/bconfig/lambdas.d.ts.map +0 -1
- package/dist/bconfig/normalization.d.ts.map +0 -1
- package/dist/bconfig/types.d.ts.map +0 -1
- package/dist/bconfig/util.d.ts.map +0 -1
- package/dist/bconfig/v3.d.ts.map +0 -1
- package/dist/block_api_v1.d.ts.map +0 -1
- package/dist/block_api_v2.d.ts.map +0 -1
- package/dist/block_state_patch.d.ts.map +0 -1
- package/dist/block_state_util.d.ts.map +0 -1
- package/dist/branding.d.ts.map +0 -1
- package/dist/builder.d.ts.map +0 -1
- package/dist/components/PFrameForGraphs.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
- package/dist/components/PlAnnotations/index.d.ts.map +0 -1
- package/dist/components/PlAnnotations/types.d.ts.map +0 -1
- package/dist/components/PlDataTable.d.ts.map +0 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
- package/dist/components/PlSelectionModel.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/config/actions.d.ts.map +0 -1
- package/dist/config/actions_kinds.d.ts.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/model.d.ts.map +0 -1
- package/dist/config/model_meta.d.ts.map +0 -1
- package/dist/config/type_engine.d.ts.map +0 -1
- package/dist/config/type_util.d.ts.map +0 -1
- package/dist/env_value.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -2845
- package/dist/index.mjs.map +0 -1
- package/dist/internal.d.ts.map +0 -1
- package/dist/pframe.d.ts.map +0 -1
- package/dist/platforma.d.ts.map +0 -1
- package/dist/raw_globals.d.ts.map +0 -1
- package/dist/ref_util.d.ts.map +0 -1
- package/dist/render/accessor.d.ts.map +0 -1
- package/dist/render/api.d.ts.map +0 -1
- package/dist/render/future.d.ts.map +0 -1
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/internal.d.ts.map +0 -1
- package/dist/render/traversal_ops.d.ts.map +0 -1
- package/dist/render/util/axis_filtering.d.ts.map +0 -1
- package/dist/render/util/column_collection.d.ts.map +0 -1
- package/dist/render/util/index.d.ts.map +0 -1
- package/dist/render/util/label.d.ts.map +0 -1
- package/dist/render/util/pcolumn_data.d.ts.map +0 -1
- package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
- package/dist/render/util/split_selectors.d.ts.map +0 -1
- package/dist/sdk_info.d.ts.map +0 -1
- package/dist/unionize.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sources":["../src/builder.ts"],"sourcesContent":["import type { BlockRenderingMode, BlockSection, ValueOrErrors, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { Checked, ConfigResult, TypedConfig } from './config';\nimport { getImmediate } from './config';\nimport { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';\nimport type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';\nimport type { InferRenderFunctionReturn, RenderFunction } from './render';\nimport { RenderCtx } from './render';\nimport { PlatformaSDKVersion } from './version';\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ResolveCfgType,\n ExtractFunctionHandleReturn,\n ConfigRenderLambdaFlags,\n} from './bconfig';\nimport {\n downgradeCfgOrLambda,\n} from './bconfig';\n\ntype SectionsExpectedType = readonly BlockSection[];\n\ntype SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type SectionsRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends SectionsExpectedType ? true : false\n// >;\n\ntype InputsValidExpectedType = boolean;\n\ntype InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type InputsValidRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends InputsValidExpectedType ? true : false\n// >;\n\ntype NoOb = Record<string, never>;\n\n/** Main entry point that each block should use in it's \"config\" module. Don't forget\n * to call {@link done()} at the end of configuration. Value returned by this builder must be\n * exported as constant with name \"platforma\" from the \"config\" module. */\nexport class BlockModel<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n Href extends `/${string}` = '/',\n> {\n private constructor(\n private readonly _renderingMode: BlockRenderingMode,\n private readonly _initialArgs: Args | undefined,\n private readonly _initialUiState: UiState,\n private readonly _outputs: OutputsCfg,\n private readonly _inputsValid: TypedConfigOrConfigLambda,\n private readonly _sections: TypedConfigOrConfigLambda,\n private readonly _title: ConfigRenderLambda | undefined,\n private readonly _enrichmentTargets: ConfigRenderLambda | undefined,\n private readonly _featureFlags: BlockCodeKnownFeatureFlags,\n ) {}\n\n public static readonly INITIAL_BLOCK_FEATURE_FLAGS: BlockCodeKnownFeatureFlags = {\n supportsLazyState: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n };\n\n /** Initiates configuration builder */\n public static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;\n /** Initiates configuration builder */\n public static create(): BlockModel<NoOb, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(): BlockModel<Args, {}, NoOb>;\n public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {\n return new BlockModel<NoOb, {}, NoOb>(\n renderingMode,\n undefined,\n {},\n {},\n getImmediate(true),\n getImmediate([]),\n undefined,\n undefined,\n { ...BlockModel.INITIAL_BLOCK_FEATURE_FLAGS },\n );\n }\n\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param cfg configuration describing how to render cell value from the blocks\n * workflow outputs\n * @deprecated use lambda-based API\n * */\n public output<const Key extends string, const Cfg extends TypedConfig>(\n key: Key,\n cfg: Cfg\n ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n flags?: ConfigRenderLambdaFlags\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n >;\n public output(\n key: string,\n cfgOrRf: TypedConfig | AnyFunction,\n flags: ConfigRenderLambdaFlags = {},\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n if (typeof cfgOrRf === 'function') {\n const handle = `output#${key}`;\n tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));\n return new BlockModel(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n {\n ...this._outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n } satisfies ConfigRenderLambda,\n },\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n {\n ...this._outputs,\n [key]: cfgOrRf,\n },\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n > {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Sets custom configuration predicate on the block args at which block can be executed\n * @deprecated use lambda-based API */\n public argsValid<Cfg extends TypedConfig>(\n cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n /** Sets custom configuration predicate on the block args at which block can be executed */\n public argsValid<RF extends RenderFunction<Args, UiState, boolean>>(\n rf: RF\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n public argsValid(\n cfgOrRf: TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (typeof cfgOrRf === 'function') {\n tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n {\n __renderLambda: true,\n handle: 'inputsValid',\n } satisfies ConfigRenderLambda,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n cfgOrRf,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets the config to generate list of section in the left block overviews panel\n * @deprecated use lambda-based API */\n public sections<const S extends SectionsExpectedType>(\n rf: S\n ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;\n /** Sets the config to generate list of section in the left block overviews panel */\n public sections<\n const Ret extends SectionsExpectedType,\n const RF extends RenderFunction<Args, UiState, Ret>,\n >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;\n public sections<const Cfg extends TypedConfig>(\n cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>\n ): BlockModel<\n Args,\n OutputsCfg,\n UiState,\n DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>\n >;\n public sections(\n arrOrCfgOrRf: SectionsExpectedType | TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (Array.isArray(arrOrCfgOrRf)) {\n return this.sections(getImmediate(arrOrCfgOrRf));\n } else if (typeof arrOrCfgOrRf === 'function') {\n tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n { __renderLambda: true, handle: 'sections' } as ConfigRenderLambda,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n arrOrCfgOrRf as TypedConfig,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */\n public title(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('title', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n { __renderLambda: true, handle: 'title' } as ConfigRenderLambda,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /**\n * Sets initial args for the block, this value must be specified.\n * @deprecated use {@link withArgs}\n * */\n public initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n value,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialValue: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n initialValue,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(initialValue: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n initialValue,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n { ...this._featureFlags, ...flags },\n );\n }\n\n /**\n * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.\n * Influences dependency graph construction.\n */\n public enriches(\n lambda: (args: Args) => PlRef[],\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('enrichmentTargets', lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n { __renderLambda: true, handle: 'enrichmentTargets' } as ConfigRenderLambda,\n this._featureFlags,\n );\n }\n\n public done(apiVersion?: 1): PlatformaV1<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n public done(apiVersion: 2): PlatformaV2<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n /** Renders all provided block settings into a pre-configured platforma API\n * instance, that can be used in frontend to interact with block state, and\n * other features provided by the platforma to the block. */\n public done(apiVersion?: PlatformaApiVersion): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n const requiresUIAPIVersion = apiVersion ?? 1;\n return this.withFeatureFlags({\n ...this._featureFlags,\n requiresUIAPIVersion,\n })._done(requiresUIAPIVersion);\n }\n\n public _done(apiVersion: PlatformaApiVersion): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n if (this._initialArgs === undefined) throw new Error('Initial arguments not set.');\n\n const config: BlockConfigContainer = {\n v3: {\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this._renderingMode,\n initialArgs: this._initialArgs,\n initialUiState: this._initialUiState,\n inputsValid: this._inputsValid,\n sections: this._sections,\n title: this._title,\n outputs: this._outputs,\n enrichmentTargets: this._enrichmentTargets,\n featureFlags: this._featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this._renderingMode,\n initialArgs: this._initialArgs,\n inputsValid: downgradeCfgOrLambda(this._inputsValid),\n sections: downgradeCfgOrLambda(this._sections),\n outputs: Object.fromEntries(\n Object.entries(this._outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),\n ),\n };\n\n globalThis.platformaApiVersion = apiVersion;\n\n if (!isInUI())\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n // normal operation inside the UI\n else return getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }) as any;\n }\n}\n\nexport type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig\n ? ResolveCfgType<CfgOrFH, Args, UiState>\n : CfgOrFH extends ConfigRenderLambda\n ? ExtractFunctionHandleReturn<CfgOrFH>\n : never;\n\ntype InferOutputsFromConfigs<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n> = {\n [Key in keyof OutputsCfg]: ValueOrErrors<InferOutputType<OutputsCfg[Key], Args, UiState>>;\n};\n"],"names":[],"mappings":";;;;;;;;;AAiDA;;AAE0E;MAC7D,UAAU,CAAA;AAOF,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,eAAA;AACA,IAAA,QAAA;AACA,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAA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,EAAE,IAAI,CAAC,eAAe;gBACpC,WAAW,EAAE,IAAI,CAAC,YAAY;gBAC9B,QAAQ,EAAE,IAAI,CAAC,SAAS;gBACxB,KAAK,EAAE,IAAI,CAAC,MAAM;gBAClB,OAAO,EAAE,IAAI,CAAC,QAAQ;gBACtB,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;gBAC1C,YAAY,EAAE,IAAI,CAAC,aAAa;AACjC,aAAA;;AAGD,YAAA,UAAU,EAAE,mBAAmB;YAC/B,aAAa,EAAE,IAAI,CAAC,cAAc;YAClC,WAAW,EAAE,IAAI,CAAC,YAAY;AAC9B,YAAA,WAAW,EAAE,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC;AACpD,YAAA,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC;AAC9C,YAAA,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CACxF;SACF;AAED,QAAA,UAAU,CAAC,mBAAmB,GAAG,UAAU;QAE3C,IAAI,CAAC,MAAM,EAAE;;YAEX,OAAO,EAAE,MAAM,EAAS;;;AAErB,YAAA,OAAO,oBAAoB,CAAC,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAQ;IAC/G;;;;;"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var plModelCommon = require('@milaboratories/pl-model-common');
|
|
4
|
+
require('canonicalize');
|
|
5
|
+
var accessor = require('../render/accessor.cjs');
|
|
6
|
+
var column_collection = require('../render/util/column_collection.cjs');
|
|
7
|
+
require('../render/util/label.cjs');
|
|
8
|
+
var PlDataTable = require('./PlDataTable.cjs');
|
|
9
|
+
|
|
10
|
+
/** Create id for column copy with added keys in axes domains */
|
|
11
|
+
const colId = (id, domains) => {
|
|
12
|
+
let wid = id.toString();
|
|
13
|
+
domains?.forEach((domain) => {
|
|
14
|
+
if (domain) {
|
|
15
|
+
for (const [k, v] of Object.entries(domain)) {
|
|
16
|
+
wid += k;
|
|
17
|
+
wid += v;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return wid;
|
|
22
|
+
};
|
|
23
|
+
/** All combinations with 1 key from each list */
|
|
24
|
+
function getKeysCombinations(idsLists) {
|
|
25
|
+
if (!idsLists.length) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
let result = [[]];
|
|
29
|
+
idsLists.forEach((list) => {
|
|
30
|
+
const nextResult = [];
|
|
31
|
+
list.forEach((key) => {
|
|
32
|
+
nextResult.push(...result.map((resultItem) => [...resultItem, key]));
|
|
33
|
+
});
|
|
34
|
+
result = nextResult;
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
/** Check if column is a linker column */
|
|
39
|
+
function isLinkerColumn(column) {
|
|
40
|
+
return !!plModelCommon.readAnnotationJson(column, plModelCommon.Annotation.IsLinkerColumn);
|
|
41
|
+
}
|
|
42
|
+
function getAvailableWithLinkersAxes(linkerColumns, blockAxes) {
|
|
43
|
+
const linkerMap = plModelCommon.LinkerMap.fromColumns(linkerColumns.map(plModelCommon.getColumnIdAndSpec));
|
|
44
|
+
const startKeys = [];
|
|
45
|
+
const blockAxesGrouped = [...blockAxes.values()].map((axis) => plModelCommon.getArrayFromAxisTree(plModelCommon.getAxesTree(axis)).map(plModelCommon.getAxisId));
|
|
46
|
+
for (const axesGroupBlock of blockAxesGrouped) {
|
|
47
|
+
const matched = linkerMap.keyAxesIds.find((keyIds) => keyIds.every((keySourceAxis) => axesGroupBlock.find((axisSpecFromBlock) => plModelCommon.matchAxisId(axisSpecFromBlock, keySourceAxis))));
|
|
48
|
+
if (matched) {
|
|
49
|
+
startKeys.push(plModelCommon.canonicalizeJson(matched)); // linker column can contain fewer domains than in block's columns, it's fixed on next step in enrichCompatible
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const availableKeys = linkerMap.searchAvailableAxesKeys(startKeys);
|
|
53
|
+
const availableAxes = linkerMap.getAxesListFromKeysList([...availableKeys]);
|
|
54
|
+
return new Map(availableAxes.map((axisSpec) => {
|
|
55
|
+
const id = plModelCommon.getAxisId(axisSpec);
|
|
56
|
+
return [plModelCommon.canonicalizeJson(id), axisSpec];
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
/** Add columns with fully compatible axes created from partial compatible ones */
|
|
60
|
+
function enrichCompatible(blockAxes, columns) {
|
|
61
|
+
const result = [];
|
|
62
|
+
columns.forEach((column) => {
|
|
63
|
+
result.push(...getAdditionalColumnsForColumn(blockAxes, column));
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
function getAdditionalColumnsForColumn(blockAxes, column) {
|
|
68
|
+
const columnAxesIds = column.spec.axesSpec.map(plModelCommon.getAxisId);
|
|
69
|
+
if (columnAxesIds.every((id) => blockAxes.has(plModelCommon.canonicalizeJson(id)))) {
|
|
70
|
+
return [column]; // the column is compatible with its own domains without modifications
|
|
71
|
+
}
|
|
72
|
+
// options with different possible domains for every axis of secondary column
|
|
73
|
+
const secondaryIdsOptions = columnAxesIds.map((id) => {
|
|
74
|
+
const result = [];
|
|
75
|
+
for (const [_, mainId] of blockAxes) {
|
|
76
|
+
if (plModelCommon.matchAxisId(mainId, id) && !plModelCommon.matchAxisId(id, mainId)) {
|
|
77
|
+
result.push(mainId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
});
|
|
82
|
+
// all possible combinations of axes with added domains
|
|
83
|
+
const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);
|
|
84
|
+
// sets of added to column domain fields
|
|
85
|
+
const allAddedDomainValues = new Set();
|
|
86
|
+
const addedNotToAllVariantsDomainValues = new Set();
|
|
87
|
+
const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {
|
|
88
|
+
const addedSet = new Set();
|
|
89
|
+
idsList.map((axisId, idx) => {
|
|
90
|
+
const d1 = column.spec.axesSpec[idx].domain;
|
|
91
|
+
const d2 = axisId.domain;
|
|
92
|
+
Object.entries(d2 ?? {}).forEach(([key, value]) => {
|
|
93
|
+
if (d1?.[key] === undefined) {
|
|
94
|
+
const item = JSON.stringify([key, value]);
|
|
95
|
+
addedSet.add(item);
|
|
96
|
+
allAddedDomainValues.add(item);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return ({
|
|
100
|
+
...axisId,
|
|
101
|
+
annotations: column.spec.axesSpec[idx].annotations,
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
return addedSet;
|
|
105
|
+
});
|
|
106
|
+
[...allAddedDomainValues].forEach((addedPart) => {
|
|
107
|
+
if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {
|
|
108
|
+
addedNotToAllVariantsDomainValues.add(addedPart);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {
|
|
112
|
+
const id = colId(column.id, idsList.map((id) => id.domain));
|
|
113
|
+
const label = plModelCommon.readAnnotation(column.spec, plModelCommon.Annotation.Label) ?? '';
|
|
114
|
+
const labelDomainPart = ([...addedByVariantsDomainValues[idx]])
|
|
115
|
+
.filter((str) => addedNotToAllVariantsDomainValues.has(str))
|
|
116
|
+
.sort()
|
|
117
|
+
.map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants
|
|
118
|
+
.join(' / ');
|
|
119
|
+
const annotations = {
|
|
120
|
+
...column.spec.annotations,
|
|
121
|
+
[plModelCommon.Annotation.Graph.IsVirtual]: plModelCommon.stringifyJson(true),
|
|
122
|
+
};
|
|
123
|
+
if (label || labelDomainPart) {
|
|
124
|
+
annotations[plModelCommon.Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
id: id,
|
|
128
|
+
spec: {
|
|
129
|
+
...column.spec,
|
|
130
|
+
axesSpec: idsList.map((axisId, idx) => ({
|
|
131
|
+
...axisId,
|
|
132
|
+
annotations: column.spec.axesSpec[idx].annotations,
|
|
133
|
+
})),
|
|
134
|
+
annotations,
|
|
135
|
+
},
|
|
136
|
+
data: column.data,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
return [column, ...additionalColumns];
|
|
140
|
+
}
|
|
141
|
+
function isColumnReady(c) {
|
|
142
|
+
let ready = true;
|
|
143
|
+
if (c.data instanceof accessor.TreeNodeAccessor) {
|
|
144
|
+
ready = ready && c.data.getIsReadyOrError();
|
|
145
|
+
}
|
|
146
|
+
else if (plModelCommon.isDataInfo(c.data)) {
|
|
147
|
+
plModelCommon.visitDataInfo(c.data, (v) => {
|
|
148
|
+
ready = ready && v.getIsReadyOrError();
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return ready;
|
|
152
|
+
}
|
|
153
|
+
function allColumnsReady(columns) {
|
|
154
|
+
return columns.every(isColumnReady);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool
|
|
158
|
+
(including linker columns and all label columns).
|
|
159
|
+
Block’s columns are added to pframe as is.
|
|
160
|
+
Other columns are added basing on set of axes of block’s columns, considering available with linker columns.
|
|
161
|
+
Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from
|
|
162
|
+
result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values
|
|
163
|
+
among existing ones).
|
|
164
|
+
In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case
|
|
165
|
+
of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)
|
|
166
|
+
and modified label (with added domain values in case if more than one copy with different domains exist).
|
|
167
|
+
*/
|
|
168
|
+
function createPFrameForGraphs(ctx, blockColumns) {
|
|
169
|
+
// if current block doesn't produce own columns then use all columns from result pool
|
|
170
|
+
if (!blockColumns) {
|
|
171
|
+
const columns = new column_collection.PColumnCollection();
|
|
172
|
+
columns.addColumnProvider(ctx.resultPool);
|
|
173
|
+
const allColumns = columns.getColumns(() => true, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
|
|
174
|
+
// if at least one column is not yet ready, we can't show the graph
|
|
175
|
+
if (!allColumnsReady(allColumns)) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
const allAxes = new Map(allColumns
|
|
179
|
+
.flatMap((column) => plModelCommon.getNormalizedAxesList(column.spec.axesSpec))
|
|
180
|
+
.map((axisSpec) => {
|
|
181
|
+
const axisId = plModelCommon.getAxisId(axisSpec);
|
|
182
|
+
return [plModelCommon.canonicalizeJson(axisId), axisSpec];
|
|
183
|
+
}));
|
|
184
|
+
// additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
|
|
185
|
+
const extendedColumns = enrichCompatible(allAxes, allColumns);
|
|
186
|
+
return ctx.createPFrame(extendedColumns);
|
|
187
|
+
}
|
|
188
|
+
if (!allColumnsReady(blockColumns)) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
// if current block has its own columns then take from result pool only compatible with them
|
|
192
|
+
const columns = new column_collection.PColumnCollection();
|
|
193
|
+
columns.addColumnProvider(ctx.resultPool);
|
|
194
|
+
columns.addColumns(blockColumns);
|
|
195
|
+
// all possible axes from block columns
|
|
196
|
+
const blockAxes = new Map();
|
|
197
|
+
// axes from block columns and compatible result pool columns
|
|
198
|
+
const allAxes = new Map();
|
|
199
|
+
for (const c of blockColumns) {
|
|
200
|
+
for (const spec of plModelCommon.getNormalizedAxesList(c.spec.axesSpec)) {
|
|
201
|
+
const aid = plModelCommon.getAxisId(spec);
|
|
202
|
+
blockAxes.set(plModelCommon.canonicalizeJson(aid), spec);
|
|
203
|
+
allAxes.set(plModelCommon.canonicalizeJson(aid), spec);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
|
|
207
|
+
const linkerColumns = columns.getColumns((spec) => isLinkerColumn(spec)) ?? [];
|
|
208
|
+
const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
|
|
209
|
+
// all possible axes from connected linkers
|
|
210
|
+
for (const item of availableWithLinkersAxes) {
|
|
211
|
+
blockAxes.set(...item);
|
|
212
|
+
allAxes.set(...item);
|
|
213
|
+
}
|
|
214
|
+
// all compatible with block columns but without label columns
|
|
215
|
+
const compatibleWithoutLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {
|
|
216
|
+
const axisId = plModelCommon.getAxisId(axisSpec);
|
|
217
|
+
for (const selectorAxisSpec of blockAxes.values()) {
|
|
218
|
+
if (plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId)) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !PlDataTable.isLabelColumn(column.spec));
|
|
224
|
+
// if at least one column is not yet ready, we can't show the graph
|
|
225
|
+
if (!allColumnsReady(compatibleWithoutLabels)) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
// extend axes set for label columns request
|
|
229
|
+
for (const c of compatibleWithoutLabels) {
|
|
230
|
+
for (const spec of plModelCommon.getNormalizedAxesList(c.spec.axesSpec)) {
|
|
231
|
+
const aid = plModelCommon.getAxisId(spec);
|
|
232
|
+
allAxes.set(plModelCommon.canonicalizeJson(aid), spec);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
|
|
236
|
+
const compatibleLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {
|
|
237
|
+
const axisId = plModelCommon.getAxisId(axisSpec);
|
|
238
|
+
for (const selectorAxisSpec of allAxes.values()) {
|
|
239
|
+
if (plModelCommon.matchAxisId(plModelCommon.getAxisId(selectorAxisSpec), axisId)) {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
}), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => PlDataTable.isLabelColumn(column.spec));
|
|
245
|
+
// if at least one column is not yet ready, we can't show the graph
|
|
246
|
+
if (!allColumnsReady(compatibleLabels)) {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
|
|
250
|
+
// additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
|
|
251
|
+
const extendedColumns = enrichCompatible(blockAxes, compatible);
|
|
252
|
+
return ctx.createPFrame(extendedColumns);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
exports.allColumnsReady = allColumnsReady;
|
|
256
|
+
exports.createPFrameForGraphs = createPFrameForGraphs;
|
|
257
|
+
exports.enrichCompatible = enrichCompatible;
|
|
258
|
+
exports.getAvailableWithLinkersAxes = getAvailableWithLinkersAxes;
|
|
259
|
+
exports.isColumnReady = isColumnReady;
|
|
260
|
+
exports.isLinkerColumn = isLinkerColumn;
|
|
261
|
+
//# sourceMappingURL=PFrameForGraphs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PFrameForGraphs.cjs","sources":["../../src/components/PFrameForGraphs.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpecNormalized,\n CanonicalizedJson,\n PColumn,\n PColumnSpec,\n PFrameHandle,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n canonicalizeJson,\n getAxisId,\n isDataInfo,\n matchAxisId,\n visitDataInfo,\n getColumnIdAndSpec,\n Annotation,\n readAnnotation,\n getNormalizedAxesList,\n stringifyJson,\n readAnnotationJson,\n LinkerMap,\n getArrayFromAxisTree,\n getAxesTree,\n} from '@milaboratories/pl-model-common';\nimport type { PColumnDataUniversal, RenderCtx } from '../render';\nimport { PColumnCollection, TreeNodeAccessor } from '../render';\nimport { isLabelColumn } from './PlDataTable';\n\n/** Create id for column copy with added keys in axes domains */\nconst colId = (id: PObjectId, domains: (Record<string, string> | undefined)[]) => {\n let wid = id.toString();\n domains?.forEach((domain) => {\n if (domain) {\n for (const [k, v] of Object.entries(domain)) {\n wid += k;\n wid += v;\n }\n }\n });\n return wid;\n};\n\n/** All combinations with 1 key from each list */\nfunction getKeysCombinations(idsLists: AxisId[][]) {\n if (!idsLists.length) {\n return [];\n }\n let result: AxisId[][] = [[]];\n idsLists.forEach((list) => {\n const nextResult: AxisId[][] = [];\n list.forEach((key) => {\n nextResult.push(...result.map((resultItem) => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\n/** Check if column is a linker column */\nexport function isLinkerColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.IsLinkerColumn);\n}\n\ntype AxesVault = Map<CanonicalizedJson<AxisId>, AxisSpecNormalized>;\n\nexport function getAvailableWithLinkersAxes(\n linkerColumns: PColumn<PColumnDataUniversal>[],\n blockAxes: AxesVault,\n): AxesVault {\n const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));\n const startKeys: CanonicalizedJson<AxisId[]>[] = [];\n const blockAxesGrouped: AxisId[][] = [...blockAxes.values()].map((axis) => getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));\n\n for (const axesGroupBlock of blockAxesGrouped) {\n const matched = linkerMap.keyAxesIds.find(\n (keyIds: AxisId[]) => keyIds.every(\n (keySourceAxis) => axesGroupBlock.find((axisSpecFromBlock) => matchAxisId(axisSpecFromBlock, keySourceAxis)),\n ),\n );\n if (matched) {\n startKeys.push(canonicalizeJson(matched)); // linker column can contain fewer domains than in block's columns, it's fixed on next step in enrichCompatible\n }\n }\n\n const availableKeys = linkerMap.searchAvailableAxesKeys(startKeys);\n const availableAxes = linkerMap.getAxesListFromKeysList([...availableKeys]);\n\n return new Map(availableAxes.map((axisSpec) => {\n const id = getAxisId(axisSpec);\n return [canonicalizeJson(id), axisSpec];\n }));\n}\n/** Add columns with fully compatible axes created from partial compatible ones */\nexport function enrichCompatible(blockAxes: AxesVault, columns: PColumn<PColumnDataUniversal>[]) {\n const result: PColumn<PColumnDataUniversal>[] = [];\n columns.forEach((column) => {\n result.push(...getAdditionalColumnsForColumn(blockAxes, column));\n });\n return result;\n}\n\nfunction getAdditionalColumnsForColumn(\n blockAxes: AxesVault,\n column: PColumn<PColumnDataUniversal>,\n): PColumn<PColumnDataUniversal>[] {\n const columnAxesIds = column.spec.axesSpec.map(getAxisId);\n\n if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) {\n return [column]; // the column is compatible with its own domains without modifications\n }\n\n // options with different possible domains for every axis of secondary column\n const secondaryIdsOptions = columnAxesIds.map((id) => {\n const result = [];\n for (const [_, mainId] of blockAxes) {\n if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) {\n result.push(mainId);\n }\n }\n return result;\n });\n // all possible combinations of axes with added domains\n const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);\n\n // sets of added to column domain fields\n const allAddedDomainValues = new Set<string>();\n const addedNotToAllVariantsDomainValues = new Set<string>();\n const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {\n const addedSet = new Set<string>();\n idsList.map((axisId, idx) => {\n const d1 = column.spec.axesSpec[idx].domain;\n const d2 = axisId.domain;\n Object.entries(d2 ?? {}).forEach(([key, value]) => {\n if (d1?.[key] === undefined) {\n const item = JSON.stringify([key, value]);\n addedSet.add(item);\n allAddedDomainValues.add(item);\n }\n });\n return ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n });\n });\n return addedSet;\n });\n [...allAddedDomainValues].forEach((addedPart) => {\n if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {\n addedNotToAllVariantsDomainValues.add(addedPart);\n }\n });\n\n const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {\n const id = colId(column.id, idsList.map((id) => id.domain));\n\n const label = readAnnotation(column.spec, Annotation.Label) ?? '';\n const labelDomainPart = ([...addedByVariantsDomainValues[idx]])\n .filter((str) => addedNotToAllVariantsDomainValues.has(str))\n .sort()\n .map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants\n .join(' / ');\n\n const annotations: Annotation = {\n ...column.spec.annotations,\n [Annotation.Graph.IsVirtual]: stringifyJson(true),\n };\n if (label || labelDomainPart) {\n annotations[Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;\n }\n\n return {\n id: id as PObjectId,\n spec: {\n ...column.spec,\n axesSpec: idsList.map((axisId, idx) => ({\n ...axisId,\n annotations: column.spec.axesSpec[idx].annotations,\n })),\n annotations,\n },\n data: column.data,\n };\n });\n\n return [column, ...additionalColumns];\n}\n\nexport function isColumnReady(c: PColumn<PColumnDataUniversal>) {\n let ready = true;\n if (c.data instanceof TreeNodeAccessor) {\n ready = ready && c.data.getIsReadyOrError();\n } else if (isDataInfo(c.data)) {\n visitDataInfo(c.data, (v) => {\n ready = ready && v.getIsReadyOrError();\n });\n }\n return ready;\n}\n\nexport function allColumnsReady(columns: PColumn<PColumnDataUniversal>[]): boolean {\n return columns.every(isColumnReady);\n}\n\n/**\n The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool\n (including linker columns and all label columns).\n Block’s columns are added to pframe as is.\n Other columns are added basing on set of axes of block’s columns, considering available with linker columns.\n Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from\n result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values\n among existing ones).\n In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case\n of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)\n and modified label (with added domain values in case if more than one copy with different domains exist).\n */\nexport function createPFrameForGraphs<A, U>(\n ctx: RenderCtx<A, U>,\n blockColumns?: PColumn<PColumnDataUniversal>[],\n): PFrameHandle | undefined {\n // if current block doesn't produce own columns then use all columns from result pool\n if (!blockColumns) {\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n\n const allColumns = columns.getColumns(() => true, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n // if at least one column is not yet ready, we can't show the graph\n if (!allColumnsReady(allColumns)) {\n return undefined;\n }\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return ctx.createPFrame(extendedColumns);\n };\n\n if (!allColumnsReady(blockColumns)) {\n return undefined;\n }\n\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(blockColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of blockColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getColumns((spec) => isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n // all compatible with block columns but without label columns\n const compatibleWithoutLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n for (const selectorAxisSpec of blockAxes.values()) {\n if (matchAxisId(getAxisId(selectorAxisSpec), axisId)) {\n return true;\n }\n }\n return false;\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // if at least one column is not yet ready, we can't show the graph\n if (!allColumnsReady(compatibleWithoutLabels)) {\n return undefined;\n }\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n for (const selectorAxisSpec of allAxes.values()) {\n if (matchAxisId(getAxisId(selectorAxisSpec), axisId)) {\n return true;\n }\n }\n return false;\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n // if at least one column is not yet ready, we can't show the graph\n if (!allColumnsReady(compatibleLabels)) {\n return undefined;\n }\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return ctx.createPFrame(extendedColumns);\n}\n"],"names":["readAnnotationJson","Annotation","LinkerMap","getColumnIdAndSpec","getArrayFromAxisTree","getAxesTree","getAxisId","matchAxisId","canonicalizeJson","readAnnotation","stringifyJson","TreeNodeAccessor","isDataInfo","visitDataInfo","PColumnCollection","getNormalizedAxesList","isLabelColumn"],"mappings":";;;;;;;;;AA6BA;AACA,MAAM,KAAK,GAAG,CAAC,EAAa,EAAE,OAA+C,KAAI;AAC/E,IAAA,IAAI,GAAG,GAAG,EAAE,CAAC,QAAQ,EAAE;AACvB,IAAA,OAAO,EAAE,OAAO,CAAC,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CAAC,IAAI,CAAC,CAAC;;AAGpH,IAAA,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE;AACtC,QAAA,OAAO,SAAS;IAClB;IAEA,MAAM,UAAU,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,CAAC;;IAGpE,MAAM,eAAe,GAAG,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC;AAE/D,IAAA,OAAO,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC;AAC1C;;;;;;;;;"}
|
|
@@ -22,4 +22,3 @@ export declare function allColumnsReady(columns: PColumn<PColumnDataUniversal>[]
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function createPFrameForGraphs<A, U>(ctx: RenderCtx<A, U>, blockColumns?: PColumn<PColumnDataUniversal>[]): PFrameHandle | undefined;
|
|
24
24
|
export {};
|
|
25
|
-
//# sourceMappingURL=PFrameForGraphs.d.ts.map
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { readAnnotationJson, Annotation, LinkerMap, getColumnIdAndSpec, getArrayFromAxisTree, getAxesTree, getAxisId, matchAxisId, canonicalizeJson, isDataInfo, visitDataInfo, getNormalizedAxesList, readAnnotation, stringifyJson } from '@milaboratories/pl-model-common';
|
|
2
|
+
import 'canonicalize';
|
|
3
|
+
import { TreeNodeAccessor } from '../render/accessor.js';
|
|
4
|
+
import { PColumnCollection } from '../render/util/column_collection.js';
|
|
5
|
+
import '../render/util/label.js';
|
|
6
|
+
import { isLabelColumn } from './PlDataTable.js';
|
|
7
|
+
|
|
8
|
+
/** Create id for column copy with added keys in axes domains */
|
|
9
|
+
const colId = (id, domains) => {
|
|
10
|
+
let wid = id.toString();
|
|
11
|
+
domains?.forEach((domain) => {
|
|
12
|
+
if (domain) {
|
|
13
|
+
for (const [k, v] of Object.entries(domain)) {
|
|
14
|
+
wid += k;
|
|
15
|
+
wid += v;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return wid;
|
|
20
|
+
};
|
|
21
|
+
/** All combinations with 1 key from each list */
|
|
22
|
+
function getKeysCombinations(idsLists) {
|
|
23
|
+
if (!idsLists.length) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
let result = [[]];
|
|
27
|
+
idsLists.forEach((list) => {
|
|
28
|
+
const nextResult = [];
|
|
29
|
+
list.forEach((key) => {
|
|
30
|
+
nextResult.push(...result.map((resultItem) => [...resultItem, key]));
|
|
31
|
+
});
|
|
32
|
+
result = nextResult;
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
/** Check if column is a linker column */
|
|
37
|
+
function isLinkerColumn(column) {
|
|
38
|
+
return !!readAnnotationJson(column, Annotation.IsLinkerColumn);
|
|
39
|
+
}
|
|
40
|
+
function getAvailableWithLinkersAxes(linkerColumns, blockAxes) {
|
|
41
|
+
const linkerMap = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec));
|
|
42
|
+
const startKeys = [];
|
|
43
|
+
const blockAxesGrouped = [...blockAxes.values()].map((axis) => getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));
|
|
44
|
+
for (const axesGroupBlock of blockAxesGrouped) {
|
|
45
|
+
const matched = linkerMap.keyAxesIds.find((keyIds) => keyIds.every((keySourceAxis) => axesGroupBlock.find((axisSpecFromBlock) => matchAxisId(axisSpecFromBlock, keySourceAxis))));
|
|
46
|
+
if (matched) {
|
|
47
|
+
startKeys.push(canonicalizeJson(matched)); // linker column can contain fewer domains than in block's columns, it's fixed on next step in enrichCompatible
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const availableKeys = linkerMap.searchAvailableAxesKeys(startKeys);
|
|
51
|
+
const availableAxes = linkerMap.getAxesListFromKeysList([...availableKeys]);
|
|
52
|
+
return new Map(availableAxes.map((axisSpec) => {
|
|
53
|
+
const id = getAxisId(axisSpec);
|
|
54
|
+
return [canonicalizeJson(id), axisSpec];
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/** Add columns with fully compatible axes created from partial compatible ones */
|
|
58
|
+
function enrichCompatible(blockAxes, columns) {
|
|
59
|
+
const result = [];
|
|
60
|
+
columns.forEach((column) => {
|
|
61
|
+
result.push(...getAdditionalColumnsForColumn(blockAxes, column));
|
|
62
|
+
});
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
function getAdditionalColumnsForColumn(blockAxes, column) {
|
|
66
|
+
const columnAxesIds = column.spec.axesSpec.map(getAxisId);
|
|
67
|
+
if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) {
|
|
68
|
+
return [column]; // the column is compatible with its own domains without modifications
|
|
69
|
+
}
|
|
70
|
+
// options with different possible domains for every axis of secondary column
|
|
71
|
+
const secondaryIdsOptions = columnAxesIds.map((id) => {
|
|
72
|
+
const result = [];
|
|
73
|
+
for (const [_, mainId] of blockAxes) {
|
|
74
|
+
if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) {
|
|
75
|
+
result.push(mainId);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
});
|
|
80
|
+
// all possible combinations of axes with added domains
|
|
81
|
+
const secondaryIdsVariants = getKeysCombinations(secondaryIdsOptions);
|
|
82
|
+
// sets of added to column domain fields
|
|
83
|
+
const allAddedDomainValues = new Set();
|
|
84
|
+
const addedNotToAllVariantsDomainValues = new Set();
|
|
85
|
+
const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {
|
|
86
|
+
const addedSet = new Set();
|
|
87
|
+
idsList.map((axisId, idx) => {
|
|
88
|
+
const d1 = column.spec.axesSpec[idx].domain;
|
|
89
|
+
const d2 = axisId.domain;
|
|
90
|
+
Object.entries(d2 ?? {}).forEach(([key, value]) => {
|
|
91
|
+
if (d1?.[key] === undefined) {
|
|
92
|
+
const item = JSON.stringify([key, value]);
|
|
93
|
+
addedSet.add(item);
|
|
94
|
+
allAddedDomainValues.add(item);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return ({
|
|
98
|
+
...axisId,
|
|
99
|
+
annotations: column.spec.axesSpec[idx].annotations,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
return addedSet;
|
|
103
|
+
});
|
|
104
|
+
[...allAddedDomainValues].forEach((addedPart) => {
|
|
105
|
+
if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) {
|
|
106
|
+
addedNotToAllVariantsDomainValues.add(addedPart);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const additionalColumns = secondaryIdsVariants.map((idsList, idx) => {
|
|
110
|
+
const id = colId(column.id, idsList.map((id) => id.domain));
|
|
111
|
+
const label = readAnnotation(column.spec, Annotation.Label) ?? '';
|
|
112
|
+
const labelDomainPart = ([...addedByVariantsDomainValues[idx]])
|
|
113
|
+
.filter((str) => addedNotToAllVariantsDomainValues.has(str))
|
|
114
|
+
.sort()
|
|
115
|
+
.map((v) => JSON.parse(v)?.[1]) // use in labels only domain values, but sort them by key to save the same order in all column variants
|
|
116
|
+
.join(' / ');
|
|
117
|
+
const annotations = {
|
|
118
|
+
...column.spec.annotations,
|
|
119
|
+
[Annotation.Graph.IsVirtual]: stringifyJson(true),
|
|
120
|
+
};
|
|
121
|
+
if (label || labelDomainPart) {
|
|
122
|
+
annotations[Annotation.Label] = label && labelDomainPart ? label + ' / ' + labelDomainPart : label + labelDomainPart;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
id: id,
|
|
126
|
+
spec: {
|
|
127
|
+
...column.spec,
|
|
128
|
+
axesSpec: idsList.map((axisId, idx) => ({
|
|
129
|
+
...axisId,
|
|
130
|
+
annotations: column.spec.axesSpec[idx].annotations,
|
|
131
|
+
})),
|
|
132
|
+
annotations,
|
|
133
|
+
},
|
|
134
|
+
data: column.data,
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
return [column, ...additionalColumns];
|
|
138
|
+
}
|
|
139
|
+
function isColumnReady(c) {
|
|
140
|
+
let ready = true;
|
|
141
|
+
if (c.data instanceof TreeNodeAccessor) {
|
|
142
|
+
ready = ready && c.data.getIsReadyOrError();
|
|
143
|
+
}
|
|
144
|
+
else if (isDataInfo(c.data)) {
|
|
145
|
+
visitDataInfo(c.data, (v) => {
|
|
146
|
+
ready = ready && v.getIsReadyOrError();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return ready;
|
|
150
|
+
}
|
|
151
|
+
function allColumnsReady(columns) {
|
|
152
|
+
return columns.every(isColumnReady);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool
|
|
156
|
+
(including linker columns and all label columns).
|
|
157
|
+
Block’s columns are added to pframe as is.
|
|
158
|
+
Other columns are added basing on set of axes of block’s columns, considering available with linker columns.
|
|
159
|
+
Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from
|
|
160
|
+
result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values
|
|
161
|
+
among existing ones).
|
|
162
|
+
In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case
|
|
163
|
+
of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)
|
|
164
|
+
and modified label (with added domain values in case if more than one copy with different domains exist).
|
|
165
|
+
*/
|
|
166
|
+
function createPFrameForGraphs(ctx, blockColumns) {
|
|
167
|
+
// if current block doesn't produce own columns then use all columns from result pool
|
|
168
|
+
if (!blockColumns) {
|
|
169
|
+
const columns = new PColumnCollection();
|
|
170
|
+
columns.addColumnProvider(ctx.resultPool);
|
|
171
|
+
const allColumns = columns.getColumns(() => true, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];
|
|
172
|
+
// if at least one column is not yet ready, we can't show the graph
|
|
173
|
+
if (!allColumnsReady(allColumns)) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
const allAxes = new Map(allColumns
|
|
177
|
+
.flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))
|
|
178
|
+
.map((axisSpec) => {
|
|
179
|
+
const axisId = getAxisId(axisSpec);
|
|
180
|
+
return [canonicalizeJson(axisId), axisSpec];
|
|
181
|
+
}));
|
|
182
|
+
// additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
|
|
183
|
+
const extendedColumns = enrichCompatible(allAxes, allColumns);
|
|
184
|
+
return ctx.createPFrame(extendedColumns);
|
|
185
|
+
}
|
|
186
|
+
if (!allColumnsReady(blockColumns)) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
// if current block has its own columns then take from result pool only compatible with them
|
|
190
|
+
const columns = new PColumnCollection();
|
|
191
|
+
columns.addColumnProvider(ctx.resultPool);
|
|
192
|
+
columns.addColumns(blockColumns);
|
|
193
|
+
// all possible axes from block columns
|
|
194
|
+
const blockAxes = new Map();
|
|
195
|
+
// axes from block columns and compatible result pool columns
|
|
196
|
+
const allAxes = new Map();
|
|
197
|
+
for (const c of blockColumns) {
|
|
198
|
+
for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
|
|
199
|
+
const aid = getAxisId(spec);
|
|
200
|
+
blockAxes.set(canonicalizeJson(aid), spec);
|
|
201
|
+
allAxes.set(canonicalizeJson(aid), spec);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden
|
|
205
|
+
const linkerColumns = columns.getColumns((spec) => isLinkerColumn(spec)) ?? [];
|
|
206
|
+
const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);
|
|
207
|
+
// all possible axes from connected linkers
|
|
208
|
+
for (const item of availableWithLinkersAxes) {
|
|
209
|
+
blockAxes.set(...item);
|
|
210
|
+
allAxes.set(...item);
|
|
211
|
+
}
|
|
212
|
+
// all compatible with block columns but without label columns
|
|
213
|
+
const compatibleWithoutLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {
|
|
214
|
+
const axisId = getAxisId(axisSpec);
|
|
215
|
+
for (const selectorAxisSpec of blockAxes.values()) {
|
|
216
|
+
if (matchAxisId(getAxisId(selectorAxisSpec), axisId)) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
}), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));
|
|
222
|
+
// if at least one column is not yet ready, we can't show the graph
|
|
223
|
+
if (!allColumnsReady(compatibleWithoutLabels)) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
// extend axes set for label columns request
|
|
227
|
+
for (const c of compatibleWithoutLabels) {
|
|
228
|
+
for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
|
|
229
|
+
const aid = getAxisId(spec);
|
|
230
|
+
allAxes.set(canonicalizeJson(aid), spec);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool
|
|
234
|
+
const compatibleLabels = (columns.getColumns((spec) => spec.axesSpec.some((axisSpec) => {
|
|
235
|
+
const axisId = getAxisId(axisSpec);
|
|
236
|
+
for (const selectorAxisSpec of allAxes.values()) {
|
|
237
|
+
if (matchAxisId(getAxisId(selectorAxisSpec), axisId)) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return false;
|
|
242
|
+
}), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));
|
|
243
|
+
// if at least one column is not yet ready, we can't show the graph
|
|
244
|
+
if (!allColumnsReady(compatibleLabels)) {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
const compatible = [...compatibleWithoutLabels, ...compatibleLabels];
|
|
248
|
+
// additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match
|
|
249
|
+
const extendedColumns = enrichCompatible(blockAxes, compatible);
|
|
250
|
+
return ctx.createPFrame(extendedColumns);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { allColumnsReady, createPFrameForGraphs, enrichCompatible, getAvailableWithLinkersAxes, isColumnReady, isLinkerColumn };
|
|
254
|
+
//# sourceMappingURL=PFrameForGraphs.js.map
|