@platforma-sdk/model 1.86.5 → 1.87.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/column_providers/providers.cjs +2 -10
- package/dist/columns/column_providers/providers.cjs.map +1 -1
- package/dist/columns/column_providers/providers.d.ts.map +1 -1
- package/dist/columns/column_providers/providers.js +3 -11
- package/dist/columns/column_providers/providers.js.map +1 -1
- package/dist/columns/column_recipes/index.cjs +2 -2
- package/dist/columns/column_recipes/index.cjs.map +1 -1
- package/dist/columns/column_recipes/index.d.ts +2 -3
- package/dist/columns/column_recipes/index.d.ts.map +1 -1
- package/dist/columns/column_recipes/index.js +2 -2
- package/dist/columns/column_recipes/index.js.map +1 -1
- package/dist/columns/data_column.cjs +12 -42
- package/dist/columns/data_column.cjs.map +1 -1
- package/dist/columns/data_column.d.ts +10 -26
- package/dist/columns/data_column.d.ts.map +1 -1
- package/dist/columns/data_column.js +13 -42
- package/dist/columns/data_column.js.map +1 -1
- package/dist/columns/index.cjs +0 -1
- package/dist/columns/index.d.ts +2 -2
- package/dist/columns/index.js +2 -2
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/src/columns/column_providers/providers.ts +3 -15
- package/src/columns/column_recipes/column_recipes.test.ts +11 -15
- package/src/columns/column_recipes/index.ts +2 -3
- package/src/columns/data_column.test.ts +13 -14
- package/src/columns/data_column.ts +12 -41
|
@@ -84,7 +84,7 @@ var AccessorColumnsProviderImpl = class extends _milaboratories_pl_model_common.
|
|
|
84
84
|
}
|
|
85
85
|
getColumns() {
|
|
86
86
|
if (this.cachedColumns !== void 0) return this.cachedColumns;
|
|
87
|
-
return this.cachedColumns = Array.from(this.entries.values(),
|
|
87
|
+
return this.cachedColumns = Array.from(this.entries.values(), require_data_column.DataColumn.fromAccessor).filter((column) => column !== void 0);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
@@ -106,17 +106,9 @@ var ResultPoolColumnsProviderImpl = class extends _milaboratories_pl_model_commo
|
|
|
106
106
|
}
|
|
107
107
|
getColumns() {
|
|
108
108
|
if (this.cachedColumns !== void 0) return this.cachedColumns;
|
|
109
|
-
return this.cachedColumns = Array.from(this.getPObjectEntries().values(),
|
|
109
|
+
return this.cachedColumns = Array.from(this.getPObjectEntries().values(), require_data_column.DataColumn.fromAccessor).filter((column) => column !== void 0);
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
function columnUnlessAbsent(entry) {
|
|
113
|
-
try {
|
|
114
|
-
return require_data_column.DataColumn.fromAccessor(entry);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
if (error instanceof require_data_column.ColumnAbsentError) return void 0;
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
112
|
function hashRawPool(rawPool) {
|
|
121
113
|
return rawPool.map((b) => `${b.blockId}\x1f${b.prodCtx ?? ""}\x1f${b.stagingCtx ?? ""}\x1f${b.prodIncomplete ? 1 : 0}\x1f${b.stagingIncomplete ? 1 : 0}`).join("");
|
|
122
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.cjs","names":["isNil","TreeNodeAccessor","LRUCache","getCfgRenderCtx","DataColumn","AccessorEntriesProvider","ResultPoolEntriesProvider"
|
|
1
|
+
{"version":3,"file":"providers.cjs","names":["isNil","TreeNodeAccessor","LRUCache","getCfgRenderCtx","DataColumn","AccessorEntriesProvider","ResultPoolEntriesProvider"],"sources":["../../../src/columns/column_providers/providers.ts"],"sourcesContent":["import {\n AccessorEntriesProvider,\n ResultPoolEntriesProvider,\n type PColumn,\n type PObjectId,\n type UpstreamBlockCtx,\n} from \"@milaboratories/pl-model-common\";\nimport { AccessorHandle, PColumnDataUniversal, TreeNodeAccessor } from \"../../render\";\nimport { DataColumn, DataColumnRecipe } from \"../data_column\";\nimport { getCfgRenderCtx } from \"../../internal\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\n\n/**\n * Data source for sandbox column-list builders. Has nothing to say about\n * id-resolution — `ColumnRegistry` (in `@milaboratories/pl-model-common`)\n * consumes the separate `ColumnEntriesProvider` interface for that.\n *\n * Same name as the factory function below — they merge into one TS\n * declaration: `ColumnsProvider` is callable AND the interface type.\n */\nexport interface ColumnsProvider {\n /** Returns all currently known PColumn columns as lazy views. */\n getColumns(): DataColumnRecipe<PObjectId>[];\n /** Whether the provider has finished enumerating all its columns. */\n isFinal(): boolean;\n}\n\n/**\n * Unified memoised factory dispatching to the right provider flavour by the\n * source shape:\n * - `TreeNodeAccessor` → {@link AccessorColumnsProvider}\n * (indexed by `root.handle`, walks the accessor tree once per root).\n * - `UpstreamBlockCtx<AccessorHandle>[]` (or omitted — pulled from the\n * ambient ctx) → {@link ResultPoolColumnsProvider}\n * (indexed by a content-hash of the block list).\n *\n * Both branches return cached instances within their LRU window, so repeated\n * calls with the same source skip re-walking / re-hashing.\n */\nexport function ColumnsProvider(\n source?: TreeNodeAccessor | ReadonlyArray<UpstreamBlockCtx<AccessorHandle>>,\n) {\n if (isNil(source) || Array.isArray(source)) {\n return ResultPoolColumnsProvider(source);\n } else if (source instanceof TreeNodeAccessor) {\n return AccessorColumnsProvider(source);\n } else {\n throw new Error(\"Unknown columns provider source\");\n }\n}\n\n/**\n * Memoised constructor — same `root.handle` returns the same\n * {@link AccessorColumnsProviderImpl}, so `indexAccessorRoot` runs once per\n * accessor root (within the LRU window).\n */\nconst _accessorProviderCache = new LRUCache<AccessorHandle, AccessorColumnsProviderImpl>({\n max: 64,\n});\nexport function AccessorColumnsProvider(root: TreeNodeAccessor): AccessorColumnsProvider {\n let provider = _accessorProviderCache.get(root.handle);\n if (provider === undefined) {\n provider = new AccessorColumnsProviderImpl(root);\n _accessorProviderCache.set(root.handle, provider);\n }\n return provider;\n}\n\n/**\n * Memoised constructor — same `rawPool` content returns the same\n * {@link ResultPoolColumnsProviderImpl}, so `indexPoolBlock` runs once per\n * pool snapshot (within the LRU window).\n */\nconst _resultPoolProviderCache = new LRUCache<string, ResultPoolColumnsProviderImpl>({ max: 4 });\nexport function ResultPoolColumnsProvider(\n rawPool: ReadonlyArray<\n UpstreamBlockCtx<AccessorHandle>\n > = getCfgRenderCtx().getUpstreamBlockCtx(),\n): ResultPoolColumnsProvider {\n const key = hashRawPool(rawPool);\n let provider = _resultPoolProviderCache.get(key);\n if (provider === undefined) {\n provider = new ResultPoolColumnsProviderImpl(rawPool);\n _resultPoolProviderCache.set(key, provider);\n }\n return provider;\n}\n\n/**\n * Simple provider wrapping an array of PColumns. Sandbox-only —\n * implements {@link ColumnsProvider} (lazy-view enumeration). It is *not* an\n * id-index source — `ColumnRegistry` does not consume it.\n */\nexport class ArrayColumnsProvider implements ColumnsProvider {\n private readonly columns: DataColumnRecipe<PObjectId>[];\n\n constructor(\n columns: ReadonlyArray<PColumn<undefined | PColumnDataUniversal> | DataColumnRecipe<PObjectId>>,\n private readonly _isFinal: boolean,\n ) {\n this.columns = columns.map((c) => DataColumn.fromColumn(c));\n }\n\n getColumns(): DataColumnRecipe<PObjectId>[] {\n return this.columns;\n }\n\n isFinal(): boolean {\n return this._isFinal;\n }\n}\n\n/**\n * Sandbox-specific provider over a {@link TreeNodeAccessor} root. Uses the\n * accessor's own `resolvePath` as the canonical root path for id construction,\n * and adds `getColumns()` returning {@link DataColumnRecipe<PObjectId>}s on top of the generic\n * entries index.\n */\nexport class AccessorColumnsProviderImpl\n extends AccessorEntriesProvider<TreeNodeAccessor>\n implements ColumnsProvider\n{\n private cachedColumns?: DataColumnRecipe<PObjectId>[];\n\n constructor(root: TreeNodeAccessor) {\n super(root, root.resolvePath);\n }\n\n getColumns(): DataColumnRecipe<PObjectId>[] {\n if (this.cachedColumns !== undefined) return this.cachedColumns;\n return (this.cachedColumns = Array.from(this.entries.values(), DataColumn.fromAccessor).filter(\n (column) => column !== undefined,\n ));\n }\n}\n\n/** Public type alias — value of the same name is the memoised factory above. */\nexport type AccessorColumnsProvider = AccessorColumnsProviderImpl;\n\n/**\n * Sandbox-specific result-pool provider. Accepts the raw handle-shaped blocks\n * returned by {@link GlobalCfgRenderCtxMethods.getUpstreamBlockCtx} and\n * wraps them into {@link TreeNodeAccessor}s, then adds `getColumns()`.\n */\nexport class ResultPoolColumnsProviderImpl\n extends ResultPoolEntriesProvider<TreeNodeAccessor>\n implements ColumnsProvider\n{\n private cachedColumns?: DataColumnRecipe<PObjectId>[];\n\n constructor(\n rawPool: ReadonlyArray<\n UpstreamBlockCtx<AccessorHandle>\n > = getCfgRenderCtx().getUpstreamBlockCtx(),\n ) {\n const blocks = rawPool.map((b) => ({\n blockId: b.blockId,\n prodCtx:\n b.prodCtx !== undefined\n ? new TreeNodeAccessor(b.prodCtx, [b.blockId, \"prodCtx\"])\n : undefined,\n stagingCtx:\n b.stagingCtx !== undefined\n ? new TreeNodeAccessor(b.stagingCtx, [b.blockId, \"stagingCtx\"])\n : undefined,\n prodIncomplete: b.prodIncomplete,\n stagingIncomplete: b.stagingIncomplete,\n }));\n\n super(blocks);\n }\n\n getColumns(): DataColumnRecipe<PObjectId>[] {\n if (this.cachedColumns !== undefined) return this.cachedColumns;\n return (this.cachedColumns = Array.from(\n this.getPObjectEntries().values(),\n DataColumn.fromAccessor,\n ).filter((column) => column !== undefined));\n }\n}\n\n/** Public type alias — value of the same name is the memoised factory above. */\nexport type ResultPoolColumnsProvider = ResultPoolColumnsProviderImpl;\n\nfunction hashRawPool(rawPool: ReadonlyArray<UpstreamBlockCtx<AccessorHandle>>): string {\n return rawPool\n .map(\n (b) =>\n `${b.blockId}\\x1f${b.prodCtx ?? \"\"}\\x1f${b.stagingCtx ?? \"\"}\\x1f${\n b.prodIncomplete ? 1 : 0\n }\\x1f${b.stagingIncomplete ? 1 : 0}`,\n )\n .join(\"\\x1e\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,gBACd,Q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,KAAK,gBAAgB,MAAM,KAAK,KAAK,QAAQ,OAAO,GAAGD,oBAAAA,WAAW,YAAY,CAAC,CAAC,QACrF,WAAW,WAAW,KAAA,CACzB;CACF;AACF;;;;;;AAUA,IAAa,gCAAb,cACUE,gCAAAA,0BAEV;CACE;CAEA,YACE,UAEIH,iBAAAA,gBAAgB,CAAC,CAAC,oBAAoB,GAC1C;EACA,MAAM,SAAS,QAAQ,KAAK,OAAO;GACjC,SAAS,EAAE;GACX,SACE,EAAE,YAAY,KAAA,IACV,IAAIF,iBAAAA,iBAAiB,EAAE,SAAS,CAAC,EAAE,SAAS,SAAS,CAAC,IACtD,KAAA;GACN,YACE,EAAE,eAAe,KAAA,IACb,IAAIA,iBAAAA,iBAAiB,EAAE,YAAY,CAAC,EAAE,SAAS,YAAY,CAAC,IAC5D,KAAA;GACN,gBAAgB,EAAE;GAClB,mBAAmB,EAAE;EACvB,EAAE;EAEF,MAAM,MAAM;CACd;CAEA,aAA4C;EAC1C,IAAI,KAAK,kBAAkB,KAAA,GAAW,OAAO,KAAK;EAClD,OAAQ,KAAK,gBAAgB,MAAM,KACjC,KAAK,kBAAkB,CAAC,CAAC,OAAO,GAChCG,oBAAAA,WAAW,YACb,CAAC,CAAC,QAAQ,WAAW,WAAW,KAAA,CAAS;CAC3C;AACF;AAKA,SAAS,YAAY,SAAkE;CACrF,OAAO,QACJ,KACE,MACC,GAAG,EAAE,QAAQ,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,cAAc,GAAG,MAC1D,EAAE,iBAAiB,IAAI,EACxB,MAAM,EAAE,oBAAoB,IAAI,GACrC,CAAC,CACA,KAAK,GAAM;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","names":[],"sources":["../../../src/columns/column_providers/providers.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","names":[],"sources":["../../../src/columns/column_providers/providers.ts"],"mappings":";;;;;;;;;;;;;iBAqBiB;;EAEf,cAAc,iBAAiB;;EAE/B;;;;;;;;;;;;;;wBAec,gBACd,SAAS,mBAAmB,cAAc,iBAAiB,mBAAgB,8BAAA;wBAmB7D,wBAAwB,MAAM,mBAAmB;wBAejD,0BACd,UAAS,cACP,iBAAiB,mBAElB;;;;;;qBAeU,gCAAgC;mBAKxB;mBAJF;EAEjB,YACE,SAAS,cAAc,oBAAoB,wBAAwB,iBAAiB,aACnE;EAKnB,cAAc,iBAAiB;EAI/B;;;;;;;;qBAWW,oCACH,wBAAwB,6BACrB;UAEH;EAER,YAAY,MAAM;EAIlB,cAAc,iBAAiB;;;YASrB,0BAA0B;;;;;;qBAOzB,sCACH,0BAA0B,6BACvB;UAEH;EAER,YACE,UAAS,cACP,iBAAiB;EAoBrB,cAAc,iBAAiB;;;YAUrB,4BAA4B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getCfgRenderCtx } from "../../internal.js";
|
|
2
2
|
import { TreeNodeAccessor } from "../../render/accessor.js";
|
|
3
3
|
import "../../render/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DataColumn } from "../data_column.js";
|
|
5
5
|
import { AccessorEntriesProvider, ResultPoolEntriesProvider } from "@milaboratories/pl-model-common";
|
|
6
6
|
import { isNil } from "es-toolkit";
|
|
7
7
|
import { LRUCache } from "lru-cache";
|
|
@@ -84,7 +84,7 @@ var AccessorColumnsProviderImpl = class extends AccessorEntriesProvider {
|
|
|
84
84
|
}
|
|
85
85
|
getColumns() {
|
|
86
86
|
if (this.cachedColumns !== void 0) return this.cachedColumns;
|
|
87
|
-
return this.cachedColumns = Array.from(this.entries.values(),
|
|
87
|
+
return this.cachedColumns = Array.from(this.entries.values(), DataColumn.fromAccessor).filter((column) => column !== void 0);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
@@ -106,17 +106,9 @@ var ResultPoolColumnsProviderImpl = class extends ResultPoolEntriesProvider {
|
|
|
106
106
|
}
|
|
107
107
|
getColumns() {
|
|
108
108
|
if (this.cachedColumns !== void 0) return this.cachedColumns;
|
|
109
|
-
return this.cachedColumns = Array.from(this.getPObjectEntries().values(),
|
|
109
|
+
return this.cachedColumns = Array.from(this.getPObjectEntries().values(), DataColumn.fromAccessor).filter((column) => column !== void 0);
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
function columnUnlessAbsent(entry) {
|
|
113
|
-
try {
|
|
114
|
-
return DataColumn.fromAccessor(entry);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
if (error instanceof ColumnAbsentError) return void 0;
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
112
|
function hashRawPool(rawPool) {
|
|
121
113
|
return rawPool.map((b) => `${b.blockId}\x1f${b.prodCtx ?? ""}\x1f${b.stagingCtx ?? ""}\x1f${b.prodIncomplete ? 1 : 0}\x1f${b.stagingIncomplete ? 1 : 0}`).join("");
|
|
122
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","names":[],"sources":["../../../src/columns/column_providers/providers.ts"],"sourcesContent":["import {\n AccessorEntriesProvider,\n ResultPoolEntriesProvider,\n type
|
|
1
|
+
{"version":3,"file":"providers.js","names":[],"sources":["../../../src/columns/column_providers/providers.ts"],"sourcesContent":["import {\n AccessorEntriesProvider,\n ResultPoolEntriesProvider,\n type PColumn,\n type PObjectId,\n type UpstreamBlockCtx,\n} from \"@milaboratories/pl-model-common\";\nimport { AccessorHandle, PColumnDataUniversal, TreeNodeAccessor } from \"../../render\";\nimport { DataColumn, DataColumnRecipe } from \"../data_column\";\nimport { getCfgRenderCtx } from \"../../internal\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\n\n/**\n * Data source for sandbox column-list builders. Has nothing to say about\n * id-resolution — `ColumnRegistry` (in `@milaboratories/pl-model-common`)\n * consumes the separate `ColumnEntriesProvider` interface for that.\n *\n * Same name as the factory function below — they merge into one TS\n * declaration: `ColumnsProvider` is callable AND the interface type.\n */\nexport interface ColumnsProvider {\n /** Returns all currently known PColumn columns as lazy views. */\n getColumns(): DataColumnRecipe<PObjectId>[];\n /** Whether the provider has finished enumerating all its columns. */\n isFinal(): boolean;\n}\n\n/**\n * Unified memoised factory dispatching to the right provider flavour by the\n * source shape:\n * - `TreeNodeAccessor` → {@link AccessorColumnsProvider}\n * (indexed by `root.handle`, walks the accessor tree once per root).\n * - `UpstreamBlockCtx<AccessorHandle>[]` (or omitted — pulled from the\n * ambient ctx) → {@link ResultPoolColumnsProvider}\n * (indexed by a content-hash of the block list).\n *\n * Both branches return cached instances within their LRU window, so repeated\n * calls with the same source skip re-walking / re-hashing.\n */\nexport function ColumnsProvider(\n source?: TreeNodeAccessor | ReadonlyArray<UpstreamBlockCtx<AccessorHandle>>,\n) {\n if (isNil(source) || Array.isArray(source)) {\n return ResultPoolColumnsProvider(source);\n } else if (source instanceof TreeNodeAccessor) {\n return AccessorColumnsProvider(source);\n } else {\n throw new Error(\"Unknown columns provider source\");\n }\n}\n\n/**\n * Memoised constructor — same `root.handle` returns the same\n * {@link AccessorColumnsProviderImpl}, so `indexAccessorRoot` runs once per\n * accessor root (within the LRU window).\n */\nconst _accessorProviderCache = new LRUCache<AccessorHandle, AccessorColumnsProviderImpl>({\n max: 64,\n});\nexport function AccessorColumnsProvider(root: TreeNodeAccessor): AccessorColumnsProvider {\n let provider = _accessorProviderCache.get(root.handle);\n if (provider === undefined) {\n provider = new AccessorColumnsProviderImpl(root);\n _accessorProviderCache.set(root.handle, provider);\n }\n return provider;\n}\n\n/**\n * Memoised constructor — same `rawPool` content returns the same\n * {@link ResultPoolColumnsProviderImpl}, so `indexPoolBlock` runs once per\n * pool snapshot (within the LRU window).\n */\nconst _resultPoolProviderCache = new LRUCache<string, ResultPoolColumnsProviderImpl>({ max: 4 });\nexport function ResultPoolColumnsProvider(\n rawPool: ReadonlyArray<\n UpstreamBlockCtx<AccessorHandle>\n > = getCfgRenderCtx().getUpstreamBlockCtx(),\n): ResultPoolColumnsProvider {\n const key = hashRawPool(rawPool);\n let provider = _resultPoolProviderCache.get(key);\n if (provider === undefined) {\n provider = new ResultPoolColumnsProviderImpl(rawPool);\n _resultPoolProviderCache.set(key, provider);\n }\n return provider;\n}\n\n/**\n * Simple provider wrapping an array of PColumns. Sandbox-only —\n * implements {@link ColumnsProvider} (lazy-view enumeration). It is *not* an\n * id-index source — `ColumnRegistry` does not consume it.\n */\nexport class ArrayColumnsProvider implements ColumnsProvider {\n private readonly columns: DataColumnRecipe<PObjectId>[];\n\n constructor(\n columns: ReadonlyArray<PColumn<undefined | PColumnDataUniversal> | DataColumnRecipe<PObjectId>>,\n private readonly _isFinal: boolean,\n ) {\n this.columns = columns.map((c) => DataColumn.fromColumn(c));\n }\n\n getColumns(): DataColumnRecipe<PObjectId>[] {\n return this.columns;\n }\n\n isFinal(): boolean {\n return this._isFinal;\n }\n}\n\n/**\n * Sandbox-specific provider over a {@link TreeNodeAccessor} root. Uses the\n * accessor's own `resolvePath` as the canonical root path for id construction,\n * and adds `getColumns()` returning {@link DataColumnRecipe<PObjectId>}s on top of the generic\n * entries index.\n */\nexport class AccessorColumnsProviderImpl\n extends AccessorEntriesProvider<TreeNodeAccessor>\n implements ColumnsProvider\n{\n private cachedColumns?: DataColumnRecipe<PObjectId>[];\n\n constructor(root: TreeNodeAccessor) {\n super(root, root.resolvePath);\n }\n\n getColumns(): DataColumnRecipe<PObjectId>[] {\n if (this.cachedColumns !== undefined) return this.cachedColumns;\n return (this.cachedColumns = Array.from(this.entries.values(), DataColumn.fromAccessor).filter(\n (column) => column !== undefined,\n ));\n }\n}\n\n/** Public type alias — value of the same name is the memoised factory above. */\nexport type AccessorColumnsProvider = AccessorColumnsProviderImpl;\n\n/**\n * Sandbox-specific result-pool provider. Accepts the raw handle-shaped blocks\n * returned by {@link GlobalCfgRenderCtxMethods.getUpstreamBlockCtx} and\n * wraps them into {@link TreeNodeAccessor}s, then adds `getColumns()`.\n */\nexport class ResultPoolColumnsProviderImpl\n extends ResultPoolEntriesProvider<TreeNodeAccessor>\n implements ColumnsProvider\n{\n private cachedColumns?: DataColumnRecipe<PObjectId>[];\n\n constructor(\n rawPool: ReadonlyArray<\n UpstreamBlockCtx<AccessorHandle>\n > = getCfgRenderCtx().getUpstreamBlockCtx(),\n ) {\n const blocks = rawPool.map((b) => ({\n blockId: b.blockId,\n prodCtx:\n b.prodCtx !== undefined\n ? new TreeNodeAccessor(b.prodCtx, [b.blockId, \"prodCtx\"])\n : undefined,\n stagingCtx:\n b.stagingCtx !== undefined\n ? new TreeNodeAccessor(b.stagingCtx, [b.blockId, \"stagingCtx\"])\n : undefined,\n prodIncomplete: b.prodIncomplete,\n stagingIncomplete: b.stagingIncomplete,\n }));\n\n super(blocks);\n }\n\n getColumns(): DataColumnRecipe<PObjectId>[] {\n if (this.cachedColumns !== undefined) return this.cachedColumns;\n return (this.cachedColumns = Array.from(\n this.getPObjectEntries().values(),\n DataColumn.fromAccessor,\n ).filter((column) => column !== undefined));\n }\n}\n\n/** Public type alias — value of the same name is the memoised factory above. */\nexport type ResultPoolColumnsProvider = ResultPoolColumnsProviderImpl;\n\nfunction hashRawPool(rawPool: ReadonlyArray<UpstreamBlockCtx<AccessorHandle>>): string {\n return rawPool\n .map(\n (b) =>\n `${b.blockId}\\x1f${b.prodCtx ?? \"\"}\\x1f${b.stagingCtx ?? \"\"}\\x1f${\n b.prodIncomplete ? 1 : 0\n }\\x1f${b.stagingIncomplete ? 1 : 0}`,\n )\n .join(\"\\x1e\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,gBACd,QACA;CACA,IAAI,MAAM,MAAM,KAAK,MAAM,QAAQ,MAAM,GACvC,OAAO,0BAA0B,MAAM;MAClC,IAAI,kBAAkB,kBAC3B,OAAO,wBAAwB,MAAM;MAErC,MAAM,IAAI,MAAM,iCAAiC;AAErD;;;;;;AAOA,MAAM,yBAAyB,IAAI,SAAsD,EACvF,KAAK,GACP,CAAC;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BAAiB,EAAE,SAAS,CAAC,EAAE,SAAS,SAAS,CAAC,IACtD,KAAA;GACN,YACE,EAAE,eAAe,KAAA,IACb,IAAI,iBAAiB,EAAE,YAAY,CAAC,EAAE,SAAS,YAAY,CAAC,IAC5D,KAAA;GACN,gBAAgB,EAAE;GAClB,mBAAmB,EAAE;EACvB,EAAE;EAEF,MAAM,MAAM;CACd;CAEA,aAA4C;EAC1C,IAAI,KAAK,kBAAkB,KAAA,GAAW,OAAO,KAAK;EAClD,OAAQ,KAAK,gBAAgB,MAAM,KACjC,KAAK,kBAAkB,CAAC,CAAC,OAAO,GAChC,WAAW,YACb,CAAC,CAAC,QAAQ,WAAW,WAAW,KAAA,CAAS;CAC3C;AACF;AAKA,SAAS,YAAY,SAAkE;CACrF,OAAO,QACJ,KACE,MACC,GAAG,EAAE,QAAQ,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,cAAc,GAAG,MAC1D,EAAE,iBAAiB,IAAI,EACxB,MAAM,EAAE,oBAAoB,IAAI,GACrC,CAAC,CACA,KAAK,GAAM;AAChB"}
|
|
@@ -41,8 +41,8 @@ function ColumnRecipeBuild(id, opts = {}) {
|
|
|
41
41
|
* Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on
|
|
42
42
|
* the parsed id shape to the matching `getStatusBy*` static — never
|
|
43
43
|
* constructs the recipe. Use this at boundaries (resolver, filter/sort
|
|
44
|
-
* targets) to
|
|
45
|
-
*
|
|
44
|
+
* targets) to tell an `absent` column from a `resolving` one: the recipe
|
|
45
|
+
* factory returns `undefined` for both.
|
|
46
46
|
*/
|
|
47
47
|
function ColumnRecipeGetStatus(id, opts = {}) {
|
|
48
48
|
const parsed = (0, _milaboratories_pl_model_common.parseColumnIdSafely)(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["parseColumnIdSafely","isPObjectKey","DataColumn","isColumnDiscoveredKey","ColumnDiscoveredRecipe","isColumnOverriddenKey","ColumnOverriddenRecipe","isColumnFilteredKey","ColumnFilteredRecipe"],"sources":["../../../src/columns/column_recipes/index.ts"],"sourcesContent":["import {\n isColumnDiscoveredKey,\n isColumnOverriddenKey,\n parseColumnIdSafely,\n type ColumnUniversalId,\n type PObjectId,\n isPObjectKey,\n isColumnFilteredKey,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../../render/internal\";\nimport { DataColumn } from \"../data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\nimport type {\n ColumnRecipe as ColumnRecipeBase,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./types\";\n\nexport type { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from \"./types\";\nexport {
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["parseColumnIdSafely","isPObjectKey","DataColumn","isColumnDiscoveredKey","ColumnDiscoveredRecipe","isColumnOverriddenKey","ColumnOverriddenRecipe","isColumnFilteredKey","ColumnFilteredRecipe"],"sources":["../../../src/columns/column_recipes/index.ts"],"sourcesContent":["import {\n isColumnDiscoveredKey,\n isColumnOverriddenKey,\n parseColumnIdSafely,\n type ColumnUniversalId,\n type PObjectId,\n isPObjectKey,\n isColumnFilteredKey,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../../render/internal\";\nimport { DataColumn } from \"../data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\nimport type {\n ColumnRecipe as ColumnRecipeBase,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./types\";\n\nexport type { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from \"./types\";\nexport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nexport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nexport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\n\n// Re-declare the interface locally so the name can merge with the dispatcher\n// value declared below: a single name `ColumnRecipe` resolves to the\n// interface in type position and to the factory function (`Object.assign`d\n// with `.getStatus`) in value position.\n// (Type-only re-exports do not participate in TS declaration merging.)\nexport interface ColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipeBase<ID> {}\n\n/**\n * Build a `ColumnRecipe` from a stringified id. Dispatches to the matching\n * concrete recipe variant based on the id's encoding and recurses on\n * wrappers' inner `source`:\n *\n * - bare {@link PObjectId} (non-JSON) → `DataColumnRecipe.fromId`\n * - `ColumnDiscoveredKey` → {@link ColumnDiscoveredRecipe}\n * - `ColumnOverriddenKey { source, specOverrides }` → recurse on `source`,\n * then {@link ColumnOverriddenRecipe.wrap}\n * - `ColumnFilteredKey { source, axisFilters }` → recurse on `source`,\n * then {@link ColumnFilteredRecipe.wrap}\n *\n * Returns `undefined` for unsupported variants (e.g. AnchoredPColumnId,\n * which needs an anchor map to resolve) or when a nested source itself\n * cannot be built.\n */\nfunction ColumnRecipeBuild(\n id: ColumnUniversalId,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | ColumnRecipe {\n const parsed = parseColumnIdSafely(id);\n\n if (isPObjectKey(parsed)) {\n return DataColumn.fromId(id as PObjectId, opts);\n }\n\n if (isColumnDiscoveredKey(parsed)) {\n return ColumnDiscoveredRecipe.fromKey(parsed, opts);\n }\n\n if (isColumnOverriddenKey(parsed)) {\n const inner = ColumnRecipe(parsed.source, opts);\n if (inner === undefined) return undefined;\n return ColumnOverriddenRecipe.wrap(inner, parsed.specOverrides);\n }\n\n if (isColumnFilteredKey(parsed)) {\n // ColumnFilteredKey.source is a stringified ColumnUniversalId (leaf or\n // any nested wrapper). Legacy `FilteredPColumnId` with an AnchoredPColumnId\n // (object) source is not supported here — guard against it explicitly.\n if (typeof parsed.source !== \"string\") {\n throw new Error(\n `Unsupported ColumnRecipe id variant: filtered column with non-string source (${JSON.stringify(parsed.source)})`,\n );\n }\n const inner = ColumnRecipe(parsed.source, opts);\n if (inner === undefined) return undefined;\n return ColumnFilteredRecipe.wrap(inner, parsed.axisFilters);\n }\n\n throw new Error(`Unsupported ColumnRecipe id variant: ${id}`);\n}\n\n/**\n * Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on\n * the parsed id shape to the matching `getStatusBy*` static — never\n * constructs the recipe. Use this at boundaries (resolver, filter/sort\n * targets) to tell an `absent` column from a `resolving` one: the recipe\n * factory returns `undefined` for both.\n */\nfunction ColumnRecipeGetStatus(\n id: ColumnUniversalId,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n const parsed = parseColumnIdSafely(id);\n if (isPObjectKey(parsed)) return DataColumn.getStatusById(id as PObjectId, opts);\n if (isColumnDiscoveredKey(parsed)) return ColumnDiscoveredRecipe.getStatusByKey(parsed, opts);\n if (isColumnOverriddenKey(parsed)) return ColumnOverriddenRecipe.getStatusByKey(parsed, opts);\n if (isColumnFilteredKey(parsed)) return ColumnFilteredRecipe.getStatusByKey(parsed, opts);\n throw new Error(`Unsupported ColumnRecipe id variant: ${id}`);\n}\n\nexport const ColumnRecipe: typeof ColumnRecipeBuild & {\n readonly getStatus: typeof ColumnRecipeGetStatus;\n} = Object.assign(ColumnRecipeBuild, {\n getStatus: ColumnRecipeGetStatus,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,kBACP,IACA,OAAqC,CAAC,GACZ;CAC1B,MAAM,UAAA,GAASA,gCAAAA,oBAAAA,CAAoB,EAAE;CAErC,KAAA,GAAIC,gCAAAA,aAAAA,CAAa,MAAM,GACrB,OAAOC,oBAAAA,WAAW,OAAO,IAAiB,IAAI;CAGhD,KAAA,GAAIC,gCAAAA,sBAAAA,CAAsB,MAAM,GAC9B,OAAOC,iCAAAA,uBAAuB,QA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tx } from "../../render/internal.js";
|
|
2
2
|
import { ColumnFieldStatus, ColumnRecipe as ColumnRecipe$1, ColumnRecipeId, ColumnResolutionStatus, SpecQuery as SpecQuery$1 } from "./types.js";
|
|
3
|
-
import { ColumnAbsentError } from "../data_column.js";
|
|
4
3
|
import { ColumnDiscoveredRecipe } from "./column_discovered_recipe.js";
|
|
5
4
|
import { ColumnFilteredRecipe } from "./column_filtered_recipe.js";
|
|
6
5
|
import { ColumnOverriddenRecipe } from "./column_overrided_recipe.js";
|
|
@@ -29,8 +28,8 @@ declare function ColumnRecipeBuild(id: ColumnUniversalId, opts?: {
|
|
|
29
28
|
* Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on
|
|
30
29
|
* the parsed id shape to the matching `getStatusBy*` static — never
|
|
31
30
|
* constructs the recipe. Use this at boundaries (resolver, filter/sort
|
|
32
|
-
* targets) to
|
|
33
|
-
*
|
|
31
|
+
* targets) to tell an `absent` column from a `resolving` one: the recipe
|
|
32
|
+
* factory returns `undefined` for both.
|
|
34
33
|
*/
|
|
35
34
|
declare function ColumnRecipeGetStatus(id: ColumnUniversalId, opts?: {
|
|
36
35
|
ctx?: GlobalCfgRenderCtx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["ColumnRecipeBase"],"sources":["../../../src/columns/column_recipes/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["ColumnRecipeBase"],"sources":["../../../src/columns/column_recipes/index.ts"],"mappings":";;;;;;iBA8BiB,aACf,WAAW,iBAAiB,wBACpBA,eAAiB;;;;;;;;;;;;;;;;;iBAkBlB,kBACP,IAAI,mBACJ;EAAQ,MAAM;gBACD;;;;;;;;iBAyCN,sBACP,IAAI,mBACJ;EAAQ,MAAM;IACb;qBASU,qBAAqB;WACvB,kBAAkB"}
|
|
@@ -41,8 +41,8 @@ function ColumnRecipeBuild(id, opts = {}) {
|
|
|
41
41
|
* Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on
|
|
42
42
|
* the parsed id shape to the matching `getStatusBy*` static — never
|
|
43
43
|
* constructs the recipe. Use this at boundaries (resolver, filter/sort
|
|
44
|
-
* targets) to
|
|
45
|
-
*
|
|
44
|
+
* targets) to tell an `absent` column from a `resolving` one: the recipe
|
|
45
|
+
* factory returns `undefined` for both.
|
|
46
46
|
*/
|
|
47
47
|
function ColumnRecipeGetStatus(id, opts = {}) {
|
|
48
48
|
const parsed = parseColumnIdSafely(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/columns/column_recipes/index.ts"],"sourcesContent":["import {\n isColumnDiscoveredKey,\n isColumnOverriddenKey,\n parseColumnIdSafely,\n type ColumnUniversalId,\n type PObjectId,\n isPObjectKey,\n isColumnFilteredKey,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../../render/internal\";\nimport { DataColumn } from \"../data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\nimport type {\n ColumnRecipe as ColumnRecipeBase,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./types\";\n\nexport type { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from \"./types\";\nexport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/columns/column_recipes/index.ts"],"sourcesContent":["import {\n isColumnDiscoveredKey,\n isColumnOverriddenKey,\n parseColumnIdSafely,\n type ColumnUniversalId,\n type PObjectId,\n isPObjectKey,\n isColumnFilteredKey,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../../render/internal\";\nimport { DataColumn } from \"../data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\nimport type {\n ColumnRecipe as ColumnRecipeBase,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./types\";\n\nexport type { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from \"./types\";\nexport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nexport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nexport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\n\n// Re-declare the interface locally so the name can merge with the dispatcher\n// value declared below: a single name `ColumnRecipe` resolves to the\n// interface in type position and to the factory function (`Object.assign`d\n// with `.getStatus`) in value position.\n// (Type-only re-exports do not participate in TS declaration merging.)\nexport interface ColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipeBase<ID> {}\n\n/**\n * Build a `ColumnRecipe` from a stringified id. Dispatches to the matching\n * concrete recipe variant based on the id's encoding and recurses on\n * wrappers' inner `source`:\n *\n * - bare {@link PObjectId} (non-JSON) → `DataColumnRecipe.fromId`\n * - `ColumnDiscoveredKey` → {@link ColumnDiscoveredRecipe}\n * - `ColumnOverriddenKey { source, specOverrides }` → recurse on `source`,\n * then {@link ColumnOverriddenRecipe.wrap}\n * - `ColumnFilteredKey { source, axisFilters }` → recurse on `source`,\n * then {@link ColumnFilteredRecipe.wrap}\n *\n * Returns `undefined` for unsupported variants (e.g. AnchoredPColumnId,\n * which needs an anchor map to resolve) or when a nested source itself\n * cannot be built.\n */\nfunction ColumnRecipeBuild(\n id: ColumnUniversalId,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | ColumnRecipe {\n const parsed = parseColumnIdSafely(id);\n\n if (isPObjectKey(parsed)) {\n return DataColumn.fromId(id as PObjectId, opts);\n }\n\n if (isColumnDiscoveredKey(parsed)) {\n return ColumnDiscoveredRecipe.fromKey(parsed, opts);\n }\n\n if (isColumnOverriddenKey(parsed)) {\n const inner = ColumnRecipe(parsed.source, opts);\n if (inner === undefined) return undefined;\n return ColumnOverriddenRecipe.wrap(inner, parsed.specOverrides);\n }\n\n if (isColumnFilteredKey(parsed)) {\n // ColumnFilteredKey.source is a stringified ColumnUniversalId (leaf or\n // any nested wrapper). Legacy `FilteredPColumnId` with an AnchoredPColumnId\n // (object) source is not supported here — guard against it explicitly.\n if (typeof parsed.source !== \"string\") {\n throw new Error(\n `Unsupported ColumnRecipe id variant: filtered column with non-string source (${JSON.stringify(parsed.source)})`,\n );\n }\n const inner = ColumnRecipe(parsed.source, opts);\n if (inner === undefined) return undefined;\n return ColumnFilteredRecipe.wrap(inner, parsed.axisFilters);\n }\n\n throw new Error(`Unsupported ColumnRecipe id variant: ${id}`);\n}\n\n/**\n * Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on\n * the parsed id shape to the matching `getStatusBy*` static — never\n * constructs the recipe. Use this at boundaries (resolver, filter/sort\n * targets) to tell an `absent` column from a `resolving` one: the recipe\n * factory returns `undefined` for both.\n */\nfunction ColumnRecipeGetStatus(\n id: ColumnUniversalId,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n const parsed = parseColumnIdSafely(id);\n if (isPObjectKey(parsed)) return DataColumn.getStatusById(id as PObjectId, opts);\n if (isColumnDiscoveredKey(parsed)) return ColumnDiscoveredRecipe.getStatusByKey(parsed, opts);\n if (isColumnOverriddenKey(parsed)) return ColumnOverriddenRecipe.getStatusByKey(parsed, opts);\n if (isColumnFilteredKey(parsed)) return ColumnFilteredRecipe.getStatusByKey(parsed, opts);\n throw new Error(`Unsupported ColumnRecipe id variant: ${id}`);\n}\n\nexport const ColumnRecipe: typeof ColumnRecipeBuild & {\n readonly getStatus: typeof ColumnRecipeGetStatus;\n} = Object.assign(ColumnRecipeBuild, {\n getStatus: ColumnRecipeGetStatus,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,kBACP,IACA,OAAqC,CAAC,GACZ;CAC1B,MAAM,SAAS,oBAAoB,EAAE;CAErC,IAAI,aAAa,MAAM,GACrB,OAAO,WAAW,OAAO,IAAiB,IAAI;CAGhD,IAAI,sBAAsB,MAAM,GAC9B,OAAO,uBAAuB,QAAQ,QAAQ,IAAI;CAGpD,IAAI,sBAAsB,MAAM,GAAG;EACjC,MAAM,QAAQ,aAAa,OAAO,QAAQ,IAAI;EAC9C,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,OAAO,uBAAuB,KAAK,OAAO,OAAO,aAAa;CAChE;CAEA,IAAI,oBAAoB,MAAM,GAAG;EAI/B,IAAI,OAAO,OAAO,WAAW,UAC3B,MAAM,IAAI,MACR,gFAAgF,KAAK,UAAU,OAAO,MAAM,EAAE,EAChH;EAEF,MAAM,QAAQ,aAAa,OAAO,QAAQ,IAAI;EAC9C,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,OAAO,qBAAqB,KAAK,OAAO,OAAO,WAAW;CAC5D;CAEA,MAAM,IAAI,MAAM,wCAAwC,IAAI;AAC9D;;;;;;;;AASA,SAAS,sBACP,IACA,OAAqC,CAAC,GACd;CACxB,MAAM,SAAS,oBAAoB,EAAE;CACrC,IAAI,aAAa,MAAM,GAAG,OAAO,WAAW,cAAc,IAAiB,IAAI;CAC/E,IAAI,sBAAsB,MAAM,GAAG,OAAO,uBAAuB,eAAe,QAAQ,IAAI;CAC5F,IAAI,sBAAsB,MAAM,GAAG,OAAO,uBAAuB,eAAe,QAAQ,IAAI;CAC5F,IAAI,oBAAoB,MAAM,GAAG,OAAO,qBAAqB,eAAe,QAAQ,IAAI;CACxF,MAAM,IAAI,MAAM,wCAAwC,IAAI;AAC9D;AAEA,MAAa,eAET,OAAO,OAAO,mBAAmB,EACnC,WAAW,sBACb,CAAC"}
|
|
@@ -5,25 +5,6 @@ let es_toolkit = require("es-toolkit");
|
|
|
5
5
|
let lru_cache = require("lru-cache");
|
|
6
6
|
// src/columns/data_column.ts
|
|
7
7
|
/**
|
|
8
|
-
* Thrown by leaf-recipe factories when the requested column is provably
|
|
9
|
-
* absent in the active render ctx — i.e. every relevant accessor reports
|
|
10
|
-
* `inputsLocked` and the column did not appear. Distinct from the
|
|
11
|
-
* `undefined` return that the factories still use for the "resolving" case
|
|
12
|
-
* (the column may still appear later).
|
|
13
|
-
*
|
|
14
|
-
* Catch at the boundary (resolver / filter+sort wiring / data-table assembly)
|
|
15
|
-
* when partial absence should be surfaced to the user rather than silently
|
|
16
|
-
* producing an empty result.
|
|
17
|
-
*/
|
|
18
|
-
var ColumnAbsentError = class extends Error {
|
|
19
|
-
id;
|
|
20
|
-
constructor(id) {
|
|
21
|
-
super(`Column is absent in the active render ctx and will not appear: ${id}`);
|
|
22
|
-
this.id = id;
|
|
23
|
-
this.name = "ColumnAbsentError";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
8
|
* The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare
|
|
28
9
|
* {@link PObjectId} and whose readers are bound to a single tree-accessor
|
|
29
10
|
* leaf. Layered encodings (Overridden / Discovered / Filtered) are reified
|
|
@@ -75,19 +56,14 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
75
56
|
}
|
|
76
57
|
/**
|
|
77
58
|
* Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:
|
|
78
|
-
* returns `undefined`
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* exist in this ctx. Data and dataStatus stay lazy.
|
|
59
|
+
* returns `undefined` unless the id names a column whose spec is readable in
|
|
60
|
+
* this ctx — while it is resolving, when it is absent, and when the id names
|
|
61
|
+
* an export that is not a column (a `kind: "File"` object, for example).
|
|
62
|
+
* Data and dataStatus stay lazy.
|
|
83
63
|
*/
|
|
84
64
|
static fromId(id, { ctx } = {}) {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
if ((0, es_toolkit.isNil)(leaf)) {
|
|
88
|
-
if (registry.isFinal()) throw new ColumnAbsentError(id);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
65
|
+
const leaf = new _milaboratories_pl_model_common.ColumnRegistry(require_index.getCtxProviders({ ctx })).resolve(id);
|
|
66
|
+
if ((0, es_toolkit.isNil)(leaf)) return void 0;
|
|
91
67
|
return DataColumnImpl.fromAccessor(leaf);
|
|
92
68
|
}
|
|
93
69
|
/** {@link PlRef} wrapper over {@link fromId}. */
|
|
@@ -96,18 +72,13 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
96
72
|
}
|
|
97
73
|
/**
|
|
98
74
|
* Bind directly to an accessor-backed {@link LeafEntry} — no registry.
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
75
|
+
* Returns `undefined` unless the leaf's spec is readable and is a column
|
|
76
|
+
* spec: while the spec is resolving, when it is absent, and for an export
|
|
77
|
+
* that is not a column.
|
|
102
78
|
*/
|
|
103
79
|
static fromAccessor(entry) {
|
|
104
|
-
if ((0, es_toolkit.isNil)(readSpecAccessor(entry))) {
|
|
105
|
-
if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
80
|
const spec = readSpec(entry);
|
|
109
|
-
if (spec === void 0) return void 0;
|
|
110
|
-
if (!(0, _milaboratories_pl_model_common.isPColumnSpec)(spec)) throw new ColumnAbsentError(entry.id);
|
|
81
|
+
if (spec === void 0 || !(0, _milaboratories_pl_model_common.isPColumnSpec)(spec)) return void 0;
|
|
111
82
|
return new DataColumnImpl(entry.id, {
|
|
112
83
|
getSpec: () => spec,
|
|
113
84
|
getData: () => readDataAccessor(entry),
|
|
@@ -132,8 +103,8 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
132
103
|
* in the active render ctx. Falls back to the registry's `isFinal()`
|
|
133
104
|
* when the id has no entry — only then we can say `absent` instead of
|
|
134
105
|
* `resolving`. The status tells only whether the spec is readable: for an
|
|
135
|
-
* export that is not a column it is `present`, and the factories
|
|
136
|
-
*
|
|
106
|
+
* export that is not a column it is `present`, and the factories return
|
|
107
|
+
* `undefined`.
|
|
137
108
|
*/
|
|
138
109
|
static getStatusById(id, { ctx } = {}) {
|
|
139
110
|
const registry = new _milaboratories_pl_model_common.ColumnRegistry(require_index.getCtxProviders({ ctx }));
|
|
@@ -243,7 +214,6 @@ function memoizeByEntry(fn) {
|
|
|
243
214
|
return hit.value;
|
|
244
215
|
};
|
|
245
216
|
}
|
|
246
|
-
exports.ColumnAbsentError = ColumnAbsentError;
|
|
247
217
|
exports.DataColumn = DataColumn;
|
|
248
218
|
exports.DataColumnImpl = DataColumnImpl;
|
|
249
219
|
exports.isDataColumn = isDataColumn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_column.cjs","names":["ColumnOverriddenRecipe","ColumnRegistry","getCtxProviders","isNil","createGlobalPObjectId","isPColumnSpec","isPlRef","isPColumn","LRUCache"],"sources":["../../src/columns/data_column.ts"],"sourcesContent":["import {\n ColumnRegistry,\n createGlobalPObjectId,\n isPColumn,\n isPColumnSpec,\n isPlRef,\n PlRef,\n PObjectId,\n type ColumnUniversalId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\n type PObjectSpec,\n type SpecOverrides,\n type SpecQuery,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCtxProviders } from \"./column_providers\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\nimport { TreeNodeAccessor } from \"../render\";\nimport type {\n ColumnFieldStatus,\n ColumnRecipe,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./column_recipes/types\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\n\nexport type DataColumnId = PObjectId;\nexport type ColumnData = undefined | PColumnDataUniversal;\nexport type { ColumnFieldStatus, ColumnResolutionStatus } from \"./column_recipes/types\";\n\n/**\n * A {@link ColumnRecipe} that can be read directly in the sandbox: its\n * {@link getData} is guaranteed to be consistent with {@link getSpec}.\n *\n * This is a *capability*, not a class. Only two recipe shapes carry it — a\n * bare leaf and a spec-override over a bare leaf — because those are the only\n * ones whose data still matches their spec. An axis-filtered recipe drops axes\n * from its spec while the underlying data keeps them, and a discovered recipe\n * only materialises after a join; neither can be read here, so neither\n * implements this interface.\n *\n * Narrow to it with `hasReachableData(recipe)` rather than testing for a concrete\n * class — which recipe classes exist is an implementation detail behind\n * `recipe.id`.\n */\nexport interface DataColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipe<ID> {\n /** Column data, consistent with {@link ColumnRecipe.getSpec}. */\n getData(): ColumnData;\n}\n\n/**\n * Thrown by leaf-recipe factories when the requested column is provably\n * absent in the active render ctx — i.e. every relevant accessor reports\n * `inputsLocked` and the column did not appear. Distinct from the\n * `undefined` return that the factories still use for the \"resolving\" case\n * (the column may still appear later).\n *\n * Catch at the boundary (resolver / filter+sort wiring / data-table assembly)\n * when partial absence should be surfaced to the user rather than silently\n * producing an empty result.\n */\nexport class ColumnAbsentError extends Error {\n constructor(public readonly id: ColumnUniversalId) {\n super(`Column is absent in the active render ctx and will not appear: ${id}`);\n this.name = \"ColumnAbsentError\";\n }\n}\n\n/**\n * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare\n * {@link PObjectId} and whose readers are bound to a single tree-accessor\n * leaf. Layered encodings (Overridden / Discovered / Filtered) are reified\n * through their dedicated recipe classes and reference leaf columns by id.\n *\n * Internal — consumers hold the {@link DataColumnRecipe} interface and construct\n * through the {@link DataColumnRecipe} dispatcher.\n */\nexport class DataColumnImpl implements DataColumnRecipe<PObjectId> {\n private specCache?: { readonly value: PColumnSpec };\n private dataCache?: { readonly value: ColumnData };\n private dataStatusCache?: { readonly value: ColumnFieldStatus };\n\n private constructor(\n public readonly id: PObjectId,\n private readonly options: {\n getSpec: () => PColumnSpec;\n getData: () => ColumnData;\n getDataStatus: () => ColumnFieldStatus;\n },\n ) {}\n\n /** A leaf-recipe references exactly one column — its own id. */\n getReferencedIds(): PObjectId[] {\n return [this.id];\n }\n\n getSpec(): PColumnSpec {\n if (this.specCache === undefined) {\n this.specCache = { value: this.options.getSpec() };\n }\n return this.specCache.value;\n }\n\n /** Leaf-shaped — points straight at `this.id`. */\n getQuery(): SpecQuery {\n return { type: \"column\", column: this.id } as SpecQuery;\n }\n\n getData(): ColumnData {\n if (this.dataCache === undefined) this.dataCache = { value: this.options.getData() };\n return this.dataCache.value;\n }\n\n getDataStatus(): ColumnFieldStatus {\n if (this.dataStatusCache === undefined) {\n this.dataStatusCache = { value: this.options.getDataStatus() };\n }\n return this.dataStatusCache.value;\n }\n\n /**\n * Overlay overrides → produces a {@link ColumnOverriddenRecipe} wrapping\n * this leaf. The leaf itself stays bare (id remains a plain PObjectId);\n * layering lives entirely in the recipe wrappers.\n */\n withSpecs(overrides: SpecOverrides): ColumnRecipe {\n return ColumnOverriddenRecipe.wrap(this, overrides);\n }\n\n /**\n * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:\n * returns `undefined` if the leaf isn't reachable yet (resolving). Throws\n * {@link ColumnAbsentError} when every relevant accessor is `inputsLocked`\n * and the column did not appear, or when the id names an export that is not\n * a column (a `kind: \"File\"` object, for example) — the column will not\n * exist in this ctx. Data and dataStatus stay lazy.\n */\n static fromId(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): undefined | DataColumnRecipe<PObjectId> {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) {\n if (registry.isFinal()) throw new ColumnAbsentError(id);\n return undefined;\n }\n return DataColumnImpl.fromAccessor(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link fromId}. */\n static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId> {\n return DataColumnImpl.fromId(createGlobalPObjectId(ref.blockId, ref.name));\n }\n\n /**\n * Bind directly to an accessor-backed {@link LeafEntry} — no registry.\n * Throws {@link ColumnAbsentError} if the leaf has no spec field and its\n * accessor is `inputsLocked`, or if it names an export that is not a column.\n * Returns `undefined` while still resolving.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n if (isNil(readSpecAccessor(entry))) {\n if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);\n return undefined;\n }\n const spec = readSpec(entry);\n if (spec === undefined) return undefined;\n if (!isPColumnSpec(spec)) throw new ColumnAbsentError(entry.id);\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec,\n getData: () => readDataAccessor(entry),\n getDataStatus: () => readDataStatus(entry),\n });\n }\n\n /**\n * Wrap a materialised {@link PColumn}. If the input is already a\n * {@link DataColumnRecipe} leaf it is returned as-is.\n */\n static fromColumn(\n column: PColumn<ColumnData> | DataColumnRecipe<PObjectId>,\n ): DataColumnRecipe<PObjectId> {\n if (column instanceof DataColumnImpl) return column;\n // `DataColumnRecipe` is an interface, so `instanceof` above does not remove it\n // from the union. The only implementation carrying a bare `PObjectId` is\n // `DataColumnImpl` (wrappers expose `ColumnUniversalId`), so anything\n // reaching here is a materialised `PColumn`.\n const pColumn = column as PColumn<ColumnData>;\n return new DataColumnImpl(pColumn.id, {\n getSpec: () => pColumn.spec,\n getData: () => pColumn.data,\n getDataStatus: () => \"present\",\n });\n }\n\n /**\n * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}\n * in the active render ctx. Falls back to the registry's `isFinal()`\n * when the id has no entry — only then we can say `absent` instead of\n * `resolving`. The status tells only whether the spec is readable: for an\n * export that is not a column it is `present`, and the factories throw\n * {@link ColumnAbsentError}.\n */\n static getStatusById(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) return registry.isFinal() ? \"absent\" : \"resolving\";\n return getLeafEntryStatus(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link getStatusById}. */\n static getStatusByPlRef(\n ref: PlRef,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n return DataColumnImpl.getStatusById(createGlobalPObjectId(ref.blockId, ref.name), opts);\n }\n\n /** No registry — reads straight off the entry's accessor. */\n static getStatusByAccessor(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n return getLeafEntryStatus(entry);\n }\n}\n\n/** Anything the {@link DataColumnRecipe} dispatcher can build a leaf from. */\nexport type DataColumnSource =\n | PObjectId\n | PlRef\n | LeafEntry<TreeNodeAccessor>\n | PColumn<ColumnData>\n | DataColumnRecipe<PObjectId>;\n\n/**\n * Unified dispatcher — picks the right `DataColumnImpl.fromX` by source\n * shape. For ambiguous inputs callers can still use the explicit factories\n * (also attached as properties: `DataColumn.fromId`, `.fromPlRef`,\n * `.fromAccessor`, `.fromColumn`).\n */\nfunction DataColumnDispatch(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | DataColumnRecipe<PObjectId> {\n if (typeof source === \"string\") return DataColumnImpl.fromId(source, opts);\n if (source instanceof DataColumnImpl) return source;\n // `DataColumnRecipe` is an interface — `instanceof` above cannot remove it from\n // the union, and only `DataColumnImpl` implements it with a bare id.\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.fromAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.fromPlRef(rest);\n if (isPColumn(rest)) return DataColumnImpl.fromColumn(rest);\n throw new Error(\"DataColumn: unknown source shape\");\n}\n\n/**\n * Polymorphic counterpart to {@link DataColumnDispatch}: returns the\n * {@link ColumnResolutionStatus} for any factory input without constructing\n * the recipe. For already-materialised sources ({@link PColumn} value,\n * existing {@link DataColumnRecipe}) status is `present` by construction.\n */\nfunction DataColumnGetStatus(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n if (typeof source === \"string\") return DataColumnImpl.getStatusById(source, opts);\n if (source instanceof DataColumnImpl) return \"present\";\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.getStatusByAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.getStatusByPlRef(rest, opts);\n if (isPColumn(rest)) return \"present\";\n throw new Error(\"DataColumn.getStatus: unknown source shape\");\n}\n\nexport const DataColumn = Object.assign(DataColumnDispatch, {\n fromId: DataColumnImpl.fromId,\n fromPlRef: DataColumnImpl.fromPlRef,\n fromAccessor: DataColumnImpl.fromAccessor,\n fromColumn: DataColumnImpl.fromColumn,\n getStatus: DataColumnGetStatus,\n getStatusById: DataColumnImpl.getStatusById,\n getStatusByPlRef: DataColumnImpl.getStatusByPlRef,\n getStatusByAccessor: DataColumnImpl.getStatusByAccessor,\n});\n\n/**\n * Type-guard narrowing to a bare leaf — a {@link DataColumnRecipe} whose `id` is a\n * plain {@link PObjectId}.\n */\nexport function isDataColumn(value: unknown): value is DataColumnRecipe<PObjectId> {\n return value instanceof DataColumnImpl;\n}\n\nconst readSpecAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.spec`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\n/** The leaf's spec, or `undefined` until the spec resource has data. */\nconst readSpec = memoizeByEntry((entry: LeafEntry<TreeNodeAccessor>): undefined | PObjectSpec => {\n const spec = readSpecAccessor(entry);\n if (isNil(spec) || !spec.hasData()) return undefined;\n return spec.getDataAsJson<PObjectSpec>();\n});\n\n/**\n * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's\n * **spec** can be read in this ctx, and — for the negative cases —\n * distinguishes `resolving` from `absent` via `getInputsLocked()`.\n *\n * - spec field not yet on the entry's accessor + inputs locked → `absent`\n * - spec field not yet on the entry's accessor + still resolving → `resolving`\n * - spec resource present but bytes not yet written → `resolving`\n * (transient — the spec resource is connected, just unfilled)\n * - spec resource present and `hasData()` → `present`\n */\nfunction getLeafEntryStatus(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) return entry.accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n if (!spec.hasData()) return \"resolving\";\n return \"present\";\n}\n\nconst readDataAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.data`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\nconst readDataStatus = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): ColumnFieldStatus => {\n if (accessor.listInputFields().includes(`${name}.data`)) return \"present\";\n return accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n },\n);\n\nfunction memoizeByEntry<R>(\n fn: (entry: LeafEntry<TreeNodeAccessor>) => R,\n): (entry: LeafEntry<TreeNodeAccessor>) => R {\n const cache = new LRUCache<string, { value: R }>({ max: 1000 });\n return (entry) => {\n const key = `${entry.accessor.handle}:${entry.name}`;\n let hit = cache.get(key);\n if (!hit) cache.set(key, (hit = { value: fn(entry) }));\n return hit.value;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,IAAa,oBAAb,cAAuC,MAAM;CACf;CAA5B,YAAY,IAAuC;EACjD,MAAM,kEAAkE,IAAI;EADlD,KAAA,KAAA;EAE1B,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,IAAa,iBAAb,MAAa,eAAsD;CAM/C;CACC;CANnB;CACA;CACA;CAEA,YACE,IACA,SAKA;EANgB,KAAA,KAAA;EACC,KAAA,UAAA;CAKhB;;CAGH,mBAAgC;EAC9B,OAAO,CAAC,KAAK,EAAE;CACjB;CAEA,UAAuB;EACrB,IAAI,KAAK,cAAc,KAAA,GACrB,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;E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AAE,UAAU,WACX,SAAS,SAAS;CAAE,OAAO,GAAG,KAAK;CAAQ,iBAAiB;CAAS,aAAa;AAAK,CAAC,CAC5F;AAEA,MAAM,iBAAiB,gBACpB,EAAE,UAAU,WAA2D;CACtE,IAAI,SAAS,gBAAgB,CAAC,CAAC,SAAS,GAAG,KAAK,MAAM,GAAG,OAAO;CAChE,OAAO,SAAS,gBAAgB,IAAI,WAAW;AACjD,CACF;AAEA,SAAS,eACP,IAC2C;CAC3C,MAAM,QAAQ,IAAIK,UAAAA,SAA+B,EAAE,KAAK,IAAK,CAAC;CAC9D,QAAQ,UAAU;EAChB,MAAM,MAAM,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM;EAC9C,IAAI,MAAM,MAAM,IAAI,GAAG;EACvB,IAAI,CAAC,KAAK,MAAM,IAAI,KAAM,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,CAAE;EACrD,OAAO,IAAI;CACb;AACF"}
|
|
1
|
+
{"version":3,"file":"data_column.cjs","names":["ColumnOverriddenRecipe","ColumnRegistry","getCtxProviders","isNil","createGlobalPObjectId","isPColumnSpec","isPlRef","isPColumn","LRUCache"],"sources":["../../src/columns/data_column.ts"],"sourcesContent":["import {\n ColumnRegistry,\n createGlobalPObjectId,\n isPColumn,\n isPColumnSpec,\n isPlRef,\n PlRef,\n PObjectId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\n type PObjectSpec,\n type SpecOverrides,\n type SpecQuery,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCtxProviders } from \"./column_providers\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\nimport { TreeNodeAccessor } from \"../render\";\nimport type {\n ColumnFieldStatus,\n ColumnRecipe,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./column_recipes/types\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\n\nexport type DataColumnId = PObjectId;\nexport type ColumnData = undefined | PColumnDataUniversal;\nexport type { ColumnFieldStatus, ColumnResolutionStatus } from \"./column_recipes/types\";\n\n/**\n * A {@link ColumnRecipe} that can be read directly in the sandbox: its\n * {@link getData} is guaranteed to be consistent with {@link getSpec}.\n *\n * This is a *capability*, not a class. Only two recipe shapes carry it — a\n * bare leaf and a spec-override over a bare leaf — because those are the only\n * ones whose data still matches their spec. An axis-filtered recipe drops axes\n * from its spec while the underlying data keeps them, and a discovered recipe\n * only materialises after a join; neither can be read here, so neither\n * implements this interface.\n *\n * Narrow to it with `hasReachableData(recipe)` rather than testing for a concrete\n * class — which recipe classes exist is an implementation detail behind\n * `recipe.id`.\n */\nexport interface DataColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipe<ID> {\n /** Column data, consistent with {@link ColumnRecipe.getSpec}. */\n getData(): ColumnData;\n}\n\n/**\n * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare\n * {@link PObjectId} and whose readers are bound to a single tree-accessor\n * leaf. Layered encodings (Overridden / Discovered / Filtered) are reified\n * through their dedicated recipe classes and reference leaf columns by id.\n *\n * Internal — consumers hold the {@link DataColumnRecipe} interface and construct\n * through the {@link DataColumnRecipe} dispatcher.\n */\nexport class DataColumnImpl implements DataColumnRecipe<PObjectId> {\n private specCache?: { readonly value: PColumnSpec };\n private dataCache?: { readonly value: ColumnData };\n private dataStatusCache?: { readonly value: ColumnFieldStatus };\n\n private constructor(\n public readonly id: PObjectId,\n private readonly options: {\n getSpec: () => PColumnSpec;\n getData: () => ColumnData;\n getDataStatus: () => ColumnFieldStatus;\n },\n ) {}\n\n /** A leaf-recipe references exactly one column — its own id. */\n getReferencedIds(): PObjectId[] {\n return [this.id];\n }\n\n getSpec(): PColumnSpec {\n if (this.specCache === undefined) {\n this.specCache = { value: this.options.getSpec() };\n }\n return this.specCache.value;\n }\n\n /** Leaf-shaped — points straight at `this.id`. */\n getQuery(): SpecQuery {\n return { type: \"column\", column: this.id } as SpecQuery;\n }\n\n getData(): ColumnData {\n if (this.dataCache === undefined) this.dataCache = { value: this.options.getData() };\n return this.dataCache.value;\n }\n\n getDataStatus(): ColumnFieldStatus {\n if (this.dataStatusCache === undefined) {\n this.dataStatusCache = { value: this.options.getDataStatus() };\n }\n return this.dataStatusCache.value;\n }\n\n /**\n * Overlay overrides → produces a {@link ColumnOverriddenRecipe} wrapping\n * this leaf. The leaf itself stays bare (id remains a plain PObjectId);\n * layering lives entirely in the recipe wrappers.\n */\n withSpecs(overrides: SpecOverrides): ColumnRecipe {\n return ColumnOverriddenRecipe.wrap(this, overrides);\n }\n\n /**\n * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:\n * returns `undefined` unless the id names a column whose spec is readable in\n * this ctx — while it is resolving, when it is absent, and when the id names\n * an export that is not a column (a `kind: \"File\"` object, for example).\n * Data and dataStatus stay lazy.\n */\n static fromId(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): undefined | DataColumnRecipe<PObjectId> {\n const leaf = new ColumnRegistry(getCtxProviders({ ctx })).resolve(id);\n if (isNil(leaf)) return undefined;\n return DataColumnImpl.fromAccessor(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link fromId}. */\n static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId> {\n return DataColumnImpl.fromId(createGlobalPObjectId(ref.blockId, ref.name));\n }\n\n /**\n * Bind directly to an accessor-backed {@link LeafEntry} — no registry.\n * Returns `undefined` unless the leaf's spec is readable and is a column\n * spec: while the spec is resolving, when it is absent, and for an export\n * that is not a column.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n const spec = readSpec(entry);\n if (spec === undefined || !isPColumnSpec(spec)) return undefined;\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec,\n getData: () => readDataAccessor(entry),\n getDataStatus: () => readDataStatus(entry),\n });\n }\n\n /**\n * Wrap a materialised {@link PColumn}. If the input is already a\n * {@link DataColumnRecipe} leaf it is returned as-is.\n */\n static fromColumn(\n column: PColumn<ColumnData> | DataColumnRecipe<PObjectId>,\n ): DataColumnRecipe<PObjectId> {\n if (column instanceof DataColumnImpl) return column;\n // `DataColumnRecipe` is an interface, so `instanceof` above does not remove it\n // from the union. The only implementation carrying a bare `PObjectId` is\n // `DataColumnImpl` (wrappers expose `ColumnUniversalId`), so anything\n // reaching here is a materialised `PColumn`.\n const pColumn = column as PColumn<ColumnData>;\n return new DataColumnImpl(pColumn.id, {\n getSpec: () => pColumn.spec,\n getData: () => pColumn.data,\n getDataStatus: () => \"present\",\n });\n }\n\n /**\n * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}\n * in the active render ctx. Falls back to the registry's `isFinal()`\n * when the id has no entry — only then we can say `absent` instead of\n * `resolving`. The status tells only whether the spec is readable: for an\n * export that is not a column it is `present`, and the factories return\n * `undefined`.\n */\n static getStatusById(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) return registry.isFinal() ? \"absent\" : \"resolving\";\n return getLeafEntryStatus(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link getStatusById}. */\n static getStatusByPlRef(\n ref: PlRef,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n return DataColumnImpl.getStatusById(createGlobalPObjectId(ref.blockId, ref.name), opts);\n }\n\n /** No registry — reads straight off the entry's accessor. */\n static getStatusByAccessor(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n return getLeafEntryStatus(entry);\n }\n}\n\n/** Anything the {@link DataColumnRecipe} dispatcher can build a leaf from. */\nexport type DataColumnSource =\n | PObjectId\n | PlRef\n | LeafEntry<TreeNodeAccessor>\n | PColumn<ColumnData>\n | DataColumnRecipe<PObjectId>;\n\n/**\n * Unified dispatcher — picks the right `DataColumnImpl.fromX` by source\n * shape. For ambiguous inputs callers can still use the explicit factories\n * (also attached as properties: `DataColumn.fromId`, `.fromPlRef`,\n * `.fromAccessor`, `.fromColumn`).\n */\nfunction DataColumnDispatch(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | DataColumnRecipe<PObjectId> {\n if (typeof source === \"string\") return DataColumnImpl.fromId(source, opts);\n if (source instanceof DataColumnImpl) return source;\n // `DataColumnRecipe` is an interface — `instanceof` above cannot remove it from\n // the union, and only `DataColumnImpl` implements it with a bare id.\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.fromAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.fromPlRef(rest);\n if (isPColumn(rest)) return DataColumnImpl.fromColumn(rest);\n throw new Error(\"DataColumn: unknown source shape\");\n}\n\n/**\n * Polymorphic counterpart to {@link DataColumnDispatch}: returns the\n * {@link ColumnResolutionStatus} for any factory input without constructing\n * the recipe. For already-materialised sources ({@link PColumn} value,\n * existing {@link DataColumnRecipe}) status is `present` by construction.\n */\nfunction DataColumnGetStatus(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n if (typeof source === \"string\") return DataColumnImpl.getStatusById(source, opts);\n if (source instanceof DataColumnImpl) return \"present\";\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.getStatusByAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.getStatusByPlRef(rest, opts);\n if (isPColumn(rest)) return \"present\";\n throw new Error(\"DataColumn.getStatus: unknown source shape\");\n}\n\nexport const DataColumn = Object.assign(DataColumnDispatch, {\n fromId: DataColumnImpl.fromId,\n fromPlRef: DataColumnImpl.fromPlRef,\n fromAccessor: DataColumnImpl.fromAccessor,\n fromColumn: DataColumnImpl.fromColumn,\n getStatus: DataColumnGetStatus,\n getStatusById: DataColumnImpl.getStatusById,\n getStatusByPlRef: DataColumnImpl.getStatusByPlRef,\n getStatusByAccessor: DataColumnImpl.getStatusByAccessor,\n});\n\n/**\n * Type-guard narrowing to a bare leaf — a {@link DataColumnRecipe} whose `id` is a\n * plain {@link PObjectId}.\n */\nexport function isDataColumn(value: unknown): value is DataColumnRecipe<PObjectId> {\n return value instanceof DataColumnImpl;\n}\n\nconst readSpecAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.spec`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\n/** The leaf's spec, or `undefined` until the spec resource has data. */\nconst readSpec = memoizeByEntry((entry: LeafEntry<TreeNodeAccessor>): undefined | PObjectSpec => {\n const spec = readSpecAccessor(entry);\n if (isNil(spec) || !spec.hasData()) return undefined;\n return spec.getDataAsJson<PObjectSpec>();\n});\n\n/**\n * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's\n * **spec** can be read in this ctx, and — for the negative cases —\n * distinguishes `resolving` from `absent` via `getInputsLocked()`.\n *\n * - spec field not yet on the entry's accessor + inputs locked → `absent`\n * - spec field not yet on the entry's accessor + still resolving → `resolving`\n * - spec resource present but bytes not yet written → `resolving`\n * (transient — the spec resource is connected, just unfilled)\n * - spec resource present and `hasData()` → `present`\n */\nfunction getLeafEntryStatus(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) return entry.accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n if (!spec.hasData()) return \"resolving\";\n return \"present\";\n}\n\nconst readDataAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.data`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\nconst readDataStatus = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): ColumnFieldStatus => {\n if (accessor.listInputFields().includes(`${name}.data`)) return \"present\";\n return accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n },\n);\n\nfunction memoizeByEntry<R>(\n fn: (entry: LeafEntry<TreeNodeAccessor>) => R,\n): (entry: LeafEntry<TreeNodeAccessor>) => R {\n const cache = new LRUCache<string, { value: R }>({ max: 1000 });\n return (entry) => {\n const key = `${entry.accessor.handle}:${entry.name}`;\n let hit = cache.get(key);\n if (!hit) cache.set(key, (hit = { value: fn(entry) }));\n return hit.value;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+DA,IAAa,iBAAb,MAAa,eAAsD;CAM/C;CACC;CANnB;CACA;CACA;CAEA,YACE,IACA,SAKA;EANgB,KAAA,KAAA;EACC,KAAA,UAAA;CAKhB;;CAGH,mBAAgC;EAC9B,OAAO,CAAC,KAAK,EAAE;CACjB;CAEA,UAAuB;EACrB,IAAI,KAAK,cAAc,KAAA,GACrB,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EAEnD,OAAO,KAAK,UAAU;CACxB;;CAGA,WAAsB;EACpB,OAAO;GAAE,MAAM;GAAU,QAAQ,KAAK;EAAG;CAC3C;CAEA,UAAsB;EACpB,IAAI,KAAK,cAAc,KAAA,GAAW,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EACnF,OAAO,KAAK,UAAU;CACxB;CAEA,gBAAmC;EACjC,IAAI,KAAK,oBAAoB,KAAA,GAC3B,KAAK,kBAAkB,EAAE,OAAO,KAAK,QAAQ,cAAc,EAAE;EAE/D,OAAO,KAAK,gBAAgB;CAC9B;;;;;;CAOA,UAAU,WAAwC;EAChD,OAAOA,gCAAAA,uBAAuB,KAAK,MAAM,SAAS;CACpD;;;;;;;;CASA,OAAO,OACL,IACA,EAAE,QAAsC,CAAC,GACA;EACzC,MAAM,OAAO,IAAIC,gCAAAA,eAAeC,cAAAA,gBAAgB,EAAE,IAAI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iBAAiB,KAAK;CACnC,KAAA,GAAIJ,WAAAA,MAAAA,CAAM,IAAI,KAAK,CAAC,KAAK,QAAQ,GAAG,OAAO,KAAA;CAC3C,OAAO,KAAK,cAA2B;AACzC,CAAC;;;;;;;;;;;;AAaD,SAAS,mBAAmB,OAA4D;CACtF,MAAM,OAAO,iBAAiB,KAAK;CACnC,KAAA,GAAIA,WAAAA,MAAAA,CAAM,IAAI,GAAG,OAAO,MAAM,SAAS,gBAAgB,IAAI,WAAW;CACtE,IAAI,CAAC,KAAK,QAAQ,GAAG,OAAO;CAC5B,OAAO;AACT;AAEA,MAAM,mBAAmB,gBACtB,EAAE,UAAU,WACX,SAAS,SAAS;CAAE,OAAO,GAAG,KAAK;CAAQ,iBAAiB;CAAS,aAAa;AAAK,CAAC,CAC5F;AAEA,MAAM,iBAAiB,gBACpB,EAAE,UAAU,WAA2D;CACtE,IAAI,SAAS,gBAAgB,CAAC,CAAC,SAAS,GAAG,KAAK,MAAM,GAAG,OAAO;CAChE,OAAO,SAAS,gBAAgB,IAAI,WAAW;AACjD,CACF;AAEA,SAAS,eACP,IAC2C;CAC3C,MAAM,QAAQ,IAAIK,UAAAA,SAA+B,EAAE,KAAK,IAAK,CAAC;CAC9D,QAAQ,UAAU;EAChB,MAAM,MAAM,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM;EAC9C,IAAI,MAAM,MAAM,IAAI,GAAG;EACvB,IAAI,CAAC,KAAK,MAAM,IAAI,KAAM,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,CAAE;EACrD,OAAO,IAAI;CACb;AACF"}
|
|
@@ -2,7 +2,7 @@ import { GlobalCfgRenderCtx, PColumnDataUniversal } from "../render/internal.js"
|
|
|
2
2
|
import { TreeNodeAccessor } from "../render/accessor.js";
|
|
3
3
|
import "../render/index.js";
|
|
4
4
|
import { ColumnFieldStatus, ColumnRecipe, ColumnRecipeId, ColumnResolutionStatus } from "./column_recipes/types.js";
|
|
5
|
-
import {
|
|
5
|
+
import { LeafEntry, PColumn, PColumnSpec, PObjectId, PlRef, SpecOverrides, SpecQuery } from "@milaboratories/pl-model-common";
|
|
6
6
|
export type DataColumnId = PObjectId;
|
|
7
7
|
export type ColumnData = undefined | PColumnDataUniversal;
|
|
8
8
|
/**
|
|
@@ -24,21 +24,6 @@ export interface DataColumnRecipe<ID extends ColumnRecipeId = ColumnRecipeId> ex
|
|
|
24
24
|
/** Column data, consistent with {@link ColumnRecipe.getSpec}. */
|
|
25
25
|
getData(): ColumnData;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Thrown by leaf-recipe factories when the requested column is provably
|
|
29
|
-
* absent in the active render ctx — i.e. every relevant accessor reports
|
|
30
|
-
* `inputsLocked` and the column did not appear. Distinct from the
|
|
31
|
-
* `undefined` return that the factories still use for the "resolving" case
|
|
32
|
-
* (the column may still appear later).
|
|
33
|
-
*
|
|
34
|
-
* Catch at the boundary (resolver / filter+sort wiring / data-table assembly)
|
|
35
|
-
* when partial absence should be surfaced to the user rather than silently
|
|
36
|
-
* producing an empty result.
|
|
37
|
-
*/
|
|
38
|
-
export declare class ColumnAbsentError extends Error {
|
|
39
|
-
readonly id: ColumnUniversalId;
|
|
40
|
-
constructor(id: ColumnUniversalId);
|
|
41
|
-
}
|
|
42
27
|
/**
|
|
43
28
|
* The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare
|
|
44
29
|
* {@link PObjectId} and whose readers are bound to a single tree-accessor
|
|
@@ -70,11 +55,10 @@ export declare class DataColumnImpl implements DataColumnRecipe<PObjectId> {
|
|
|
70
55
|
withSpecs(overrides: SpecOverrides): ColumnRecipe;
|
|
71
56
|
/**
|
|
72
57
|
* Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:
|
|
73
|
-
* returns `undefined`
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* exist in this ctx. Data and dataStatus stay lazy.
|
|
58
|
+
* returns `undefined` unless the id names a column whose spec is readable in
|
|
59
|
+
* this ctx — while it is resolving, when it is absent, and when the id names
|
|
60
|
+
* an export that is not a column (a `kind: "File"` object, for example).
|
|
61
|
+
* Data and dataStatus stay lazy.
|
|
78
62
|
*/
|
|
79
63
|
static fromId(id: PObjectId, { ctx }?: {
|
|
80
64
|
ctx?: GlobalCfgRenderCtx;
|
|
@@ -83,9 +67,9 @@ export declare class DataColumnImpl implements DataColumnRecipe<PObjectId> {
|
|
|
83
67
|
static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId>;
|
|
84
68
|
/**
|
|
85
69
|
* Bind directly to an accessor-backed {@link LeafEntry} — no registry.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
70
|
+
* Returns `undefined` unless the leaf's spec is readable and is a column
|
|
71
|
+
* spec: while the spec is resolving, when it is absent, and for an export
|
|
72
|
+
* that is not a column.
|
|
89
73
|
*/
|
|
90
74
|
static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId>;
|
|
91
75
|
/**
|
|
@@ -98,8 +82,8 @@ export declare class DataColumnImpl implements DataColumnRecipe<PObjectId> {
|
|
|
98
82
|
* in the active render ctx. Falls back to the registry's `isFinal()`
|
|
99
83
|
* when the id has no entry — only then we can say `absent` instead of
|
|
100
84
|
* `resolving`. The status tells only whether the spec is readable: for an
|
|
101
|
-
* export that is not a column it is `present`, and the factories
|
|
102
|
-
*
|
|
85
|
+
* export that is not a column it is `present`, and the factories return
|
|
86
|
+
* `undefined`.
|
|
103
87
|
*/
|
|
104
88
|
static getStatusById(id: PObjectId, { ctx }?: {
|
|
105
89
|
ctx?: GlobalCfgRenderCtx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_column.d.ts","names":[],"sources":["../../src/columns/data_column.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"data_column.d.ts","names":[],"sources":["../../src/columns/data_column.ts"],"mappings":";;;;;YA4BY,eAAe;YACf,yBAAyB;;;;;;;;;;;;;;;;iBAkBpB,iBACf,WAAW,iBAAiB,wBACpB,aAAa;;EAErB,WAAW;;;;;;;;;;;qBAYA,0BAA0B,iBAAiB;WAMpC,IAAI;mBACH;UANX;UACA;UACA;UAED;;EAUP,oBAAoB;EAIpB,WAAW;;EAQX,YAAY;EAIZ,WAAW;EAKX,iBAAiB;;;;;;EAYjB,UAAU,WAAW,gBAAgB;;;;;;;;SAW9B,OACL,IAAI,aACF;IAAS,MAAM;kBACJ,iBAAiB;;SAOzB,UAAU,KAAK,oBAAoB,iBAAiB;;;;;;;SAUpD,aAAa,OAAO,UAAU,gCAAgC,iBAAiB;;;;;SAc/E,WACL,QAAQ,QAAQ,cAAc,iBAAiB,aAC9C,iBAAiB;;;;;;;;;SAsBb,cACL,IAAI,aACF;IAAS,MAAM;MAChB;;SAQI,iBACL,KAAK,OACL;IAAQ,MAAM;MACb;;SAKI,oBAAoB,OAAO,UAAU,oBAAoB;;;YAMtD,mBACR,YACA,QACA,UAAU,oBACV,QAAQ,cACR,iBAAiB;;;;;;;iBAQZ,mBACP,QAAQ,kBACR;EAAQ,MAAM;gBACD,iBAAiB;;;;;;;iBAkBvB,oBACP,QAAQ,kBACR;EAAQ,MAAM;IACb;qBAUU,mBAAU;;;;;;;;;;;;;;wBAeP,aAAa,iBAAiB,SAAS,iBAAiB"}
|