@platforma-sdk/model 1.71.0 → 1.73.0
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/block_model.cjs +3 -0
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +2 -0
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +2 -0
- package/dist/block_model.js.map +1 -1
- package/dist/block_model_legacy.cjs +4 -1
- package/dist/block_model_legacy.cjs.map +1 -1
- package/dist/block_model_legacy.d.ts.map +1 -1
- package/dist/block_model_legacy.js +3 -1
- package/dist/block_model_legacy.js.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs +24 -14
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.d.ts +9 -2
- package/dist/components/PlDatasetSelector/build_dataset_options.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.js +25 -15
- package/dist/components/PlDatasetSelector/build_dataset_options.js.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.cjs +16 -12
- package/dist/components/PlDatasetSelector/filter_discovery.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.d.ts +3 -0
- package/dist/components/PlDatasetSelector/filter_discovery.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.js +16 -12
- package/dist/components/PlDatasetSelector/filter_discovery.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +8 -8
- package/src/block_model.ts +2 -0
- package/src/block_model_legacy.ts +2 -0
- package/src/components/PlDatasetSelector/build_dataset_options.ts +62 -25
- package/src/components/PlDatasetSelector/filter_discovery.test.ts +12 -6
- package/src/components/PlDatasetSelector/filter_discovery.ts +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_model_legacy.js","names":["#done"],"sources":["../src/block_model_legacy.ts"],"sourcesContent":["import type {\n BlockRenderingMode,\n BlockSection,\n AnyFunction,\n PlRef,\n BlockCodeKnownFeatureFlags,\n BlockConfigContainer,\n} 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, RenderFunctionLegacy } from \"./render\";\nimport { RenderCtxLegacy } from \"./render\";\nimport { PlatformaSDKVersion } from \"./version\";\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ConfigRenderLambdaFlags,\n InferOutputsFromConfigs,\n} from \"./bconfig\";\nimport { downgradeCfgOrLambda, isConfigLambda } from \"./bconfig\";\nimport type { PlatformaExtended } from \"./platforma\";\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\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\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 config: {\n readonly renderingMode: BlockRenderingMode;\n readonly initialArgs?: Args;\n readonly initialUiState: UiState;\n readonly outputs: OutputsCfg;\n readonly inputsValid: TypedConfigOrConfigLambda;\n readonly sections: TypedConfigOrConfigLambda;\n readonly title?: ConfigRenderLambda;\n readonly subtitle?: ConfigRenderLambda;\n readonly tags?: ConfigRenderLambda;\n readonly enrichmentTargets?: ConfigRenderLambda;\n readonly featureFlags: BlockCodeKnownFeatureFlags;\n },\n ) {}\n\n public static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags {\n return {\n supportsLazyState: true,\n supportsPframeQueryRanking: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n requiresCreatePTable: 2,\n };\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 initialUiState: {},\n outputs: {},\n inputsValid: getImmediate(true),\n sections: getImmediate([]),\n featureFlags: 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 wrapped with additional status information 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 RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n flags: ConfigRenderLambdaFlags & { withStatus: true },\n ): BlockModel<\n Args,\n OutputsCfg & {\n [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true };\n },\n UiState,\n Href\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 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 RenderFunctionLegacy<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 RenderCtxLegacy()));\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n },\n },\n });\n } else {\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: cfgOrRf,\n },\n });\n }\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Shortcut for {@link output} with withStatus flag set to true. */\n public outputWithStatus<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { withStatus: true });\n }\n\n /** Shortcut for {@link output} with retentive and withStatus flags set to true. */\n public retentiveOutputWithStatus<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { retentive: true, withStatus: 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 RenderFunctionLegacy<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 RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: {\n __renderLambda: true,\n handle: \"inputsValid\",\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: cfgOrRf,\n });\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 RenderFunctionLegacy<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 RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: {\n __renderLambda: true,\n handle: \"sections\",\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: arrOrCfgOrRf as TypedConfig,\n });\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: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"title\", () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n title: {\n __renderLambda: true,\n handle: \"title\",\n },\n });\n }\n\n public subtitle(\n rf: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"subtitle\", () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n subtitle: {\n __renderLambda: true,\n handle: \"subtitle\",\n },\n });\n }\n\n public tags(\n rf: RenderFunctionLegacy<Args, UiState, string[]>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"tags\", () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n tags: {\n __renderLambda: true,\n handle: \"tags\",\n },\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 this.withArgs(value);\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialArgs,\n });\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(\n initialUiState: UiState,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialUiState,\n });\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(\n flags: Partial<BlockCodeKnownFeatureFlags>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n featureFlags: {\n ...this.config.featureFlags,\n ...flags,\n },\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(lambda: (args: Args) => PlRef[]): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"enrichmentTargets\", lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n enrichmentTargets: {\n __renderLambda: true,\n handle: \"enrichmentTargets\",\n },\n });\n }\n\n public done(\n apiVersion?: 1,\n ): PlatformaExtended<\n PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n >;\n\n public done(\n apiVersion: 2,\n ): PlatformaExtended<\n PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, 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(\n apiVersion: PlatformaApiVersion = 1,\n ): PlatformaExtended<\n Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n > {\n return this.withFeatureFlags({\n ...this.config.featureFlags,\n requiresUIAPIVersion: apiVersion,\n }).#done();\n }\n\n #done(): PlatformaExtended<\n Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n > {\n if (this.config.initialArgs === undefined) throw new Error(\"Initial arguments not set.\");\n\n const config: BlockConfigContainer = {\n v4: undefined,\n v3: {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n initialUiState: this.config.initialUiState,\n inputsValid: this.config.inputsValid,\n sections: this.config.sections,\n title: this.config.title,\n subtitle: this.config.subtitle,\n tags: this.config.tags,\n outputs: this.config.outputs,\n enrichmentTargets: this.config.enrichmentTargets,\n featureFlags: this.config.featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n inputsValid: downgradeCfgOrLambda(this.config.inputsValid),\n sections: downgradeCfgOrLambda(this.config.sections),\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [\n key,\n downgradeCfgOrLambda(value),\n ]),\n ),\n };\n\n globalThis.platformaApiVersion = this.config.featureFlags\n .requiresUIAPIVersion as PlatformaApiVersion;\n\n if (!isInUI()) {\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n } else {\n // normal operation inside the UI\n return {\n ...getPlatformaInstance({\n sdkVersion: PlatformaSDKVersion,\n apiVersion: platformaApiVersion,\n }),\n blockModelInfo: {\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [\n key,\n {\n withStatus: Boolean(isConfigLambda(value) && value.withStatus),\n },\n ]),\n ),\n pluginIds: [],\n featureFlags: this.config.featureFlags,\n },\n };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6CA,IAAa,aAAb,MAAa,WAKX;CACA,YACE,QAaA;AAbQ,OAAA,SAAA;;CAeV,WAAkB,8BAA0D;AAC1E,SAAO;GACL,mBAAmB;GACnB,4BAA4B;GAC5B,sBAAsB;GACtB,yBAAyB;GACzB,sBAAsB;GACvB;;CAiBH,OAAc,OAAO,gBAAoC,SAAqC;AAC5F,SAAO,IAAI,WAA2B;GACpC;GACA,gBAAgB,EAAE;GAClB,SAAS,EAAE;GACX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ts"],"sourcesContent":["import type {\n BlockRenderingMode,\n BlockSection,\n AnyFunction,\n PlRef,\n BlockCodeKnownFeatureFlags,\n BlockConfigContainer,\n} from \"@milaboratories/pl-model-common\";\nimport { REQUIRES_PFRAMES_VERSION } 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, RenderFunctionLegacy } from \"./render\";\nimport { RenderCtxLegacy } from \"./render\";\nimport { PlatformaSDKVersion } from \"./version\";\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ConfigRenderLambdaFlags,\n InferOutputsFromConfigs,\n} from \"./bconfig\";\nimport { downgradeCfgOrLambda, isConfigLambda } from \"./bconfig\";\nimport type { PlatformaExtended } from \"./platforma\";\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\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\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 config: {\n readonly renderingMode: BlockRenderingMode;\n readonly initialArgs?: Args;\n readonly initialUiState: UiState;\n readonly outputs: OutputsCfg;\n readonly inputsValid: TypedConfigOrConfigLambda;\n readonly sections: TypedConfigOrConfigLambda;\n readonly title?: ConfigRenderLambda;\n readonly subtitle?: ConfigRenderLambda;\n readonly tags?: ConfigRenderLambda;\n readonly enrichmentTargets?: ConfigRenderLambda;\n readonly featureFlags: BlockCodeKnownFeatureFlags;\n },\n ) {}\n\n public static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags {\n return {\n supportsLazyState: true,\n supportsPframeQueryRanking: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n requiresCreatePTable: 2,\n requiresPFramesVersion: REQUIRES_PFRAMES_VERSION,\n };\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 initialUiState: {},\n outputs: {},\n inputsValid: getImmediate(true),\n sections: getImmediate([]),\n featureFlags: 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 wrapped with additional status information 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 RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n flags: ConfigRenderLambdaFlags & { withStatus: true },\n ): BlockModel<\n Args,\n OutputsCfg & {\n [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true };\n },\n UiState,\n Href\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 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 RenderFunctionLegacy<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 RenderCtxLegacy()));\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n },\n },\n });\n } else {\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: cfgOrRf,\n },\n });\n }\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Shortcut for {@link output} with withStatus flag set to true. */\n public outputWithStatus<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { withStatus: true });\n }\n\n /** Shortcut for {@link output} with retentive and withStatus flags set to true. */\n public retentiveOutputWithStatus<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { retentive: true, withStatus: 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 RenderFunctionLegacy<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 RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: {\n __renderLambda: true,\n handle: \"inputsValid\",\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: cfgOrRf,\n });\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 RenderFunctionLegacy<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 RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: {\n __renderLambda: true,\n handle: \"sections\",\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: arrOrCfgOrRf as TypedConfig,\n });\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: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"title\", () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n title: {\n __renderLambda: true,\n handle: \"title\",\n },\n });\n }\n\n public subtitle(\n rf: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"subtitle\", () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n subtitle: {\n __renderLambda: true,\n handle: \"subtitle\",\n },\n });\n }\n\n public tags(\n rf: RenderFunctionLegacy<Args, UiState, string[]>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"tags\", () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n tags: {\n __renderLambda: true,\n handle: \"tags\",\n },\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 this.withArgs(value);\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialArgs,\n });\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(\n initialUiState: UiState,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialUiState,\n });\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(\n flags: Partial<BlockCodeKnownFeatureFlags>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n featureFlags: {\n ...this.config.featureFlags,\n ...flags,\n },\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(lambda: (args: Args) => PlRef[]): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"enrichmentTargets\", lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n enrichmentTargets: {\n __renderLambda: true,\n handle: \"enrichmentTargets\",\n },\n });\n }\n\n public done(\n apiVersion?: 1,\n ): PlatformaExtended<\n PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n >;\n\n public done(\n apiVersion: 2,\n ): PlatformaExtended<\n PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, 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(\n apiVersion: PlatformaApiVersion = 1,\n ): PlatformaExtended<\n Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n > {\n return this.withFeatureFlags({\n ...this.config.featureFlags,\n requiresUIAPIVersion: apiVersion,\n }).#done();\n }\n\n #done(): PlatformaExtended<\n Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n > {\n if (this.config.initialArgs === undefined) throw new Error(\"Initial arguments not set.\");\n\n const config: BlockConfigContainer = {\n v4: undefined,\n v3: {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n initialUiState: this.config.initialUiState,\n inputsValid: this.config.inputsValid,\n sections: this.config.sections,\n title: this.config.title,\n subtitle: this.config.subtitle,\n tags: this.config.tags,\n outputs: this.config.outputs,\n enrichmentTargets: this.config.enrichmentTargets,\n featureFlags: this.config.featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n inputsValid: downgradeCfgOrLambda(this.config.inputsValid),\n sections: downgradeCfgOrLambda(this.config.sections),\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [\n key,\n downgradeCfgOrLambda(value),\n ]),\n ),\n };\n\n globalThis.platformaApiVersion = this.config.featureFlags\n .requiresUIAPIVersion as PlatformaApiVersion;\n\n if (!isInUI()) {\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n } else {\n // normal operation inside the UI\n return {\n ...getPlatformaInstance({\n sdkVersion: PlatformaSDKVersion,\n apiVersion: platformaApiVersion,\n }),\n blockModelInfo: {\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [\n key,\n {\n withStatus: Boolean(isConfigLambda(value) && value.withStatus),\n },\n ]),\n ),\n pluginIds: [],\n featureFlags: this.config.featureFlags,\n },\n };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,IAAa,aAAb,MAAa,WAKX;CACA,YACE,QAaA;AAbQ,OAAA,SAAA;;CAeV,WAAkB,8BAA0D;AAC1E,SAAO;GACL,mBAAmB;GACnB,4BAA4B;GAC5B,sBAAsB;GACtB,yBAAyB;GACzB,sBAAsB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F,CAAC,CACH;IACD,WAAW,EAAE;IACb,cAAc,KAAK,OAAO;IAC3B;GACF"}
|
|
@@ -5,6 +5,10 @@ const require_ctx_column_sources = require("../../columns/ctx_column_sources.cjs
|
|
|
5
5
|
const require_enrichment_discovery = require("./enrichment_discovery.cjs");
|
|
6
6
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
7
7
|
//#region src/components/PlDatasetSelector/build_dataset_options.ts
|
|
8
|
+
function toPredicate(opt) {
|
|
9
|
+
if (opt === void 0) return () => true;
|
|
10
|
+
return typeof opt === "function" ? opt : (0, _milaboratories_pl_model_common.multiColumnSelectorsToPredicate)(opt);
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* Usage:
|
|
10
14
|
* ```ts
|
|
@@ -12,30 +16,35 @@ let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common")
|
|
|
12
16
|
* ```
|
|
13
17
|
*/
|
|
14
18
|
function buildDatasetOptions(ctx, opts) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
19
|
+
const primaryPredicate = toPredicate(opts?.primary);
|
|
20
|
+
const filterPredicate = toPredicate(opts?.filter);
|
|
17
21
|
const options = ctx.resultPool.getOptions(primaryPredicate, { refsWithEnrichments: true });
|
|
18
22
|
if (options.length === 0) return [];
|
|
19
|
-
const columnSources = require_ctx_column_sources.collectCtxColumnSnapshotProviders(ctx);
|
|
20
23
|
const refMap = require_filter_discovery.buildRefMap(ctx.resultPool.getSpecs().entries);
|
|
21
24
|
const pframeSpec = ctx.getService("pframeSpec");
|
|
25
|
+
const withEnrichments = opts?.withEnrichments ?? false;
|
|
26
|
+
const filterSource = new require_ctx_column_sources.ResultPoolColumnSnapshotProvider(ctx.resultPool);
|
|
27
|
+
const enrichmentSources = withEnrichments ? require_ctx_column_sources.collectCtxColumnSnapshotProviders(ctx) : void 0;
|
|
22
28
|
return options.map((primary) => {
|
|
23
29
|
const datasetSpec = ctx.resultPool.getPColumnSpecByRef(primary.ref);
|
|
24
30
|
if (!datasetSpec) return { primary };
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const collection = builder.build({ anchors: { main: datasetSpec } });
|
|
28
|
-
if (!collection) return { primary };
|
|
31
|
+
let filterCollection;
|
|
32
|
+
let enrichmentCollection;
|
|
29
33
|
try {
|
|
30
|
-
|
|
34
|
+
filterCollection = new require_column_collection_builder.ColumnCollectionBuilder(pframeSpec).addSource(filterSource).build({
|
|
35
|
+
anchors: { main: datasetSpec },
|
|
36
|
+
allowPartialColumnList: true
|
|
37
|
+
});
|
|
38
|
+
enrichmentCollection = enrichmentSources !== void 0 ? new require_column_collection_builder.ColumnCollectionBuilder(pframeSpec).addSources(enrichmentSources).build({ anchors: { main: datasetSpec } }) : void 0;
|
|
39
|
+
const filterMatches = require_filter_discovery.findFilterColumns(filterCollection).filter((m) => filterPredicate(m.column.spec));
|
|
31
40
|
const filters = filterMatches.length === 0 ? void 0 : require_filter_discovery.filterMatchesToOptions(filterMatches, refMap, opts?.labelOptions);
|
|
32
41
|
let enrichments;
|
|
33
|
-
if (
|
|
34
|
-
const enrichmentVariants = require_enrichment_discovery.findEnrichmentColumns(
|
|
35
|
-
maxHops: opts
|
|
36
|
-
...typeof
|
|
42
|
+
if (enrichmentCollection && withEnrichments) {
|
|
43
|
+
const enrichmentVariants = require_enrichment_discovery.findEnrichmentColumns(enrichmentCollection, {
|
|
44
|
+
maxHops: opts?.enrichmentMaxHops,
|
|
45
|
+
...typeof withEnrichments === "function" ? { predicate: withEnrichments } : { include: withEnrichments }
|
|
37
46
|
});
|
|
38
|
-
if (enrichmentVariants.length > 0) enrichments = require_enrichment_discovery.enrichmentVariantsToRefs(enrichmentVariants, opts
|
|
47
|
+
if (enrichmentVariants.length > 0) enrichments = require_enrichment_discovery.enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);
|
|
39
48
|
}
|
|
40
49
|
return {
|
|
41
50
|
primary,
|
|
@@ -43,7 +52,8 @@ function buildDatasetOptions(ctx, opts) {
|
|
|
43
52
|
...enrichments !== void 0 && enrichments.length > 0 ? { enrichments } : {}
|
|
44
53
|
};
|
|
45
54
|
} finally {
|
|
46
|
-
|
|
55
|
+
filterCollection?.dispose();
|
|
56
|
+
enrichmentCollection?.dispose();
|
|
47
57
|
}
|
|
48
58
|
});
|
|
49
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dataset_options.cjs","names":["
|
|
1
|
+
{"version":3,"file":"build_dataset_options.cjs","names":["buildRefMap","ResultPoolColumnSnapshotProvider","collectCtxColumnSnapshotProviders","ColumnCollectionBuilder","findFilterColumns","filterMatchesToOptions","findEnrichmentColumns","enrichmentVariantsToRefs"],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { AnchoredColumnCollection } from \"../../columns/column_collection_builder\";\nimport { ColumnCollectionBuilder } from \"../../columns/column_collection_builder\";\nimport {\n ResultPoolColumnSnapshotProvider,\n collectCtxColumnSnapshotProviders,\n} from \"../../columns/ctx_column_sources\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { buildRefMap, filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { enrichmentVariantsToRefs, findEnrichmentColumns } from \"./enrichment_discovery\";\n\ntype SpecPredicateOption =\n | MultiColumnSelector\n | MultiColumnSelector[]\n | ((spec: PObjectSpec) => boolean);\n\nfunction toPredicate(opt: SpecPredicateOption | undefined): (spec: PObjectSpec) => boolean {\n if (opt === undefined) return () => true;\n return typeof opt === \"function\" ? opt : multiColumnSelectorsToPredicate(opt);\n}\n\nexport type BuildDatasetOptions = {\n /** Which result pool columns qualify as datasets. Defaults to all. */\n primary?: SpecPredicateOption;\n /**\n * Restricts which result pool columns are considered as filters. Intersected\n * with the built-in `pl7.app/isSubset: \"true\"` constraint. Defaults to\n * accept-all.\n */\n filter?: SpecPredicateOption;\n /** Formatting options for filter labels. */\n labelOptions?: DeriveLabelsOptions;\n /**\n * Enables enrichment discovery and filters hits attached to\n * `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.\n */\n withEnrichments?: SpecPredicateOption;\n /** Maximum linker hops considered. Only used when `withEnrichments` is set. */\n enrichmentMaxHops?: number;\n};\n\n/**\n * Usage:\n * ```ts\n * .output(\"datasetOptions\", (ctx) => buildDatasetOptions(ctx))\n * ```\n */\nexport function buildDatasetOptions(\n ctx: RenderCtxBase,\n opts?: BuildDatasetOptions,\n): DatasetOption[] | undefined {\n const primaryPredicate = toPredicate(opts?.primary);\n const filterPredicate = toPredicate(opts?.filter);\n\n const options = ctx.resultPool.getOptions(primaryPredicate, { refsWithEnrichments: true });\n if (options.length === 0) return [];\n\n const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);\n const pframeSpec = ctx.getService(\"pframeSpec\");\n\n const withEnrichments = opts?.withEnrichments ?? false;\n const filterSource = new ResultPoolColumnSnapshotProvider(ctx.resultPool);\n // Hoisted out of the per-option loop: collectCtxColumnSnapshotProviders\n // walks the entire output tree, so calling it once per dataset option would\n // be O(N × tree).\n const enrichmentSources = withEnrichments ? collectCtxColumnSnapshotProviders(ctx) : undefined;\n\n return options.map((primary: Option): DatasetOption => {\n const datasetSpec = ctx.resultPool.getPColumnSpecByRef(primary.ref);\n if (!datasetSpec) return { primary };\n\n // Allocations happen inside try so a throw on the second build()\n // still disposes the first collection.\n let filterCollection: AnchoredColumnCollection | undefined;\n let enrichmentCollection: AnchoredColumnCollection | undefined;\n try {\n // ResultPoolColumnSnapshotProvider is always complete;\n // allowPartialColumnList narrows the return type to non-undefined.\n filterCollection = new ColumnCollectionBuilder(pframeSpec)\n .addSource(filterSource)\n .build({ anchors: { main: datasetSpec }, allowPartialColumnList: true });\n\n enrichmentCollection =\n enrichmentSources !== undefined\n ? new ColumnCollectionBuilder(pframeSpec)\n .addSources(enrichmentSources)\n .build({ anchors: { main: datasetSpec } })\n : undefined;\n\n const filterMatches = findFilterColumns(filterCollection).filter((m) =>\n filterPredicate(m.column.spec),\n );\n const filters =\n filterMatches.length === 0\n ? undefined\n : filterMatchesToOptions(filterMatches, refMap, opts?.labelOptions);\n\n let enrichments;\n if (enrichmentCollection && withEnrichments) {\n const enrichmentVariants = findEnrichmentColumns(enrichmentCollection, {\n maxHops: opts?.enrichmentMaxHops,\n ...(typeof withEnrichments === \"function\"\n ? { predicate: withEnrichments }\n : { include: withEnrichments }),\n });\n if (enrichmentVariants.length > 0) {\n enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);\n }\n }\n\n return {\n primary,\n ...(filters !== undefined && filters.length > 0 ? { filters } : {}),\n ...(enrichments !== undefined && enrichments.length > 0 ? { enrichments } : {}),\n };\n } finally {\n filterCollection?.dispose();\n enrichmentCollection?.dispose();\n }\n });\n}\n"],"mappings":";;;;;;;AAmBA,SAAS,YAAY,KAAsE;AACzF,KAAI,QAAQ,KAAA,EAAW,cAAa;AACpC,QAAO,OAAO,QAAQ,aAAa,OAAA,GAAA,gCAAA,iCAAsC,IAAI;;;;;;;;AA6B/E,SAAgB,oBACd,KACA,MAC6B;CAC7B,MAAM,mBAAmB,YAAY,MAAM,QAAQ;CACnD,MAAM,kBAAkB,YAAY,MAAM,OAAO;CAEjD,MAAM,UAAU,IAAI,WAAW,WAAW,kBAAkB,EAAE,qBAAqB,MAAM,CAAC;AAC1F,KAAI,QAAQ,WAAW,EAAG,QAAO,EAAE;CAEnC,MAAM,SAASA,yBAAAA,YAAY,IAAI,WAAW,UAAU,CAAC,QAAQ;CAC7D,MAAM,aAAa,IAAI,WAAW,aAAa;CAE/C,MAAM,kBAAkB,MAAM,mBAAmB;CACjD,MAAM,eAAe,IAAIC,2BAAAA,iCAAiC,IAAI,WAAW;CAIzE,MAAM,oBAAoB,kBAAk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
|
|
|
4
4
|
import { MultiColumnSelector, PObjectSpec } from "@milaboratories/pl-model-common";
|
|
5
5
|
|
|
6
6
|
//#region src/components/PlDatasetSelector/build_dataset_options.d.ts
|
|
7
|
+
type SpecPredicateOption = MultiColumnSelector | MultiColumnSelector[] | ((spec: PObjectSpec) => boolean);
|
|
7
8
|
type BuildDatasetOptions = {
|
|
8
|
-
/** Which result pool columns qualify as datasets. Defaults to all. */primary?:
|
|
9
|
+
/** Which result pool columns qualify as datasets. Defaults to all. */primary?: SpecPredicateOption;
|
|
10
|
+
/**
|
|
11
|
+
* Restricts which result pool columns are considered as filters. Intersected
|
|
12
|
+
* with the built-in `pl7.app/isSubset: "true"` constraint. Defaults to
|
|
13
|
+
* accept-all.
|
|
14
|
+
*/
|
|
15
|
+
filter?: SpecPredicateOption; /** Formatting options for filter labels. */
|
|
9
16
|
labelOptions?: DeriveLabelsOptions;
|
|
10
17
|
/**
|
|
11
18
|
* Enables enrichment discovery and filters hits attached to
|
|
12
19
|
* `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.
|
|
13
20
|
*/
|
|
14
|
-
withEnrichments?:
|
|
21
|
+
withEnrichments?: SpecPredicateOption; /** Maximum linker hops considered. Only used when `withEnrichments` is set. */
|
|
15
22
|
enrichmentMaxHops?: number;
|
|
16
23
|
};
|
|
17
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dataset_options.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"build_dataset_options.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"mappings":";;;;;;KAcK,mBAAA,GACD,mBAAA,GACA,mBAAA,OACE,IAAA,EAAM,WAAA;AAAA,KAOA,mBAAA;wEAEV,OAAA,GAAU,mBAAA;EAZY;;;;;EAkBtB,MAAA,GAAS,mBAAA,EAfY;EAiBrB,YAAA,GAAe,mBAAA;EAlBb;;;;EAuBF,eAAA,GAAkB,mBAAA,EAfR;EAiBV,iBAAA;AAAA;;;;;;;iBASc,mBAAA,CACd,GAAA,EAAK,aAAA,EACL,IAAA,GAAO,mBAAA,GACN,aAAA"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { buildRefMap, filterMatchesToOptions, findFilterColumns } from "./filter_discovery.js";
|
|
2
2
|
import { ColumnCollectionBuilder } from "../../columns/column_collection_builder.js";
|
|
3
|
-
import { collectCtxColumnSnapshotProviders } from "../../columns/ctx_column_sources.js";
|
|
3
|
+
import { ResultPoolColumnSnapshotProvider, collectCtxColumnSnapshotProviders } from "../../columns/ctx_column_sources.js";
|
|
4
4
|
import { enrichmentVariantsToRefs, findEnrichmentColumns } from "./enrichment_discovery.js";
|
|
5
5
|
import { multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common";
|
|
6
6
|
//#region src/components/PlDatasetSelector/build_dataset_options.ts
|
|
7
|
+
function toPredicate(opt) {
|
|
8
|
+
if (opt === void 0) return () => true;
|
|
9
|
+
return typeof opt === "function" ? opt : multiColumnSelectorsToPredicate(opt);
|
|
10
|
+
}
|
|
7
11
|
/**
|
|
8
12
|
* Usage:
|
|
9
13
|
* ```ts
|
|
@@ -11,30 +15,35 @@ import { multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common
|
|
|
11
15
|
* ```
|
|
12
16
|
*/
|
|
13
17
|
function buildDatasetOptions(ctx, opts) {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
18
|
+
const primaryPredicate = toPredicate(opts?.primary);
|
|
19
|
+
const filterPredicate = toPredicate(opts?.filter);
|
|
16
20
|
const options = ctx.resultPool.getOptions(primaryPredicate, { refsWithEnrichments: true });
|
|
17
21
|
if (options.length === 0) return [];
|
|
18
|
-
const columnSources = collectCtxColumnSnapshotProviders(ctx);
|
|
19
22
|
const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);
|
|
20
23
|
const pframeSpec = ctx.getService("pframeSpec");
|
|
24
|
+
const withEnrichments = opts?.withEnrichments ?? false;
|
|
25
|
+
const filterSource = new ResultPoolColumnSnapshotProvider(ctx.resultPool);
|
|
26
|
+
const enrichmentSources = withEnrichments ? collectCtxColumnSnapshotProviders(ctx) : void 0;
|
|
21
27
|
return options.map((primary) => {
|
|
22
28
|
const datasetSpec = ctx.resultPool.getPColumnSpecByRef(primary.ref);
|
|
23
29
|
if (!datasetSpec) return { primary };
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const collection = builder.build({ anchors: { main: datasetSpec } });
|
|
27
|
-
if (!collection) return { primary };
|
|
30
|
+
let filterCollection;
|
|
31
|
+
let enrichmentCollection;
|
|
28
32
|
try {
|
|
29
|
-
|
|
33
|
+
filterCollection = new ColumnCollectionBuilder(pframeSpec).addSource(filterSource).build({
|
|
34
|
+
anchors: { main: datasetSpec },
|
|
35
|
+
allowPartialColumnList: true
|
|
36
|
+
});
|
|
37
|
+
enrichmentCollection = enrichmentSources !== void 0 ? new ColumnCollectionBuilder(pframeSpec).addSources(enrichmentSources).build({ anchors: { main: datasetSpec } }) : void 0;
|
|
38
|
+
const filterMatches = findFilterColumns(filterCollection).filter((m) => filterPredicate(m.column.spec));
|
|
30
39
|
const filters = filterMatches.length === 0 ? void 0 : filterMatchesToOptions(filterMatches, refMap, opts?.labelOptions);
|
|
31
40
|
let enrichments;
|
|
32
|
-
if (
|
|
33
|
-
const enrichmentVariants = findEnrichmentColumns(
|
|
34
|
-
maxHops: opts
|
|
35
|
-
...typeof
|
|
41
|
+
if (enrichmentCollection && withEnrichments) {
|
|
42
|
+
const enrichmentVariants = findEnrichmentColumns(enrichmentCollection, {
|
|
43
|
+
maxHops: opts?.enrichmentMaxHops,
|
|
44
|
+
...typeof withEnrichments === "function" ? { predicate: withEnrichments } : { include: withEnrichments }
|
|
36
45
|
});
|
|
37
|
-
if (enrichmentVariants.length > 0) enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts
|
|
46
|
+
if (enrichmentVariants.length > 0) enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);
|
|
38
47
|
}
|
|
39
48
|
return {
|
|
40
49
|
primary,
|
|
@@ -42,7 +51,8 @@ function buildDatasetOptions(ctx, opts) {
|
|
|
42
51
|
...enrichments !== void 0 && enrichments.length > 0 ? { enrichments } : {}
|
|
43
52
|
};
|
|
44
53
|
} finally {
|
|
45
|
-
|
|
54
|
+
filterCollection?.dispose();
|
|
55
|
+
enrichmentCollection?.dispose();
|
|
46
56
|
}
|
|
47
57
|
});
|
|
48
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dataset_options.js","names":[],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport {
|
|
1
|
+
{"version":3,"file":"build_dataset_options.js","names":[],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { AnchoredColumnCollection } from \"../../columns/column_collection_builder\";\nimport { ColumnCollectionBuilder } from \"../../columns/column_collection_builder\";\nimport {\n ResultPoolColumnSnapshotProvider,\n collectCtxColumnSnapshotProviders,\n} from \"../../columns/ctx_column_sources\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { buildRefMap, filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { enrichmentVariantsToRefs, findEnrichmentColumns } from \"./enrichment_discovery\";\n\ntype SpecPredicateOption =\n | MultiColumnSelector\n | MultiColumnSelector[]\n | ((spec: PObjectSpec) => boolean);\n\nfunction toPredicate(opt: SpecPredicateOption | undefined): (spec: PObjectSpec) => boolean {\n if (opt === undefined) return () => true;\n return typeof opt === \"function\" ? opt : multiColumnSelectorsToPredicate(opt);\n}\n\nexport type BuildDatasetOptions = {\n /** Which result pool columns qualify as datasets. Defaults to all. */\n primary?: SpecPredicateOption;\n /**\n * Restricts which result pool columns are considered as filters. Intersected\n * with the built-in `pl7.app/isSubset: \"true\"` constraint. Defaults to\n * accept-all.\n */\n filter?: SpecPredicateOption;\n /** Formatting options for filter labels. */\n labelOptions?: DeriveLabelsOptions;\n /**\n * Enables enrichment discovery and filters hits attached to\n * `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.\n */\n withEnrichments?: SpecPredicateOption;\n /** Maximum linker hops considered. Only used when `withEnrichments` is set. */\n enrichmentMaxHops?: number;\n};\n\n/**\n * Usage:\n * ```ts\n * .output(\"datasetOptions\", (ctx) => buildDatasetOptions(ctx))\n * ```\n */\nexport function buildDatasetOptions(\n ctx: RenderCtxBase,\n opts?: BuildDatasetOptions,\n): DatasetOption[] | undefined {\n const primaryPredicate = toPredicate(opts?.primary);\n const filterPredicate = toPredicate(opts?.filter);\n\n const options = ctx.resultPool.getOptions(primaryPredicate, { refsWithEnrichments: true });\n if (options.length === 0) return [];\n\n const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);\n const pframeSpec = ctx.getService(\"pframeSpec\");\n\n const withEnrichments = opts?.withEnrichments ?? false;\n const filterSource = new ResultPoolColumnSnapshotProvider(ctx.resultPool);\n // Hoisted out of the per-option loop: collectCtxColumnSnapshotProviders\n // walks the entire output tree, so calling it once per dataset option would\n // be O(N × tree).\n const enrichmentSources = withEnrichments ? collectCtxColumnSnapshotProviders(ctx) : undefined;\n\n return options.map((primary: Option): DatasetOption => {\n const datasetSpec = ctx.resultPool.getPColumnSpecByRef(primary.ref);\n if (!datasetSpec) return { primary };\n\n // Allocations happen inside try so a throw on the second build()\n // still disposes the first collection.\n let filterCollection: AnchoredColumnCollection | undefined;\n let enrichmentCollection: AnchoredColumnCollection | undefined;\n try {\n // ResultPoolColumnSnapshotProvider is always complete;\n // allowPartialColumnList narrows the return type to non-undefined.\n filterCollection = new ColumnCollectionBuilder(pframeSpec)\n .addSource(filterSource)\n .build({ anchors: { main: datasetSpec }, allowPartialColumnList: true });\n\n enrichmentCollection =\n enrichmentSources !== undefined\n ? new ColumnCollectionBuilder(pframeSpec)\n .addSources(enrichmentSources)\n .build({ anchors: { main: datasetSpec } })\n : undefined;\n\n const filterMatches = findFilterColumns(filterCollection).filter((m) =>\n filterPredicate(m.column.spec),\n );\n const filters =\n filterMatches.length === 0\n ? undefined\n : filterMatchesToOptions(filterMatches, refMap, opts?.labelOptions);\n\n let enrichments;\n if (enrichmentCollection && withEnrichments) {\n const enrichmentVariants = findEnrichmentColumns(enrichmentCollection, {\n maxHops: opts?.enrichmentMaxHops,\n ...(typeof withEnrichments === \"function\"\n ? { predicate: withEnrichments }\n : { include: withEnrichments }),\n });\n if (enrichmentVariants.length > 0) {\n enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);\n }\n }\n\n return {\n primary,\n ...(filters !== undefined && filters.length > 0 ? { filters } : {}),\n ...(enrichments !== undefined && enrichments.length > 0 ? { enrichments } : {}),\n };\n } finally {\n filterCollection?.dispose();\n enrichmentCollection?.dispose();\n }\n });\n}\n"],"mappings":";;;;;;AAmBA,SAAS,YAAY,KAAsE;AACzF,KAAI,QAAQ,KAAA,EAAW,cAAa;AACpC,QAAO,OAAO,QAAQ,aAAa,MAAM,gCAAgC,IAAI;;;;;;;;AA6B/E,SAAgB,oBACd,KACA,MAC6B;CAC7B,MAAM,mBAAmB,YAAY,MAAM,QAAQ;CACnD,MAAM,kBAAkB,YAAY,MAAM,OAAO;CAEjD,MAAM,UAAU,IAAI,WAAW,WAAW,kBAAkB,EAAE,qBAAqB,MAAM,CAAC;AAC1F,KAAI,QAAQ,WAAW,EAAG,QAAO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AAI,EAAE,aAAa,GAAG,EAAE;IAC/E;YACO;AACR,qBAAkB,SAAS;AAC3B,yBAAsB,SAAS;;GAEjC"}
|
|
@@ -21,28 +21,32 @@ function findFilterColumns(collection) {
|
|
|
21
21
|
/**
|
|
22
22
|
* Derive labeled options from filter column matches, for use in DatasetOption.filters.
|
|
23
23
|
*
|
|
24
|
+
* Entries whose column id has no PlRef in `refsByObjectId` are silently
|
|
25
|
+
* skipped — they cannot be exposed as user-selectable options.
|
|
26
|
+
*
|
|
24
27
|
* @param matches - from findFilterColumns()
|
|
25
28
|
* @param refsByObjectId - from {@link buildRefMap}
|
|
26
29
|
* @param labelOptions - forwarded to deriveDistinctLabels()
|
|
27
30
|
*/
|
|
28
31
|
function filterMatchesToOptions(matches, refsByObjectId, labelOptions) {
|
|
29
32
|
if (matches.length === 0) return [];
|
|
30
|
-
const flattened = matches.flatMap((
|
|
31
|
-
match
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const flattened = matches.flatMap((match) => {
|
|
34
|
+
const ref = refsByObjectId.get(match.column.id);
|
|
35
|
+
if (ref === void 0) return [];
|
|
36
|
+
return match.variants.map((variant) => ({
|
|
37
|
+
match,
|
|
38
|
+
variant,
|
|
39
|
+
ref
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
34
42
|
const labels = require_derive_distinct_labels.deriveDistinctLabels(flattened.map(({ match, variant }) => ({
|
|
35
43
|
spec: match.column.spec,
|
|
36
44
|
linkerPath: variant.path.map((p) => ({ spec: p.linker.spec }))
|
|
37
45
|
})), labelOptions);
|
|
38
|
-
return flattened.map(({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
ref,
|
|
43
|
-
label: labels[i]
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
+
return flattened.map(({ ref }, i) => ({
|
|
47
|
+
ref,
|
|
48
|
+
label: labels[i]
|
|
49
|
+
}));
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Usage: `buildRefMap(ctx.resultPool.getSpecs().entries)`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_discovery.cjs","names":["Annotation","deriveDistinctLabels"],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"sourcesContent":["import { Annotation } from \"@milaboratories/pl-model-common\";\nimport type { Option, PlRef, PObjectId } from \"@milaboratories/pl-model-common\";\nimport canonicalize from \"canonicalize\";\nimport type {\n AnchoredColumnCollection,\n ColumnMatch,\n} from \"../../columns/column_collection_builder\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\n\n/**\n * Matches columns annotated `pl7.app/isSubset: \"true\"` whose axes ⊆ anchor axes.\n *\n * The axes-subset constraint is enforced by `mode: \"enrichment\"`, which sets\n * `allowFloatingHitAxes: false` — every axis of the matched column must be\n * present in the anchor's axes. See `matchingModeToConstraints()` in\n * `column_collection_builder.ts`.\n */\nexport function findFilterColumns(collection: AnchoredColumnCollection): ColumnMatch[] {\n return collection.findColumns({\n mode: \"enrichment\",\n include: {\n annotations: { [Annotation.IsSubset]: \"true\" },\n },\n });\n}\n\n/**\n * Derive labeled options from filter column matches, for use in DatasetOption.filters.\n *\n * @param matches - from findFilterColumns()\n * @param refsByObjectId - from {@link buildRefMap}\n * @param labelOptions - forwarded to deriveDistinctLabels()\n */\nexport function filterMatchesToOptions(\n matches: ColumnMatch[],\n refsByObjectId: ReadonlyMap<PObjectId, PlRef>,\n labelOptions?: DeriveLabelsOptions,\n): Option[] {\n if (matches.length === 0) return [];\n\n // Each ColumnMatch can be reached via multiple variants (different linker\n // paths / qualifications). We emit one Option per variant so the user can\n // pick a specific path — `deriveDistinctLabels` disambiguates labels by\n // path.\n const flattened = matches.flatMap((
|
|
1
|
+
{"version":3,"file":"filter_discovery.cjs","names":["Annotation","deriveDistinctLabels"],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"sourcesContent":["import { Annotation } from \"@milaboratories/pl-model-common\";\nimport type { Option, PlRef, PObjectId } from \"@milaboratories/pl-model-common\";\nimport canonicalize from \"canonicalize\";\nimport type {\n AnchoredColumnCollection,\n ColumnMatch,\n} from \"../../columns/column_collection_builder\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\n\n/**\n * Matches columns annotated `pl7.app/isSubset: \"true\"` whose axes ⊆ anchor axes.\n *\n * The axes-subset constraint is enforced by `mode: \"enrichment\"`, which sets\n * `allowFloatingHitAxes: false` — every axis of the matched column must be\n * present in the anchor's axes. See `matchingModeToConstraints()` in\n * `column_collection_builder.ts`.\n */\nexport function findFilterColumns(collection: AnchoredColumnCollection): ColumnMatch[] {\n return collection.findColumns({\n mode: \"enrichment\",\n include: {\n annotations: { [Annotation.IsSubset]: \"true\" },\n },\n });\n}\n\n/**\n * Derive labeled options from filter column matches, for use in DatasetOption.filters.\n *\n * Entries whose column id has no PlRef in `refsByObjectId` are silently\n * skipped — they cannot be exposed as user-selectable options.\n *\n * @param matches - from findFilterColumns()\n * @param refsByObjectId - from {@link buildRefMap}\n * @param labelOptions - forwarded to deriveDistinctLabels()\n */\nexport function filterMatchesToOptions(\n matches: ColumnMatch[],\n refsByObjectId: ReadonlyMap<PObjectId, PlRef>,\n labelOptions?: DeriveLabelsOptions,\n): Option[] {\n if (matches.length === 0) return [];\n\n // Each ColumnMatch can be reached via multiple variants (different linker\n // paths / qualifications). We emit one Option per variant so the user can\n // pick a specific path — `deriveDistinctLabels` disambiguates labels by\n // path. All variants of a match share a column id, so the ref lookup\n // happens once per match.\n const flattened = matches.flatMap((match) => {\n const ref = refsByObjectId.get(match.column.id);\n if (ref === undefined) return [];\n return match.variants.map((variant) => ({ match, variant, ref }));\n });\n\n const entries: Entry[] = flattened.map(({ match, variant }) => ({\n spec: match.column.spec,\n linkerPath: variant.path.map((p) => ({ spec: p.linker.spec })),\n }));\n\n const labels = deriveDistinctLabels(entries, labelOptions);\n\n return flattened.map(({ ref }, i) => ({ ref, label: labels[i] }));\n}\n\n/**\n * Usage: `buildRefMap(ctx.resultPool.getSpecs().entries)`\n */\nexport function buildRefMap(entries: readonly { readonly ref: PlRef }[]): Map<PObjectId, PlRef> {\n const map = new Map<PObjectId, PlRef>();\n for (const entry of entries) {\n map.set(canonicalize(entry.ref)! as PObjectId, entry.ref);\n }\n return map;\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,kBAAkB,YAAqD;AACrF,QAAO,WAAW,YAAY;EAC5B,MAAM;EACN,SAAS,EACP,aAAa,GAAGA,gCAAAA,WAAW,WAAW,QAAQ,EAC/C;EACF,CAAC;;;;;;;;;;;;AAaJ,SAAgB,uBACd,SACA,gBACA,cACU;AACV,KAAI,QAAQ,WAAW,EAAG,QAAO,EAAE;CAOnC,MAAM,YAAY,QAAQ,SAAS,UAAU;EAC3C,MAAM,MAAM,eAAe,IAAI,MAAM,OAAO,GAAG;AAC/C,MAAI,QAAQ,KAAA,EAAW,QAAO,EAAE;AAChC,SAAO,MAAM,SAAS,KAAK,aAAa;GAAE;GAAO;GAAS;GAAK,EAAE;GACjE;CAOF,MAAM,SAASC,+BAAAA,qBALU,UAAU,KAAK,EAAE,OAAO,eAAe;EAC9D,MAAM,MAAM,OAAO;EACnB,YAAY,QAAQ,KAAK,KAAK,OAAO,EAAE,MAAM,EAAE,OAAO,MAAM,EAAE;EAC/D,EAAE,EAE0C,aAAa;AAE1D,QAAO,UAAU,KAAK,EAAE,OAAO,OAAO;EAAE;EAAK,OAAO,OAAO;EAAI,EAAE;;;;;AAMnE,SAAgB,YAAY,SAAoE;CAC9F,MAAM,sBAAM,IAAI,KAAuB;AACvC,MAAK,MAAM,SAAS,QAClB,KAAI,KAAA,GAAA,aAAA,SAAiB,MAAM,IAAI,EAAgB,MAAM,IAAI;AAE3D,QAAO"}
|
|
@@ -15,6 +15,9 @@ declare function findFilterColumns(collection: AnchoredColumnCollection): Column
|
|
|
15
15
|
/**
|
|
16
16
|
* Derive labeled options from filter column matches, for use in DatasetOption.filters.
|
|
17
17
|
*
|
|
18
|
+
* Entries whose column id has no PlRef in `refsByObjectId` are silently
|
|
19
|
+
* skipped — they cannot be exposed as user-selectable options.
|
|
20
|
+
*
|
|
18
21
|
* @param matches - from findFilterColumns()
|
|
19
22
|
* @param refsByObjectId - from {@link buildRefMap}
|
|
20
23
|
* @param labelOptions - forwarded to deriveDistinctLabels()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_discovery.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"mappings":";;;;;;;AAqBA;;;;;;iBAAgB,iBAAA,CAAkB,UAAA,EAAY,wBAAA,GAA2B,WAAA;;;
|
|
1
|
+
{"version":3,"file":"filter_discovery.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"mappings":";;;;;;;AAqBA;;;;;;iBAAgB,iBAAA,CAAkB,UAAA,EAAY,wBAAA,GAA2B,WAAA;;;AAmBzE;;;;;;;;iBAAgB,sBAAA,CACd,OAAA,EAAS,WAAA,IACT,cAAA,EAAgB,WAAA,CAAY,SAAA,EAAW,KAAA,GACvC,YAAA,GAAe,mBAAA,GACd,MAAA;;;;iBA2Ba,WAAA,CAAY,OAAA;EAAA,SAA6B,GAAA,EAAK,KAAA;AAAA,MAAY,GAAA,CAAI,SAAA,EAAW,KAAA"}
|
|
@@ -19,28 +19,32 @@ function findFilterColumns(collection) {
|
|
|
19
19
|
/**
|
|
20
20
|
* Derive labeled options from filter column matches, for use in DatasetOption.filters.
|
|
21
21
|
*
|
|
22
|
+
* Entries whose column id has no PlRef in `refsByObjectId` are silently
|
|
23
|
+
* skipped — they cannot be exposed as user-selectable options.
|
|
24
|
+
*
|
|
22
25
|
* @param matches - from findFilterColumns()
|
|
23
26
|
* @param refsByObjectId - from {@link buildRefMap}
|
|
24
27
|
* @param labelOptions - forwarded to deriveDistinctLabels()
|
|
25
28
|
*/
|
|
26
29
|
function filterMatchesToOptions(matches, refsByObjectId, labelOptions) {
|
|
27
30
|
if (matches.length === 0) return [];
|
|
28
|
-
const flattened = matches.flatMap((
|
|
29
|
-
match
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const flattened = matches.flatMap((match) => {
|
|
32
|
+
const ref = refsByObjectId.get(match.column.id);
|
|
33
|
+
if (ref === void 0) return [];
|
|
34
|
+
return match.variants.map((variant) => ({
|
|
35
|
+
match,
|
|
36
|
+
variant,
|
|
37
|
+
ref
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
32
40
|
const labels = deriveDistinctLabels(flattened.map(({ match, variant }) => ({
|
|
33
41
|
spec: match.column.spec,
|
|
34
42
|
linkerPath: variant.path.map((p) => ({ spec: p.linker.spec }))
|
|
35
43
|
})), labelOptions);
|
|
36
|
-
return flattened.map(({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ref,
|
|
41
|
-
label: labels[i]
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
+
return flattened.map(({ ref }, i) => ({
|
|
45
|
+
ref,
|
|
46
|
+
label: labels[i]
|
|
47
|
+
}));
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
46
50
|
* Usage: `buildRefMap(ctx.resultPool.getSpecs().entries)`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_discovery.js","names":[],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"sourcesContent":["import { Annotation } from \"@milaboratories/pl-model-common\";\nimport type { Option, PlRef, PObjectId } from \"@milaboratories/pl-model-common\";\nimport canonicalize from \"canonicalize\";\nimport type {\n AnchoredColumnCollection,\n ColumnMatch,\n} from \"../../columns/column_collection_builder\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\n\n/**\n * Matches columns annotated `pl7.app/isSubset: \"true\"` whose axes ⊆ anchor axes.\n *\n * The axes-subset constraint is enforced by `mode: \"enrichment\"`, which sets\n * `allowFloatingHitAxes: false` — every axis of the matched column must be\n * present in the anchor's axes. See `matchingModeToConstraints()` in\n * `column_collection_builder.ts`.\n */\nexport function findFilterColumns(collection: AnchoredColumnCollection): ColumnMatch[] {\n return collection.findColumns({\n mode: \"enrichment\",\n include: {\n annotations: { [Annotation.IsSubset]: \"true\" },\n },\n });\n}\n\n/**\n * Derive labeled options from filter column matches, for use in DatasetOption.filters.\n *\n * @param matches - from findFilterColumns()\n * @param refsByObjectId - from {@link buildRefMap}\n * @param labelOptions - forwarded to deriveDistinctLabels()\n */\nexport function filterMatchesToOptions(\n matches: ColumnMatch[],\n refsByObjectId: ReadonlyMap<PObjectId, PlRef>,\n labelOptions?: DeriveLabelsOptions,\n): Option[] {\n if (matches.length === 0) return [];\n\n // Each ColumnMatch can be reached via multiple variants (different linker\n // paths / qualifications). We emit one Option per variant so the user can\n // pick a specific path — `deriveDistinctLabels` disambiguates labels by\n // path.\n const flattened = matches.flatMap((
|
|
1
|
+
{"version":3,"file":"filter_discovery.js","names":[],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"sourcesContent":["import { Annotation } from \"@milaboratories/pl-model-common\";\nimport type { Option, PlRef, PObjectId } from \"@milaboratories/pl-model-common\";\nimport canonicalize from \"canonicalize\";\nimport type {\n AnchoredColumnCollection,\n ColumnMatch,\n} from \"../../columns/column_collection_builder\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\n\n/**\n * Matches columns annotated `pl7.app/isSubset: \"true\"` whose axes ⊆ anchor axes.\n *\n * The axes-subset constraint is enforced by `mode: \"enrichment\"`, which sets\n * `allowFloatingHitAxes: false` — every axis of the matched column must be\n * present in the anchor's axes. See `matchingModeToConstraints()` in\n * `column_collection_builder.ts`.\n */\nexport function findFilterColumns(collection: AnchoredColumnCollection): ColumnMatch[] {\n return collection.findColumns({\n mode: \"enrichment\",\n include: {\n annotations: { [Annotation.IsSubset]: \"true\" },\n },\n });\n}\n\n/**\n * Derive labeled options from filter column matches, for use in DatasetOption.filters.\n *\n * Entries whose column id has no PlRef in `refsByObjectId` are silently\n * skipped — they cannot be exposed as user-selectable options.\n *\n * @param matches - from findFilterColumns()\n * @param refsByObjectId - from {@link buildRefMap}\n * @param labelOptions - forwarded to deriveDistinctLabels()\n */\nexport function filterMatchesToOptions(\n matches: ColumnMatch[],\n refsByObjectId: ReadonlyMap<PObjectId, PlRef>,\n labelOptions?: DeriveLabelsOptions,\n): Option[] {\n if (matches.length === 0) return [];\n\n // Each ColumnMatch can be reached via multiple variants (different linker\n // paths / qualifications). We emit one Option per variant so the user can\n // pick a specific path — `deriveDistinctLabels` disambiguates labels by\n // path. All variants of a match share a column id, so the ref lookup\n // happens once per match.\n const flattened = matches.flatMap((match) => {\n const ref = refsByObjectId.get(match.column.id);\n if (ref === undefined) return [];\n return match.variants.map((variant) => ({ match, variant, ref }));\n });\n\n const entries: Entry[] = flattened.map(({ match, variant }) => ({\n spec: match.column.spec,\n linkerPath: variant.path.map((p) => ({ spec: p.linker.spec })),\n }));\n\n const labels = deriveDistinctLabels(entries, labelOptions);\n\n return flattened.map(({ ref }, i) => ({ ref, label: labels[i] }));\n}\n\n/**\n * Usage: `buildRefMap(ctx.resultPool.getSpecs().entries)`\n */\nexport function buildRefMap(entries: readonly { readonly ref: PlRef }[]): Map<PObjectId, PlRef> {\n const map = new Map<PObjectId, PlRef>();\n for (const entry of entries) {\n map.set(canonicalize(entry.ref)! as PObjectId, entry.ref);\n }\n return map;\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAgB,kBAAkB,YAAqD;AACrF,QAAO,WAAW,YAAY;EAC5B,MAAM;EACN,SAAS,EACP,aAAa,GAAG,WAAW,WAAW,QAAQ,EAC/C;EACF,CAAC;;;;;;;;;;;;AAaJ,SAAgB,uBACd,SACA,gBACA,cACU;AACV,KAAI,QAAQ,WAAW,EAAG,QAAO,EAAE;CAOnC,MAAM,YAAY,QAAQ,SAAS,UAAU;EAC3C,MAAM,MAAM,eAAe,IAAI,MAAM,OAAO,GAAG;AAC/C,MAAI,QAAQ,KAAA,EAAW,QAAO,EAAE;AAChC,SAAO,MAAM,SAAS,KAAK,aAAa;GAAE;GAAO;GAAS;GAAK,EAAE;GACjE;CAOF,MAAM,SAAS,qBALU,UAAU,KAAK,EAAE,OAAO,eAAe;EAC9D,MAAM,MAAM,OAAO;EACnB,YAAY,QAAQ,KAAK,KAAK,OAAO,EAAE,MAAM,EAAE,OAAO,MAAM,EAAE;EAC/D,EAAE,EAE0C,aAAa;AAE1D,QAAO,UAAU,KAAK,EAAE,OAAO,OAAO;EAAE;EAAK,OAAO,OAAO;EAAI,EAAE;;;;;AAMnE,SAAgB,YAAY,SAAoE;CAC9F,MAAM,sBAAM,IAAI,KAAuB;AACvC,MAAK,MAAM,SAAS,QAClB,KAAI,IAAI,aAAa,MAAM,IAAI,EAAgB,MAAM,IAAI;AAE3D,QAAO"}
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.73.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -32,20 +32,20 @@
|
|
|
32
32
|
"zod": "~3.25.76",
|
|
33
33
|
"@milaboratories/helpers": "1.14.1",
|
|
34
34
|
"@milaboratories/pl-error-like": "1.12.10",
|
|
35
|
-
"@milaboratories/pl-model-
|
|
36
|
-
"@milaboratories/ptabler-expression-js": "1.2.
|
|
37
|
-
"@milaboratories/pl-model-
|
|
35
|
+
"@milaboratories/pl-model-common": "1.39.0",
|
|
36
|
+
"@milaboratories/ptabler-expression-js": "1.2.20",
|
|
37
|
+
"@milaboratories/pl-model-middle-layer": "1.18.10"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
41
41
|
"fast-json-patch": "^3.1.1",
|
|
42
42
|
"typescript": "~5.9.3",
|
|
43
43
|
"vitest": "^4.1.3",
|
|
44
|
-
"@milaboratories/ts-configs": "1.2.3",
|
|
45
|
-
"@milaboratories/ts-builder": "1.3.2",
|
|
46
|
-
"@milaboratories/pf-spec-driver": "1.3.8",
|
|
47
44
|
"@milaboratories/build-configs": "2.0.0",
|
|
48
|
-
"@milaboratories/pf-driver": "1.4.
|
|
45
|
+
"@milaboratories/pf-driver": "1.4.5",
|
|
46
|
+
"@milaboratories/ts-configs": "1.2.3",
|
|
47
|
+
"@milaboratories/pf-spec-driver": "1.3.9",
|
|
48
|
+
"@milaboratories/ts-builder": "1.3.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "ts-builder build --target node",
|
package/src/block_model.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
BlockCodeKnownFeatureFlags,
|
|
7
7
|
BlockConfigContainer,
|
|
8
8
|
} from "@milaboratories/pl-model-common";
|
|
9
|
+
import { REQUIRES_PFRAMES_VERSION } from "@milaboratories/pl-model-common";
|
|
9
10
|
import { getPlatformaInstance, isInUI, createAndRegisterRenderLambda } from "./internal";
|
|
10
11
|
import type { DataModel } from "./block_migrations";
|
|
11
12
|
import type { PlatformaV3 } from "./platforma";
|
|
@@ -138,6 +139,7 @@ export class BlockModelV3<
|
|
|
138
139
|
requiresUIAPIVersion: 3,
|
|
139
140
|
requiresModelAPIVersion: BLOCK_STORAGE_FACADE_VERSION,
|
|
140
141
|
requiresCreatePTable: 2,
|
|
142
|
+
requiresPFramesVersion: REQUIRES_PFRAMES_VERSION,
|
|
141
143
|
...BLOCK_SERVICE_FLAGS,
|
|
142
144
|
} satisfies BlockCodeKnownFeatureFlags;
|
|
143
145
|
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
BlockCodeKnownFeatureFlags,
|
|
7
7
|
BlockConfigContainer,
|
|
8
8
|
} from "@milaboratories/pl-model-common";
|
|
9
|
+
import { REQUIRES_PFRAMES_VERSION } from "@milaboratories/pl-model-common";
|
|
9
10
|
import type { Checked, ConfigResult, TypedConfig } from "./config";
|
|
10
11
|
import { getImmediate } from "./config";
|
|
11
12
|
import { getPlatformaInstance, isInUI, tryRegisterCallback } from "./internal";
|
|
@@ -72,6 +73,7 @@ export class BlockModel<
|
|
|
72
73
|
requiresUIAPIVersion: 1,
|
|
73
74
|
requiresModelAPIVersion: 1,
|
|
74
75
|
requiresCreatePTable: 2,
|
|
76
|
+
requiresPFramesVersion: REQUIRES_PFRAMES_VERSION,
|
|
75
77
|
};
|
|
76
78
|
}
|
|
77
79
|
|