import { InferFactoryData, InferFactoryParams, PluginFactoryLike, PluginHandle } from "../plugin_handle.js"; import { AccessorHandle, GlobalCfgRenderCtx, PColumnDataUniversal } from "./internal.js"; import { FutureRef } from "./future.js"; import { TreeNodeAccessor } from "./accessor.js"; import { DeriveLabelsOptions } from "../labels/derive_distinct_labels.js"; import "./util/label.js"; import { APColumnSelectorWithSplit } from "./util/split_selectors.js"; import { AxisLabelProvider, ColumnProvider } from "./util/column_collection.js"; import { AnchoredIdDeriver, AnchoredPColumnSelector, AnyFunction, AxisId, ColumnUniversalId, DataInfo, ModelServices, Option, PColumn, PColumnSelector, PColumnSpec, PColumnValues, PFrameDef, PFrameHandle, PObject, PObjectId, PObjectSpec, PTableDef, PTableDefV2, PTableHandle, PTableRecordFilter, PTableSorting, PlRef, ResolveAnchorsOptions, ResultCollection, SUniversalPColumnId, ValueOrError } from "@milaboratories/pl-model-common"; import { Optional } from "utility-types"; export type UniversalColumnOption = { label: string; value: SUniversalPColumnId; }; /** * Transforms PColumn data into the internal representation expected by the platform * @param column Data from a PColumn to transform * @returns Transformed data compatible with platform API */ export declare function finalizePColumnData(column: PColumn>): PColumn>; type UniversalPColumnOpts = { labelOps?: DeriveLabelsOptions; dontWaitAllData?: boolean; exclude?: AnchoredPColumnSelector | AnchoredPColumnSelector[]; } & ResolveAnchorsOptions; type GetOptionsOpts = { /** * If true, references returned by the method will contain `requireEnrichments` flag set to true. * If this reference is added to the block's args, it will communicate to the platform that the block * expects enrichments of the referenced block to be available in the context of the current block. */ refsWithEnrichments?: boolean; /** * Label derivation options. * If provided, it will be used to derive labels for the options. * If not provided, labels will be derived using the default logic. */ label?: ((spec: PObjectSpec, ref: PlRef) => string) | DeriveLabelsOptions; }; /** * @deprecated use the direct `ctx.*` methods on `RenderCtxBase` instead. * * Migration map: * - `getSpecs` → `ctx.getSpecs` * - `getSpecByRef` / `getPColumnSpecByRef` → `ctx.getSpecByRef` / `ctx.getPColumnSpecByRef` * - `getDataByRef` / `getPColumnByRef` → `ctx.getDataByRef` / `ctx.getPColumnByRef` * - `getOptions` → `ctx.getOptions` * * Eager methods `selectColumns` / `getData` / `getDataWithErrors` should be * replaced by `ctx.getSpecs` + on-demand `ctx.getStatusByRef` / * `ctx.getPColumnByRef` so that the data resource is not subscribed up-front. */ export declare class ResultPool implements ColumnProvider, AxisLabelProvider { private readonly ctx; getOptions(predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[], opts?: GetOptionsOpts): Option[]; /** @deprecated wrap label ops with { label: <...> } */ getOptions(predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[], label?: ((spec: PObjectSpec, ref: PlRef) => string) | DeriveLabelsOptions): Option[]; resolveAnchorCtx(anchorsOrCtx: AnchoredIdDeriver | Record): AnchoredIdDeriver | undefined; /** * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation. * * @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions) * @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions) * @param opts - Optional configuration for label generation and data waiting * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing */ getAnchoredPColumns(anchorsOrCtx: AnchoredIdDeriver | Record, predicateOrSelectors: ((spec: PColumnSpec) => boolean) | APColumnSelectorWithSplit | APColumnSelectorWithSplit[], opts?: UniversalPColumnOpts): undefined | PColumn[]; /** * Calculates anchored identifier options for columns matching a given predicate and returns their * canonicalized representations. * * This function filters column specifications from the result pool that match the provided predicate, * creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value * pairs for UI components (like dropdowns). * * @param anchorsOrCtx - Either: * - An existing AnchorCtx instance * - A record mapping anchor IDs to PColumnSpec objects * - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec) * @param predicateOrSelectors - Either: * - A predicate function that takes a PColumnSpec and returns a boolean. * Only specs that return true will be included. * - An APColumnSelector object for declarative filtering, which will be * resolved against the provided anchors and matched using matchPColumn. * - An array of APColumnSelector objects - columns matching ANY selector * in the array will be included (OR operation). * @param opts - Optional configuration for label generation: * - labelOps: Optional configuration for label generation: * - includeNativeLabel: Whether to include native column labels * - separator: String to use between label parts (defaults to " / ") * - addLabelAsSuffix: Whether to add labels as suffix instead of prefix * - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined, * if at least one column that requires splitting is missing data) * @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties, * or undefined if any PlRef resolution fails. */ getCanonicalOptions(anchorsOrCtx: AnchoredIdDeriver | Record, predicateOrSelectors: ((spec: PColumnSpec) => boolean) | APColumnSelectorWithSplit | APColumnSelectorWithSplit[], opts?: UniversalPColumnOpts): { label: string; value: SUniversalPColumnId; }[] | undefined; /** * @deprecated use getData() */ getDataFromResultPool(): ResultCollection>; getData(): ResultCollection>; /** * @deprecated use getDataWithErrors() */ getDataWithErrorsFromResultPool(): ResultCollection>, "id">>; getDataWithErrors(): ResultCollection>, "id">>; /** * @deprecated use getSpecs() */ getSpecsFromResultPool(): ResultCollection; getSpecs(): ResultCollection; /** * @param ref a Ref * @returns data associated with the ref */ getDataByRef(ref: PlRef): PObject | undefined; /** * Returns data associated with the ref ensuring that it is a p-column. * @param ref a Ref * @returns p-column associated with the ref */ getPColumnByRef(ref: PlRef): PColumn | undefined; /** * Returns spec associated with the ref ensuring that it is a p-column spec. * @param ref a Ref * @returns p-column spec associated with the ref */ getPColumnSpecByRef(ref: PlRef): PColumnSpec | undefined; /** * @param ref a Ref * @returns object spec associated with the ref */ getSpecByRef(ref: PlRef): PObjectSpec | undefined; /** * @param spec object specification * @returns array of data objects with compatible specs * @deprecated delete this method after Jan 1, 2025 */ findDataWithCompatibleSpec(spec: PColumnSpec): PObject[]; /** * Find labels data for a given axis id. It will search for a label column and return its data as a map. * @returns a map of axis value => label */ findLabels(axis: AxisId): Record | undefined; /** * Selects columns based on the provided selectors, returning PColumn objects * with lazily loaded data. * * @param selectors - A predicate function, a single selector, or an array of selectors. * @returns An array of PColumn objects matching the selectors. Data is loaded on first access. * @deprecated use `RenderCtxBase.rawResultPool` + `ResultPoolColumnsProvider` + * `discoverColumns` instead. This eager path materializes column data * unnecessarily for callers that only filter by spec. */ selectColumns(selectors: ((spec: PColumnSpec) => boolean) | PColumnSelector | PColumnSelector[]): PColumn[]; /** * Find labels data for a given axis id of a p-column. * @returns a map of axis value => label */ findLabelsForColumnAxis(column: PColumnSpec, axisIdx: number): Record | undefined; } /** Main entry point to the API available within model lambdas (like outputs, sections, etc..) */ export declare abstract class RenderCtxBase { readonly ctx: GlobalCfgRenderCtx; constructor(); private dataCache?; get data(): Data; private activeArgsCache?; /** * Returns args snapshot the block was executed for (i.e. when "Run" button was pressed). * Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared. * */ get activeArgs(): Args | undefined; getService(name: T): ModelServices[T]; private getNamedAccessor; get prerun(): TreeNodeAccessor | undefined; get outputs(): TreeNodeAccessor | undefined; /** @deprecated use `rawResultPool` + `ResultPoolColumnsProvider` instead. */ readonly resultPool: ResultPool; private patchPTableDef; createPFrame(def: PFrameDef>): PFrameHandle | undefined; createPTable(def: PTableDef>): PTableHandle | undefined; createPTable(def: { columns: PColumn[]; filters?: PTableRecordFilter[]; /** Table sorting */ sorting?: PTableSorting[]; }): PTableHandle | undefined; createPTableV2(def: PTableDefV2>): PTableHandle | undefined; getCurrentUnstableMarker(): string | undefined; logInfo(msg: string): void; logWarn(msg: string): void; logError(msg: string): void; } /** Main entry point to the API available within model lambdas (like outputs, sections, etc..) for v3+ blocks */ export declare class BlockRenderCtx extends RenderCtxBase { private argsCache?; get args(): Args | undefined; } /** * Render context for plugin output functions. * Reads plugin data from blockStorage and derives params from pre-wrapped input callbacks. * * Parameterized on the factory-like phantom F so that getPluginData returns * InferFactoryData directly — no casts needed for the data getter. * * @typeParam F - PluginFactoryLike phantom carrying data/params/outputs types */ export declare class PluginRenderCtx extends RenderCtxBase> { private readonly handle; private readonly wrappedInputs; constructor(handle: PluginHandle, wrappedInputs: Record unknown>); private pluginDataCache?; /** Plugin's persistent data from blockStorage.__plugins.{pluginId}.__data */ get data(): InferFactoryData; private paramsCache?; /** Params derived from block context via pre-wrapped input callbacks */ get params(): InferFactoryParams; } /** @deprecated Use BlockRenderCtx instead */ export type RenderCtx = BlockRenderCtx; export type RenderFunction = (rCtx: BlockRenderCtx) => Ret; export type UnwrapFutureRef = K extends FutureRef ? T : K extends bigint | boolean | null | number | string | symbol | undefined ? K : { [key in keyof K]: UnwrapFutureRef; }; export type InferRenderFunctionReturn = RF extends ((...args: any) => infer R) ? UnwrapFutureRef : never; export {}; //# sourceMappingURL=api.d.ts.map