@platforma-sdk/model 1.89.0 → 1.90.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/columns/columns_collection.cjs +18 -0
- package/dist/columns/columns_collection.cjs.map +1 -1
- package/dist/columns/columns_collection.d.ts +21 -1
- package/dist/columns/columns_collection.d.ts.map +1 -1
- package/dist/columns/columns_collection.js +18 -0
- package/dist/columns/columns_collection.js.map +1 -1
- package/dist/columns/index.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +7 -7
- package/src/columns/__test_helpers__/collection_driver.ts +3 -0
- package/src/columns/columns_collection.test.ts +47 -0
- package/src/columns/columns_collection.ts +33 -0
|
@@ -66,6 +66,24 @@ var ColumnsCollectionImpl = class ColumnsCollectionImpl {
|
|
|
66
66
|
filter(options) {
|
|
67
67
|
return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Finds the roots the given columns hang off: the columns that, used as
|
|
71
|
+
* `anchors` of {@link discover}, would reach them. One entry per root, leaf
|
|
72
|
+
* and linker path; entries whose columns are not yet resolvable are skipped.
|
|
73
|
+
*/
|
|
74
|
+
discoverRoots(options) {
|
|
75
|
+
return this.driver.discoverRoots(this.handle, options).flatMap((ids) => {
|
|
76
|
+
const root = require_index.ColumnRecipe(ids.root);
|
|
77
|
+
const leaf = require_index.ColumnRecipe(ids.leaf);
|
|
78
|
+
const path = ids.path.map((id) => require_index.ColumnRecipe(id)).filter((c) => !(0, es_toolkit.isNil)(c));
|
|
79
|
+
if ((0, es_toolkit.isNil)(root) || (0, es_toolkit.isNil)(leaf) || path.length !== ids.path.length) return [];
|
|
80
|
+
return [{
|
|
81
|
+
root,
|
|
82
|
+
leaf,
|
|
83
|
+
path
|
|
84
|
+
}];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
69
87
|
};
|
|
70
88
|
function toSerializedSources(source, ctx) {
|
|
71
89
|
if (source === "result_pool") return [{ kind: "result_pool" }];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns_collection.cjs","names":["getService","ColumnRecipe","isNil","TreeNodeAccessor","isColumnProvider","getCfgRenderCtx","MainAccessorName","StagingAccessorName"],"sources":["../../src/columns/columns_collection.ts"],"sourcesContent":["import type {\n CollectionHandle,\n ColumnUniversalId,\n ColumnsCollectionDriverModel,\n ColumnsDiscoverOptions,\n ColumnsFilterOptions,\n SerializedColumnsSource,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { MainAccessorName, StagingAccessorName } from \"../render/internal\";\nimport type { ColumnsSource } from \"./column_providers\";\nimport { isColumnProvider } from \"./column_providers\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getService } from \"../services/get_services\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { ColumnRecipe } from \"./column_recipes\";\nimport { isNil } from \"es-toolkit\";\n\nexport interface ColumnsCollectionDeps {\n /** Render ctx used both for service resolution and for default ctx sources. */\n readonly ctx?: GlobalCfgRenderCtx;\n /** Override the resolved `columnsCollection` service — primarily for tests. */\n readonly driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Shorthand literals accepted inside `ColumnsCollection`'s `sources`\n * array, expanded against the active render ctx:\n *\n * - `\"result_pool\"` – fan-out into the host's upstream-block result pool.\n * - `\"current_block\"` – main outputs + prerun (staging) accessors of the\n * current block, when present.\n */\nexport type ColumnsSourceShorthand = \"result_pool\" | \"current_block\";\n\n/**\n * Build a {@link ColumnsCollection} from sandbox-side source descriptors.\n * Resolves the `columnsCollection` driver (either from `deps.driver` or via\n * `getService(\"columnsCollection\")`) and asks the host to mint a fresh\n * handle covering the supplied sources. Pass `sources === undefined` to\n * fall back to the active render ctx (main outputs + prerun + result pool).\n *\n * `sources` accepts {@link ColumnsSourceShorthand} string literals\n * (`\"result_pool\"`, `\"current_block\"`) for the common ctx-derived sources.\n */\nexport function ColumnsCollection(\n sources?: (ColumnsCollection | ColumnsSource | ColumnsSourceShorthand)[],\n deps?: ColumnsCollectionDeps,\n): ColumnsCollection {\n const driver = deps?.driver ?? getService(\"columnsCollection\", { ctx: deps?.ctx });\n const serialized: SerializedColumnsSource[] = sources\n ? sources.flatMap((s) => toSerializedSources(s, deps?.ctx))\n : defaultCtxSources(deps?.ctx);\n return new ColumnsCollectionImpl(driver.create(serialized), driver);\n}\n\nexport function isColumnsCollection(value: unknown): value is ColumnsCollection {\n return value instanceof ColumnsCollectionImpl;\n}\n\n/**\n * Sandbox proxy over the host-side `ColumnsCollection` driver. The driver\n * owns all column-set state; this object only carries an opaque\n * {@link CollectionHandle} plus a reference to the driver service.\n *\n * Construct via {@link ColumnsCollection} — the bare constructor is a\n * trivial `(handle, driver)` pair so that `addSource` / `discover` / `filter`\n * can rebind a freshly-minted handle without going through source\n * serialisation again.\n *\n * Every method returning a `ColumnsCollection` mints a fresh handle on the\n * host — the host VM bridge pins it to the active render ctx, so the sandbox\n * never has to manage refcounts.\n */\nexport class ColumnsCollectionImpl {\n constructor(\n public readonly handle: CollectionHandle,\n private readonly driver: ColumnsCollectionDriverModel,\n ) {}\n\n isEmpty(): boolean {\n return this.driver.isEmpty(this.handle);\n }\n\n isFinal(): boolean {\n return this.driver.isFinal(this.handle);\n }\n\n getColumnIds(): ColumnUniversalId[] {\n return this.driver.getColumns(this.handle);\n }\n\n getColumns(): ColumnRecipe[] {\n return this.getColumnIds()\n .map((id) => ColumnRecipe(id))\n .filter((c): c is ColumnRecipe => !isNil(c));\n }\n\n addSource(source: ColumnsSource | ColumnsCollection): ColumnsCollection {\n return new ColumnsCollectionImpl(\n this.driver.addSource(this.handle, toSerializedSources(source)),\n this.driver,\n );\n }\n\n discover(options: ColumnsDiscoverOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.discover(this.handle, options), this.driver);\n }\n\n filter(options: ColumnsFilterOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);\n }\n}\n\n/** Public type alias — value of the same name is the factory function above. */\nexport type ColumnsCollection = ColumnsCollectionImpl;\n\nfunction toSerializedSources(\n source: ColumnsCollection | ColumnsSource | ColumnsSourceShorthand,\n ctx?: GlobalCfgRenderCtx,\n): SerializedColumnsSource[] {\n if (source === \"result_pool\") {\n return [{ kind: \"result_pool\" }];\n }\n if (source === \"current_block\") {\n return currentBlockSources(ctx);\n }\n if (source instanceof ColumnsCollectionImpl) {\n return [{ kind: \"collection\", handle: source.handle }];\n }\n if (source instanceof TreeNodeAccessor) {\n return [{ kind: \"accessor\", accessor: source.handle, path: source.resolvePath }];\n }\n if (isColumnArray(source)) {\n return [{ kind: \"ids\", ids: source.columns.map((c) => c.id), isFinal: source.isFinal }];\n }\n if (isColumnProvider(source)) {\n return [{ kind: \"ids\", ids: source.getColumns().map((c) => c.id), isFinal: source.isFinal() }];\n }\n throw new Error(\"ColumnsCollection: unrecognised ColumnsSource shape\");\n}\n\nfunction isColumnArray(source: unknown): source is {\n columns: ReadonlyArray<{ id: ColumnUniversalId; spec?: unknown; data?: unknown }>;\n isFinal: boolean;\n} {\n if (typeof source !== \"object\" || source === null) return false;\n const s = source as { columns?: unknown; isFinal?: unknown };\n return Array.isArray(s.columns) && typeof s.isFinal === \"boolean\";\n}\n\nfunction currentBlockSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n const renderCtx = ctx ?? getCfgRenderCtx();\n const sources: SerializedColumnsSource[] = [];\n\n const outputs = renderCtx.getAccessorHandleByName(MainAccessorName);\n if (outputs !== undefined) {\n sources.push({ kind: \"accessor\", accessor: outputs, path: [MainAccessorName] });\n }\n const prerun = renderCtx.getAccessorHandleByName(StagingAccessorName);\n if (prerun !== undefined) {\n sources.push({ kind: \"accessor\", accessor: prerun, path: [StagingAccessorName] });\n }\n\n return sources;\n}\n\nfunction defaultCtxSources(ctx?: GlobalCfgRenderCtx):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Q,MAAM,CAACA,mBAAAA,mBAAmB;CAAE,CAAC;CAGlF,OAAO;AACT;AAEA,SAAS,kBAAkB,KAAqD;CAC9E,OAAO,CAAC,GAAG,oBAAoB,GAAG,GAAG,EAAE,MAAM,cAAc,CAAC;AAC9D"}
|
|
1
|
+
{"version":3,"file":"columns_collection.cjs","names":["getService","ColumnRecipe","isNil","TreeNodeAccessor","isColumnProvider","getCfgRenderCtx","MainAccessorName","StagingAccessorName"],"sources":["../../src/columns/columns_collection.ts"],"sourcesContent":["import type {\n CollectionHandle,\n ColumnUniversalId,\n ColumnsCollectionDriverModel,\n ColumnsDiscoverOptions,\n ColumnsFilterOptions,\n DiscoverRootsOptions,\n SerializedColumnsSource,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { MainAccessorName, StagingAccessorName } from \"../render/internal\";\nimport type { ColumnsSource } from \"./column_providers\";\nimport { isColumnProvider } from \"./column_providers\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getService } from \"../services/get_services\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { ColumnRecipe } from \"./column_recipes\";\nimport { isNil } from \"es-toolkit\";\n\nexport interface ColumnsCollectionDeps {\n /** Render ctx used both for service resolution and for default ctx sources. */\n readonly ctx?: GlobalCfgRenderCtx;\n /** Override the resolved `columnsCollection` service — primarily for tests. */\n readonly driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Shorthand literals accepted inside `ColumnsCollection`'s `sources`\n * array, expanded against the active render ctx:\n *\n * - `\"result_pool\"` – fan-out into the host's upstream-block result pool.\n * - `\"current_block\"` – main outputs + prerun (staging) accessors of the\n * current block, when present.\n */\nexport type ColumnsSourceShorthand = \"result_pool\" | \"current_block\";\n\n/**\n * Build a {@link ColumnsCollection} from sandbox-side source descriptors.\n * Resolves the `columnsCollection` driver (either from `deps.driver` or via\n * `getService(\"columnsCollection\")`) and asks the host to mint a fresh\n * handle covering the supplied sources. Pass `sources === undefined` to\n * fall back to the active render ctx (main outputs + prerun + result pool).\n *\n * `sources` accepts {@link ColumnsSourceShorthand} string literals\n * (`\"result_pool\"`, `\"current_block\"`) for the common ctx-derived sources.\n */\nexport function ColumnsCollection(\n sources?: (ColumnsCollection | ColumnsSource | ColumnsSourceShorthand)[],\n deps?: ColumnsCollectionDeps,\n): ColumnsCollection {\n const driver = deps?.driver ?? getService(\"columnsCollection\", { ctx: deps?.ctx });\n const serialized: SerializedColumnsSource[] = sources\n ? sources.flatMap((s) => toSerializedSources(s, deps?.ctx))\n : defaultCtxSources(deps?.ctx);\n return new ColumnsCollectionImpl(driver.create(serialized), driver);\n}\n\nexport function isColumnsCollection(value: unknown): value is ColumnsCollection {\n return value instanceof ColumnsCollectionImpl;\n}\n\n/**\n * A root found by {@link ColumnsCollectionImpl.discoverRoots}: `leaf` is the\n * requested column exactly as `discover({ anchors: { r: root } })` would\n * return it — carrying the linker `path` and qualifications — so the table is\n * built from `root` as the anchor plus `leaf`.\n */\nexport interface DiscoveredRoot {\n /** The column the leaf hangs off. */\n readonly root: ColumnRecipe;\n /** The requested column, discovered from the root. */\n readonly leaf: ColumnRecipe;\n /** Linker columns from the root to the leaf; empty when they join directly. */\n readonly path: ColumnRecipe[];\n}\n\n/**\n * Sandbox proxy over the host-side `ColumnsCollection` driver. The driver\n * owns all column-set state; this object only carries an opaque\n * {@link CollectionHandle} plus a reference to the driver service.\n *\n * Construct via {@link ColumnsCollection} — the bare constructor is a\n * trivial `(handle, driver)` pair so that `addSource` / `discover` / `filter`\n * can rebind a freshly-minted handle without going through source\n * serialisation again.\n *\n * Every method returning a `ColumnsCollection` mints a fresh handle on the\n * host — the host VM bridge pins it to the active render ctx, so the sandbox\n * never has to manage refcounts.\n */\nexport class ColumnsCollectionImpl {\n constructor(\n public readonly handle: CollectionHandle,\n private readonly driver: ColumnsCollectionDriverModel,\n ) {}\n\n isEmpty(): boolean {\n return this.driver.isEmpty(this.handle);\n }\n\n isFinal(): boolean {\n return this.driver.isFinal(this.handle);\n }\n\n getColumnIds(): ColumnUniversalId[] {\n return this.driver.getColumns(this.handle);\n }\n\n getColumns(): ColumnRecipe[] {\n return this.getColumnIds()\n .map((id) => ColumnRecipe(id))\n .filter((c): c is ColumnRecipe => !isNil(c));\n }\n\n addSource(source: ColumnsSource | ColumnsCollection): ColumnsCollection {\n return new ColumnsCollectionImpl(\n this.driver.addSource(this.handle, toSerializedSources(source)),\n this.driver,\n );\n }\n\n discover(options: ColumnsDiscoverOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.discover(this.handle, options), this.driver);\n }\n\n filter(options: ColumnsFilterOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);\n }\n\n /**\n * Finds the roots the given columns hang off: the columns that, used as\n * `anchors` of {@link discover}, would reach them. One entry per root, leaf\n * and linker path; entries whose columns are not yet resolvable are skipped.\n */\n discoverRoots(options: DiscoverRootsOptions): DiscoveredRoot[] {\n return this.driver.discoverRoots(this.handle, options).flatMap((ids) => {\n const root = ColumnRecipe(ids.root);\n const leaf = ColumnRecipe(ids.leaf);\n const path = ids.path\n .map((id) => ColumnRecipe(id))\n .filter((c): c is ColumnRecipe => !isNil(c));\n if (isNil(root) || isNil(leaf) || path.length !== ids.path.length) return [];\n return [{ root, leaf, path }];\n });\n }\n}\n\n/** Public type alias — value of the same name is the factory function above. */\nexport type ColumnsCollection = ColumnsCollectionImpl;\n\nfunction toSerializedSources(\n source: ColumnsCollection | ColumnsSource | ColumnsSourceShorthand,\n ctx?: GlobalCfgRenderCtx,\n): SerializedColumnsSource[] {\n if (source === \"result_pool\") {\n return [{ kind: \"result_pool\" }];\n }\n if (source === \"current_block\") {\n return currentBlockSources(ctx);\n }\n if (source instanceof ColumnsCollectionImpl) {\n return [{ kind: \"collection\", handle: source.handle }];\n }\n if (source instanceof TreeNodeAccessor) {\n return [{ kind: \"accessor\", accessor: source.handle, path: source.resolvePath }];\n }\n if (isColumnArray(source)) {\n return [{ kind: \"ids\", ids: source.columns.map((c) => c.id), isFinal: source.isFinal }];\n }\n if (isColumnProvider(source)) {\n return [{ kind: \"ids\", ids: source.getColumns().map((c) => c.id), isFinal: source.isFinal() }];\n }\n throw new Error(\"ColumnsCollection: unrecognised ColumnsSource shape\");\n}\n\nfunction isColumnArray(source: unknown): source is {\n columns: ReadonlyArray<{ id: ColumnUniversalId; spec?: unknown; data?: unknown }>;\n isFinal: boolean;\n} {\n if (typeof source !== \"object\" || source === null) return false;\n const s = source as { columns?: unknown; isFinal?: unknown };\n return Array.isArray(s.columns) && typeof s.isFinal === \"boolean\";\n}\n\nfunction currentBlockSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n const renderCtx = ctx ?? getCfgRenderCtx();\n const sources: SerializedColumnsSource[] = [];\n\n const outputs = renderCtx.getAccessorHandleByName(MainAccessorName);\n if (outputs !== undefined) {\n sources.push({ kind: \"accessor\", accessor: outputs, path: [MainAccessorName] });\n }\n const prerun = renderCtx.getAccessorHandleByName(StagingAccessorName);\n if (prerun !== undefined) {\n sources.push({ kind: \"accessor\", accessor: prerun, path: [StagingAccessorName] });\n }\n\n return sources;\n}\n\nfunction defaultCtxSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n return [...currentBlockSources(ctx), { kind: \"result_pool\" }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8CA,SAAgB,kBACd,SACA,MACmB;CACnB,MAAM,SAAS,MAAM,UAAUA,qBAAAA,WAAW,qBAAqB,EAAE,KAAK,MAAM,IAAI,CAAC;CACjF,MAAM,aAAwC,UAC1C,QAAQ,SAAS,MAAM,oBAAoB,GAAG,MAAM,GAAG,CAAC,IACxD,kBAAkB,MAAM,GAAG;CAC/B,OAAO,IAAI,sBAAsB,OAAO,OAAO,UAAU,GAAG,MAAM;AACpE;AAEA,SAAgB,oBAAoB,OAA4C;CAC9E,OAAO,iBAAiB;AAC1B;;;;;;;;;;;;;;;AA+BA,IAAa,wBAAb,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,IAAI,WAAW,KAAA,GACb,QAAQ,KAAK;EAAE,MAAM;EAAY,UAAU;EAAQ,MAAM,CAACA,mBAAAA,mBAAmB;CAAE,CAAC;CAGlF,OAAO;AACT;AAEA,SAAS,kBAAkB,KAAqD;CAC9E,OAAO,CAAC,GAAG,oBAAoB,GAAG,GAAG,EAAE,MAAM,cAAc,CAAC;AAC9D"}
|
|
@@ -2,7 +2,7 @@ import { GlobalCfgRenderCtx } from "../render/internal.js";
|
|
|
2
2
|
import { ColumnRecipe } from "./column_recipes/index.js";
|
|
3
3
|
import { ColumnsSource } from "./column_providers/types.js";
|
|
4
4
|
import "./column_providers/index.js";
|
|
5
|
-
import { CollectionHandle, ColumnUniversalId, ColumnsCollectionDriverModel, ColumnsDiscoverOptions, ColumnsFilterOptions } from "@milaboratories/pl-model-common";
|
|
5
|
+
import { CollectionHandle, ColumnUniversalId, ColumnsCollectionDriverModel, ColumnsDiscoverOptions, ColumnsFilterOptions, DiscoverRootsOptions } from "@milaboratories/pl-model-common";
|
|
6
6
|
export interface ColumnsCollectionDeps {
|
|
7
7
|
/** Render ctx used both for service resolution and for default ctx sources. */
|
|
8
8
|
readonly ctx?: GlobalCfgRenderCtx;
|
|
@@ -30,6 +30,20 @@ export type ColumnsSourceShorthand = "result_pool" | "current_block";
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function ColumnsCollection(sources?: (ColumnsCollection | ColumnsSource | ColumnsSourceShorthand)[], deps?: ColumnsCollectionDeps): ColumnsCollection;
|
|
32
32
|
export declare function isColumnsCollection(value: unknown): value is ColumnsCollection;
|
|
33
|
+
/**
|
|
34
|
+
* A root found by {@link ColumnsCollectionImpl.discoverRoots}: `leaf` is the
|
|
35
|
+
* requested column exactly as `discover({ anchors: { r: root } })` would
|
|
36
|
+
* return it — carrying the linker `path` and qualifications — so the table is
|
|
37
|
+
* built from `root` as the anchor plus `leaf`.
|
|
38
|
+
*/
|
|
39
|
+
export interface DiscoveredRoot {
|
|
40
|
+
/** The column the leaf hangs off. */
|
|
41
|
+
readonly root: ColumnRecipe;
|
|
42
|
+
/** The requested column, discovered from the root. */
|
|
43
|
+
readonly leaf: ColumnRecipe;
|
|
44
|
+
/** Linker columns from the root to the leaf; empty when they join directly. */
|
|
45
|
+
readonly path: ColumnRecipe[];
|
|
46
|
+
}
|
|
33
47
|
/**
|
|
34
48
|
* Sandbox proxy over the host-side `ColumnsCollection` driver. The driver
|
|
35
49
|
* owns all column-set state; this object only carries an opaque
|
|
@@ -55,6 +69,12 @@ export declare class ColumnsCollectionImpl {
|
|
|
55
69
|
addSource(source: ColumnsSource | ColumnsCollection): ColumnsCollection;
|
|
56
70
|
discover(options: ColumnsDiscoverOptions): ColumnsCollection;
|
|
57
71
|
filter(options: ColumnsFilterOptions): ColumnsCollection;
|
|
72
|
+
/**
|
|
73
|
+
* Finds the roots the given columns hang off: the columns that, used as
|
|
74
|
+
* `anchors` of {@link discover}, would reach them. One entry per root, leaf
|
|
75
|
+
* and linker path; entries whose columns are not yet resolvable are skipped.
|
|
76
|
+
*/
|
|
77
|
+
discoverRoots(options: DiscoverRootsOptions): DiscoveredRoot[];
|
|
58
78
|
}
|
|
59
79
|
/** Public type alias — value of the same name is the factory function above. */
|
|
60
80
|
export type ColumnsCollection = ColumnsCollectionImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns_collection.d.ts","names":[],"sources":["../../src/columns/columns_collection.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"columns_collection.d.ts","names":[],"sources":["../../src/columns/columns_collection.ts"],"mappings":";;;;;iBAmBiB;;WAEN,MAAM;;WAEN,SAAS;;;;;;;;;;YAWR;;;;;;;;;;;wBAYI,kBACd,WAAW,oBAAoB,gBAAgB,2BAC/C,OAAO,wBACN;wBAQa,oBAAoB,iBAAiB,SAAS;;;;;;;iBAU7C;;WAEN,MAAM;;WAEN,MAAM;;WAEN,MAAM;;;;;;;;;;;;;;;;qBAiBJ;WAEO,QAAQ;mBACP;EAFnB,YACkB,QAAQ,kBACP,QAAQ;EAG3B;EAIA;EAIA,gBAAgB;EAIhB,cAAc;EAMd,UAAU,QAAQ,gBAAgB,oBAAoB;EAOtD,SAAS,SAAS,yBAAyB;EAI3C,OAAO,SAAS,uBAAuB;;;;;;EASvC,cAAc,SAAS,uBAAuB;;;YAcpC,oBAAoB"}
|
|
@@ -66,6 +66,24 @@ var ColumnsCollectionImpl = class ColumnsCollectionImpl {
|
|
|
66
66
|
filter(options) {
|
|
67
67
|
return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Finds the roots the given columns hang off: the columns that, used as
|
|
71
|
+
* `anchors` of {@link discover}, would reach them. One entry per root, leaf
|
|
72
|
+
* and linker path; entries whose columns are not yet resolvable are skipped.
|
|
73
|
+
*/
|
|
74
|
+
discoverRoots(options) {
|
|
75
|
+
return this.driver.discoverRoots(this.handle, options).flatMap((ids) => {
|
|
76
|
+
const root = ColumnRecipe(ids.root);
|
|
77
|
+
const leaf = ColumnRecipe(ids.leaf);
|
|
78
|
+
const path = ids.path.map((id) => ColumnRecipe(id)).filter((c) => !isNil(c));
|
|
79
|
+
if (isNil(root) || isNil(leaf) || path.length !== ids.path.length) return [];
|
|
80
|
+
return [{
|
|
81
|
+
root,
|
|
82
|
+
leaf,
|
|
83
|
+
path
|
|
84
|
+
}];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
69
87
|
};
|
|
70
88
|
function toSerializedSources(source, ctx) {
|
|
71
89
|
if (source === "result_pool") return [{ kind: "result_pool" }];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns_collection.js","names":[],"sources":["../../src/columns/columns_collection.ts"],"sourcesContent":["import type {\n CollectionHandle,\n ColumnUniversalId,\n ColumnsCollectionDriverModel,\n ColumnsDiscoverOptions,\n ColumnsFilterOptions,\n SerializedColumnsSource,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { MainAccessorName, StagingAccessorName } from \"../render/internal\";\nimport type { ColumnsSource } from \"./column_providers\";\nimport { isColumnProvider } from \"./column_providers\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getService } from \"../services/get_services\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { ColumnRecipe } from \"./column_recipes\";\nimport { isNil } from \"es-toolkit\";\n\nexport interface ColumnsCollectionDeps {\n /** Render ctx used both for service resolution and for default ctx sources. */\n readonly ctx?: GlobalCfgRenderCtx;\n /** Override the resolved `columnsCollection` service — primarily for tests. */\n readonly driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Shorthand literals accepted inside `ColumnsCollection`'s `sources`\n * array, expanded against the active render ctx:\n *\n * - `\"result_pool\"` – fan-out into the host's upstream-block result pool.\n * - `\"current_block\"` – main outputs + prerun (staging) accessors of the\n * current block, when present.\n */\nexport type ColumnsSourceShorthand = \"result_pool\" | \"current_block\";\n\n/**\n * Build a {@link ColumnsCollection} from sandbox-side source descriptors.\n * Resolves the `columnsCollection` driver (either from `deps.driver` or via\n * `getService(\"columnsCollection\")`) and asks the host to mint a fresh\n * handle covering the supplied sources. Pass `sources === undefined` to\n * fall back to the active render ctx (main outputs + prerun + result pool).\n *\n * `sources` accepts {@link ColumnsSourceShorthand} string literals\n * (`\"result_pool\"`, `\"current_block\"`) for the common ctx-derived sources.\n */\nexport function ColumnsCollection(\n sources?: (ColumnsCollection | ColumnsSource | ColumnsSourceShorthand)[],\n deps?: ColumnsCollectionDeps,\n): ColumnsCollection {\n const driver = deps?.driver ?? getService(\"columnsCollection\", { ctx: deps?.ctx });\n const serialized: SerializedColumnsSource[] = sources\n ? sources.flatMap((s) => toSerializedSources(s, deps?.ctx))\n : defaultCtxSources(deps?.ctx);\n return new ColumnsCollectionImpl(driver.create(serialized), driver);\n}\n\nexport function isColumnsCollection(value: unknown): value is ColumnsCollection {\n return value instanceof ColumnsCollectionImpl;\n}\n\n/**\n * Sandbox proxy over the host-side `ColumnsCollection` driver. The driver\n * owns all column-set state; this object only carries an opaque\n * {@link CollectionHandle} plus a reference to the driver service.\n *\n * Construct via {@link ColumnsCollection} — the bare constructor is a\n * trivial `(handle, driver)` pair so that `addSource` / `discover` / `filter`\n * can rebind a freshly-minted handle without going through source\n * serialisation again.\n *\n * Every method returning a `ColumnsCollection` mints a fresh handle on the\n * host — the host VM bridge pins it to the active render ctx, so the sandbox\n * never has to manage refcounts.\n */\nexport class ColumnsCollectionImpl {\n constructor(\n public readonly handle: CollectionHandle,\n private readonly driver: ColumnsCollectionDriverModel,\n ) {}\n\n isEmpty(): boolean {\n return this.driver.isEmpty(this.handle);\n }\n\n isFinal(): boolean {\n return this.driver.isFinal(this.handle);\n }\n\n getColumnIds(): ColumnUniversalId[] {\n return this.driver.getColumns(this.handle);\n }\n\n getColumns(): ColumnRecipe[] {\n return this.getColumnIds()\n .map((id) => ColumnRecipe(id))\n .filter((c): c is ColumnRecipe => !isNil(c));\n }\n\n addSource(source: ColumnsSource | ColumnsCollection): ColumnsCollection {\n return new ColumnsCollectionImpl(\n this.driver.addSource(this.handle, toSerializedSources(source)),\n this.driver,\n );\n }\n\n discover(options: ColumnsDiscoverOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.discover(this.handle, options), this.driver);\n }\n\n filter(options: ColumnsFilterOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);\n }\n}\n\n/** Public type alias — value of the same name is the factory function above. */\nexport type ColumnsCollection = ColumnsCollectionImpl;\n\nfunction toSerializedSources(\n source: ColumnsCollection | ColumnsSource | ColumnsSourceShorthand,\n ctx?: GlobalCfgRenderCtx,\n): SerializedColumnsSource[] {\n if (source === \"result_pool\") {\n return [{ kind: \"result_pool\" }];\n }\n if (source === \"current_block\") {\n return currentBlockSources(ctx);\n }\n if (source instanceof ColumnsCollectionImpl) {\n return [{ kind: \"collection\", handle: source.handle }];\n }\n if (source instanceof TreeNodeAccessor) {\n return [{ kind: \"accessor\", accessor: source.handle, path: source.resolvePath }];\n }\n if (isColumnArray(source)) {\n return [{ kind: \"ids\", ids: source.columns.map((c) => c.id), isFinal: source.isFinal }];\n }\n if (isColumnProvider(source)) {\n return [{ kind: \"ids\", ids: source.getColumns().map((c) => c.id), isFinal: source.isFinal() }];\n }\n throw new Error(\"ColumnsCollection: unrecognised ColumnsSource shape\");\n}\n\nfunction isColumnArray(source: unknown): source is {\n columns: ReadonlyArray<{ id: ColumnUniversalId; spec?: unknown; data?: unknown }>;\n isFinal: boolean;\n} {\n if (typeof source !== \"object\" || source === null) return false;\n const s = source as { columns?: unknown; isFinal?: unknown };\n return Array.isArray(s.columns) && typeof s.isFinal === \"boolean\";\n}\n\nfunction currentBlockSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n const renderCtx = ctx ?? getCfgRenderCtx();\n const sources: SerializedColumnsSource[] = [];\n\n const outputs = renderCtx.getAccessorHandleByName(MainAccessorName);\n if (outputs !== undefined) {\n sources.push({ kind: \"accessor\", accessor: outputs, path: [MainAccessorName] });\n }\n const prerun = renderCtx.getAccessorHandleByName(StagingAccessorName);\n if (prerun !== undefined) {\n sources.push({ kind: \"accessor\", accessor: prerun, path: [StagingAccessorName] });\n }\n\n return sources;\n}\n\nfunction defaultCtxSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n return [...currentBlockSources(ctx), { kind: \"result_pool\" }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6CA,SAAgB,kBACd,SACA,MACmB;CACnB,MAAM,SAAS,MAAM,UAAU,WAAW,qBAAqB,EAAE,KAAK,MAAM,IAAI,CAAC;CACjF,MAAM,aAAwC,UAC1C,QAAQ,SAAS,MAAM,oBAAoB,GAAG,MAAM,GAAG,CAAC,IACxD,kBAAkB,MAAM,GAAG;CAC/B,OAAO,IAAI,sBAAsB,OAAO,OAAO,UAAU,GAAG,MAAM;AACpE;AAEA,SAAgB,oBAAoB,OAA4C;CAC9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EAAE,EAAE;EAAG,SAAS,OAAO;CAAQ,CAAC;CAExF,IAAI,iBAAiB,MAAM,GACzB,OAAO,CAAC;EAAE,MAAM;EAAO,KAAK,OAAO,WAAW,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE;EAAG,SAAS,OAAO,QAAQ;CAAE,CAAC;CAE/F,MAAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,cAAc,QAGrB;CACA,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,OAAO;CAC1D,MAAM,IAAI;CACV,OAAO,MAAM,QAAQ,EAAE,OAAO,KAAK,OAAO,EAAE,YAAY;AAC1D;AAEA,SAAS,oBAAoB,KAAqD;CAChF,MAAM,YAAY,OAAO,gBAAgB;CACzC,MAAM,UAAqC,CAAC;CAE5C,MAAM,UAAU,UAAU,wBAAwB,gBAAgB;CAClE,IAAI,YAAY,KAAA,GACd,QAAQ,KAAK;EAAE,MAAM;EAAY,UAAU;EAAS,MAAM,CAAC,gBAAgB;CAAE,CAAC;CAEhF,MAAM,SAAS,UAAU,wBAAwB,mBAAmB;CACpE,IAAI,WAAW,KAAA,GACb,QAAQ,KAAK;EAAE,MAAM;EAAY,UAAU;EAAQ,MAAM,CAAC,mBAAmB;CAAE,CAAC;CAGlF,OAAO;AACT;AAEA,SAAS,kBAAkB,KAAqD;CAC9E,OAAO,CAAC,GAAG,oBAAoB,GAAG,GAAG,EAAE,MAAM,cAAc,CAAC;AAC9D"}
|
|
1
|
+
{"version":3,"file":"columns_collection.js","names":[],"sources":["../../src/columns/columns_collection.ts"],"sourcesContent":["import type {\n CollectionHandle,\n ColumnUniversalId,\n ColumnsCollectionDriverModel,\n ColumnsDiscoverOptions,\n ColumnsFilterOptions,\n DiscoverRootsOptions,\n SerializedColumnsSource,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { MainAccessorName, StagingAccessorName } from \"../render/internal\";\nimport type { ColumnsSource } from \"./column_providers\";\nimport { isColumnProvider } from \"./column_providers\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport { getService } from \"../services/get_services\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { ColumnRecipe } from \"./column_recipes\";\nimport { isNil } from \"es-toolkit\";\n\nexport interface ColumnsCollectionDeps {\n /** Render ctx used both for service resolution and for default ctx sources. */\n readonly ctx?: GlobalCfgRenderCtx;\n /** Override the resolved `columnsCollection` service — primarily for tests. */\n readonly driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Shorthand literals accepted inside `ColumnsCollection`'s `sources`\n * array, expanded against the active render ctx:\n *\n * - `\"result_pool\"` – fan-out into the host's upstream-block result pool.\n * - `\"current_block\"` – main outputs + prerun (staging) accessors of the\n * current block, when present.\n */\nexport type ColumnsSourceShorthand = \"result_pool\" | \"current_block\";\n\n/**\n * Build a {@link ColumnsCollection} from sandbox-side source descriptors.\n * Resolves the `columnsCollection` driver (either from `deps.driver` or via\n * `getService(\"columnsCollection\")`) and asks the host to mint a fresh\n * handle covering the supplied sources. Pass `sources === undefined` to\n * fall back to the active render ctx (main outputs + prerun + result pool).\n *\n * `sources` accepts {@link ColumnsSourceShorthand} string literals\n * (`\"result_pool\"`, `\"current_block\"`) for the common ctx-derived sources.\n */\nexport function ColumnsCollection(\n sources?: (ColumnsCollection | ColumnsSource | ColumnsSourceShorthand)[],\n deps?: ColumnsCollectionDeps,\n): ColumnsCollection {\n const driver = deps?.driver ?? getService(\"columnsCollection\", { ctx: deps?.ctx });\n const serialized: SerializedColumnsSource[] = sources\n ? sources.flatMap((s) => toSerializedSources(s, deps?.ctx))\n : defaultCtxSources(deps?.ctx);\n return new ColumnsCollectionImpl(driver.create(serialized), driver);\n}\n\nexport function isColumnsCollection(value: unknown): value is ColumnsCollection {\n return value instanceof ColumnsCollectionImpl;\n}\n\n/**\n * A root found by {@link ColumnsCollectionImpl.discoverRoots}: `leaf` is the\n * requested column exactly as `discover({ anchors: { r: root } })` would\n * return it — carrying the linker `path` and qualifications — so the table is\n * built from `root` as the anchor plus `leaf`.\n */\nexport interface DiscoveredRoot {\n /** The column the leaf hangs off. */\n readonly root: ColumnRecipe;\n /** The requested column, discovered from the root. */\n readonly leaf: ColumnRecipe;\n /** Linker columns from the root to the leaf; empty when they join directly. */\n readonly path: ColumnRecipe[];\n}\n\n/**\n * Sandbox proxy over the host-side `ColumnsCollection` driver. The driver\n * owns all column-set state; this object only carries an opaque\n * {@link CollectionHandle} plus a reference to the driver service.\n *\n * Construct via {@link ColumnsCollection} — the bare constructor is a\n * trivial `(handle, driver)` pair so that `addSource` / `discover` / `filter`\n * can rebind a freshly-minted handle without going through source\n * serialisation again.\n *\n * Every method returning a `ColumnsCollection` mints a fresh handle on the\n * host — the host VM bridge pins it to the active render ctx, so the sandbox\n * never has to manage refcounts.\n */\nexport class ColumnsCollectionImpl {\n constructor(\n public readonly handle: CollectionHandle,\n private readonly driver: ColumnsCollectionDriverModel,\n ) {}\n\n isEmpty(): boolean {\n return this.driver.isEmpty(this.handle);\n }\n\n isFinal(): boolean {\n return this.driver.isFinal(this.handle);\n }\n\n getColumnIds(): ColumnUniversalId[] {\n return this.driver.getColumns(this.handle);\n }\n\n getColumns(): ColumnRecipe[] {\n return this.getColumnIds()\n .map((id) => ColumnRecipe(id))\n .filter((c): c is ColumnRecipe => !isNil(c));\n }\n\n addSource(source: ColumnsSource | ColumnsCollection): ColumnsCollection {\n return new ColumnsCollectionImpl(\n this.driver.addSource(this.handle, toSerializedSources(source)),\n this.driver,\n );\n }\n\n discover(options: ColumnsDiscoverOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.discover(this.handle, options), this.driver);\n }\n\n filter(options: ColumnsFilterOptions): ColumnsCollection {\n return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);\n }\n\n /**\n * Finds the roots the given columns hang off: the columns that, used as\n * `anchors` of {@link discover}, would reach them. One entry per root, leaf\n * and linker path; entries whose columns are not yet resolvable are skipped.\n */\n discoverRoots(options: DiscoverRootsOptions): DiscoveredRoot[] {\n return this.driver.discoverRoots(this.handle, options).flatMap((ids) => {\n const root = ColumnRecipe(ids.root);\n const leaf = ColumnRecipe(ids.leaf);\n const path = ids.path\n .map((id) => ColumnRecipe(id))\n .filter((c): c is ColumnRecipe => !isNil(c));\n if (isNil(root) || isNil(leaf) || path.length !== ids.path.length) return [];\n return [{ root, leaf, path }];\n });\n }\n}\n\n/** Public type alias — value of the same name is the factory function above. */\nexport type ColumnsCollection = ColumnsCollectionImpl;\n\nfunction toSerializedSources(\n source: ColumnsCollection | ColumnsSource | ColumnsSourceShorthand,\n ctx?: GlobalCfgRenderCtx,\n): SerializedColumnsSource[] {\n if (source === \"result_pool\") {\n return [{ kind: \"result_pool\" }];\n }\n if (source === \"current_block\") {\n return currentBlockSources(ctx);\n }\n if (source instanceof ColumnsCollectionImpl) {\n return [{ kind: \"collection\", handle: source.handle }];\n }\n if (source instanceof TreeNodeAccessor) {\n return [{ kind: \"accessor\", accessor: source.handle, path: source.resolvePath }];\n }\n if (isColumnArray(source)) {\n return [{ kind: \"ids\", ids: source.columns.map((c) => c.id), isFinal: source.isFinal }];\n }\n if (isColumnProvider(source)) {\n return [{ kind: \"ids\", ids: source.getColumns().map((c) => c.id), isFinal: source.isFinal() }];\n }\n throw new Error(\"ColumnsCollection: unrecognised ColumnsSource shape\");\n}\n\nfunction isColumnArray(source: unknown): source is {\n columns: ReadonlyArray<{ id: ColumnUniversalId; spec?: unknown; data?: unknown }>;\n isFinal: boolean;\n} {\n if (typeof source !== \"object\" || source === null) return false;\n const s = source as { columns?: unknown; isFinal?: unknown };\n return Array.isArray(s.columns) && typeof s.isFinal === \"boolean\";\n}\n\nfunction currentBlockSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n const renderCtx = ctx ?? getCfgRenderCtx();\n const sources: SerializedColumnsSource[] = [];\n\n const outputs = renderCtx.getAccessorHandleByName(MainAccessorName);\n if (outputs !== undefined) {\n sources.push({ kind: \"accessor\", accessor: outputs, path: [MainAccessorName] });\n }\n const prerun = renderCtx.getAccessorHandleByName(StagingAccessorName);\n if (prerun !== undefined) {\n sources.push({ kind: \"accessor\", accessor: prerun, path: [StagingAccessorName] });\n }\n\n return sources;\n}\n\nfunction defaultCtxSources(ctx?: GlobalCfgRenderCtx): SerializedColumnsSource[] {\n return [...currentBlockSources(ctx), { kind: \"result_pool\" }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8CA,SAAgB,kBACd,SACA,MACmB;CACnB,MAAM,SAAS,MAAM,UAAU,WAAW,qBAAqB,EAAE,KAAK,MAAM,IAAI,CAAC;CACjF,MAAM,aAAwC,UAC1C,QAAQ,SAAS,MAAM,oBAAoB,GAAG,MAAM,GAAG,CAAC,IACxD,kBAAkB,MAAM,GAAG;CAC/B,OAAO,IAAI,sBAAsB,OAAO,OAAO,UAAU,GAAG,MAAM;AACpE;AAEA,SAAgB,oBAAoB,OAA4C;CAC9E,OAAO,iBAAiB;AAC1B;;;;;;;;;;;;;;;AA+BA,IAAa,wBAAb,MAAa,sBAAsB;CAEf;CACC;CAFnB,YACE,QACA,QACA;EAFgB,KAAA,SAAA;EACC,KAAA,SAAA;CAChB;CAEH,UAAmB;EACjB,OAAO,KAAK,OAAO,QAAQ,KAAK,MAAM;CACxC;CAEA,UAAmB;EACjB,OAAO,KAAK,OAAO,QAAQ,KAAK,MAAM;CACxC;CAEA,eAAoC;EAClC,OAAO,KAAK,OAAO,WAAW,KAAK,MAAM;CAC3C;CAEA,aAA6B;EAC3B,OAAO,KAAK,aAAa,CAAC,CACvB,KAAK,OAAO,aAAa,EAAE,CAAC,CAAC,CAC7B,QAAQ,MAAyB,CAAC,MAAM,CAAC,CAAC;CAC/C;CAEA,UAAU,QAA8D;EACtE,OAAO,IAAI,sBACT,KAAK,OAAO,UAAU,KAAK,QAAQ,oBAAoB,MAAM,CAAC,GAC9D,KAAK,MACP;CACF;CAEA,SAAS,SAAoD;EAC3D,OAAO,IAAI,sBAAsB,KAAK,O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AAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,cAAc,QAGrB;CACA,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,OAAO;CAC1D,MAAM,IAAI;CACV,OAAO,MAAM,QAAQ,EAAE,OAAO,KAAK,OAAO,EAAE,YAAY;AAC1D;AAEA,SAAS,oBAAoB,KAAqD;CAChF,MAAM,YAAY,OAAO,gBAAgB;CACzC,MAAM,UAAqC,CAAC;CAE5C,MAAM,UAAU,UAAU,wBAAwB,gBAAgB;CAClE,IAAI,YAAY,KAAA,GACd,QAAQ,KAAK;EAAE,MAAM;EAAY,UAAU;EAAS,MAAM,CAAC,gBAAgB;CAAE,CAAC;CAEhF,MAAM,SAAS,UAAU,wBAAwB,mBAAmB;CACpE,IAAI,WAAW,KAAA,GACb,QAAQ,KAAK;EAAE,MAAM;EAAY,UAAU;EAAQ,MAAM,CAAC,mBAAmB;CAAE,CAAC;CAGlF,OAAO;AACT;AAEA,SAAS,kBAAkB,KAAqD;CAC9E,OAAO,CAAC,GAAG,oBAAoB,GAAG,GAAG,EAAE,MAAM,cAAc,CAAC;AAC9D"}
|
package/dist/columns/index.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ import { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvi
|
|
|
9
9
|
import { ColumnsSource } from "./column_providers/types.js";
|
|
10
10
|
import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider } from "./column_providers/index.js";
|
|
11
11
|
import { SplitAxis, SplitByAxesOpts, splitByAxes } from "./split_by_axes.js";
|
|
12
|
-
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, isColumnsCollection } from "./columns_collection.js";
|
|
12
|
+
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, DiscoveredRoot, isColumnsCollection } from "./columns_collection.js";
|
|
13
13
|
import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
|
|
14
14
|
import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
|
|
15
15
|
import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./peer_links.js";
|
|
16
16
|
import { ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./column_values.js";
|
|
17
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createColumnValueOptions, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
|
17
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, DiscoveredRoot, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createColumnValueOptions, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ import { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvi
|
|
|
56
56
|
import { ColumnsSource } from "./columns/column_providers/types.js";
|
|
57
57
|
import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider } from "./columns/column_providers/index.js";
|
|
58
58
|
import { SplitAxis, SplitByAxesOpts, splitByAxes } from "./columns/split_by_axes.js";
|
|
59
|
-
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, isColumnsCollection } from "./columns/columns_collection.js";
|
|
59
|
+
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, DiscoveredRoot, isColumnsCollection } from "./columns/columns_collection.js";
|
|
60
60
|
import { deriveAxisValuesLabels } from "./columns/derive_axis_values_labels.js";
|
|
61
61
|
import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./columns/utils.js";
|
|
62
62
|
import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./columns/peer_links.js";
|
|
@@ -88,4 +88,4 @@ import "./services/index.js";
|
|
|
88
88
|
import { getEnvironmentValue } from "./env_value.js";
|
|
89
89
|
export * from "@milaboratories/pl-model-common";
|
|
90
90
|
export * from "@milaboratories/pl-error-like";
|
|
91
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, Entry, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildRefMap, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
|
91
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, DiscoveredRoot, Entry, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildRefMap, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
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.90.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@milaboratories/helpers": "1.14.7",
|
|
29
29
|
"@milaboratories/pl-error-like": "1.12.11",
|
|
30
|
-
"@milaboratories/pl-model-common": "1.
|
|
31
|
-
"@milaboratories/pl-model-middle-layer": "1.
|
|
32
|
-
"@milaboratories/ptabler-expression-js": "1.2.
|
|
30
|
+
"@milaboratories/pl-model-common": "1.56.0",
|
|
31
|
+
"@milaboratories/pl-model-middle-layer": "1.40.0",
|
|
32
|
+
"@milaboratories/ptabler-expression-js": "1.2.50",
|
|
33
33
|
"canonicalize": "~2.1.0",
|
|
34
34
|
"es-toolkit": "^1.39.10",
|
|
35
35
|
"fast-json-patch": "^3.1.1",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@milaboratories/build-configs": "2.0.3",
|
|
42
|
-
"@milaboratories/columns-collection-driver": "0.
|
|
43
|
-
"@milaboratories/pf-driver": "1.9.
|
|
44
|
-
"@milaboratories/pf-spec-driver": "1.
|
|
42
|
+
"@milaboratories/columns-collection-driver": "0.3.0",
|
|
43
|
+
"@milaboratories/pf-driver": "1.9.18",
|
|
44
|
+
"@milaboratories/pf-spec-driver": "1.6.0",
|
|
45
45
|
"@milaboratories/ts-builder": "1.8.0",
|
|
46
46
|
"@milaboratories/ts-configs": "1.4.1",
|
|
47
47
|
"@platforma-sdk/block-kind": "1.1.1",
|
|
@@ -56,12 +56,14 @@ const COLUMNS_COLLECTION_METHODS: ReadonlyArray<string> = [
|
|
|
56
56
|
"addSource",
|
|
57
57
|
"discover",
|
|
58
58
|
"filter",
|
|
59
|
+
"discoverRoots",
|
|
59
60
|
];
|
|
60
61
|
|
|
61
62
|
const PFRAME_SPEC_METHODS: ReadonlyArray<string> = [
|
|
62
63
|
"createSpecFrame",
|
|
63
64
|
"listColumns",
|
|
64
65
|
"discoverColumns",
|
|
66
|
+
"discoverRoots",
|
|
65
67
|
"deleteColumn",
|
|
66
68
|
"evaluateQuery",
|
|
67
69
|
"buildQuery",
|
|
@@ -93,6 +95,7 @@ export function createTestCollectionDriver(): TestCollectionDriverHandle {
|
|
|
93
95
|
addSource: (h, srcs) => impl.addSource(h, srcs, bindings).key,
|
|
94
96
|
discover: (h, o) => impl.discover(h, o, bindings).key,
|
|
95
97
|
filter: (h, o) => impl.filter(h, o, bindings).key,
|
|
98
|
+
discoverRoots: (h, o) => impl.discoverRoots(h, o, bindings),
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
let installedCtx: GlobalCfgRenderCtx | undefined;
|
|
@@ -201,3 +201,50 @@ describe("ColumnsCollection.filter", () => {
|
|
|
201
201
|
expect(ids).toEqual([c1.id, c2.id]);
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
|
+
|
|
205
|
+
describe("ColumnsCollection.discoverRoots", () => {
|
|
206
|
+
const cellAxis: AxisSpec = { name: "cell", type: "Int" };
|
|
207
|
+
const sampleAxis: AxisSpec = { name: "sample", type: "Long" };
|
|
208
|
+
const linkerSpec: PColumnSpec = {
|
|
209
|
+
...spec("cellToSample", [cellAxis, sampleAxis]),
|
|
210
|
+
annotations: { "pl7.app/isLinkerColumn": "true" },
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const cellData = { id: gid("cellData"), spec: spec("cellData", [cellAxis]) };
|
|
214
|
+
const linker = { id: gid("cellToSample"), spec: linkerSpec };
|
|
215
|
+
const sampleData = { id: gid("sampleData"), spec: spec("sampleData", [sampleAxis]) };
|
|
216
|
+
|
|
217
|
+
beforeEach(() => handle.installAmbientCtx());
|
|
218
|
+
afterEach(() => handle.uninstallAmbientCtx());
|
|
219
|
+
|
|
220
|
+
test("finds the column the given one hangs off, with the linker path", () => {
|
|
221
|
+
const found = makeCollection([cellData, linker, sampleData]).discoverRoots({
|
|
222
|
+
leaves: [cellData.id],
|
|
223
|
+
maxHops: 1,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
expect(found.map((r) => r.root.id)).toEqual([sampleData.id]);
|
|
227
|
+
expect(found[0]?.path.map((c) => c.id)).toEqual([linker.id]);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("the leaf is what discover anchored on the root returns", () => {
|
|
231
|
+
const collection = makeCollection([cellData, linker, sampleData]);
|
|
232
|
+
const [found] = collection.discoverRoots({ leaves: [cellData.id], maxHops: 1 });
|
|
233
|
+
|
|
234
|
+
const discovered = collection
|
|
235
|
+
.discover({ anchors: { r: sampleData.id }, maxHops: 1 })
|
|
236
|
+
.getColumnIds();
|
|
237
|
+
|
|
238
|
+
expect(found).toBeDefined();
|
|
239
|
+
expect(discovered).toContain(found?.leaf.id);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test("a column at the top of the hierarchy has no roots", () => {
|
|
243
|
+
const found = makeCollection([cellData, linker, sampleData]).discoverRoots({
|
|
244
|
+
leaves: [sampleData.id],
|
|
245
|
+
maxHops: 1,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
expect(found).toEqual([]);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ColumnsCollectionDriverModel,
|
|
5
5
|
ColumnsDiscoverOptions,
|
|
6
6
|
ColumnsFilterOptions,
|
|
7
|
+
DiscoverRootsOptions,
|
|
7
8
|
SerializedColumnsSource,
|
|
8
9
|
} from "@milaboratories/pl-model-common";
|
|
9
10
|
import type { GlobalCfgRenderCtx } from "../render/internal";
|
|
@@ -58,6 +59,21 @@ export function isColumnsCollection(value: unknown): value is ColumnsCollection
|
|
|
58
59
|
return value instanceof ColumnsCollectionImpl;
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* A root found by {@link ColumnsCollectionImpl.discoverRoots}: `leaf` is the
|
|
64
|
+
* requested column exactly as `discover({ anchors: { r: root } })` would
|
|
65
|
+
* return it — carrying the linker `path` and qualifications — so the table is
|
|
66
|
+
* built from `root` as the anchor plus `leaf`.
|
|
67
|
+
*/
|
|
68
|
+
export interface DiscoveredRoot {
|
|
69
|
+
/** The column the leaf hangs off. */
|
|
70
|
+
readonly root: ColumnRecipe;
|
|
71
|
+
/** The requested column, discovered from the root. */
|
|
72
|
+
readonly leaf: ColumnRecipe;
|
|
73
|
+
/** Linker columns from the root to the leaf; empty when they join directly. */
|
|
74
|
+
readonly path: ColumnRecipe[];
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* Sandbox proxy over the host-side `ColumnsCollection` driver. The driver
|
|
63
79
|
* owns all column-set state; this object only carries an opaque
|
|
@@ -110,6 +126,23 @@ export class ColumnsCollectionImpl {
|
|
|
110
126
|
filter(options: ColumnsFilterOptions): ColumnsCollection {
|
|
111
127
|
return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);
|
|
112
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Finds the roots the given columns hang off: the columns that, used as
|
|
132
|
+
* `anchors` of {@link discover}, would reach them. One entry per root, leaf
|
|
133
|
+
* and linker path; entries whose columns are not yet resolvable are skipped.
|
|
134
|
+
*/
|
|
135
|
+
discoverRoots(options: DiscoverRootsOptions): DiscoveredRoot[] {
|
|
136
|
+
return this.driver.discoverRoots(this.handle, options).flatMap((ids) => {
|
|
137
|
+
const root = ColumnRecipe(ids.root);
|
|
138
|
+
const leaf = ColumnRecipe(ids.leaf);
|
|
139
|
+
const path = ids.path
|
|
140
|
+
.map((id) => ColumnRecipe(id))
|
|
141
|
+
.filter((c): c is ColumnRecipe => !isNil(c));
|
|
142
|
+
if (isNil(root) || isNil(leaf) || path.length !== ids.path.length) return [];
|
|
143
|
+
return [{ root, leaf, path }];
|
|
144
|
+
});
|
|
145
|
+
}
|
|
113
146
|
}
|
|
114
147
|
|
|
115
148
|
/** Public type alias — value of the same name is the factory function above. */
|