@platforma-sdk/model 1.59.3 → 1.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +1 -11
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/columns/column_collection_builder.cjs +215 -0
- package/dist/columns/column_collection_builder.cjs.map +1 -0
- package/dist/columns/column_collection_builder.d.ts +112 -0
- package/dist/columns/column_collection_builder.js +214 -0
- package/dist/columns/column_collection_builder.js.map +1 -0
- package/dist/columns/column_selector.cjs +122 -0
- package/dist/columns/column_selector.cjs.map +1 -0
- package/dist/columns/column_selector.d.ts +41 -0
- package/dist/columns/column_selector.js +118 -0
- package/dist/columns/column_selector.js.map +1 -0
- package/dist/columns/column_snapshot.cjs +20 -0
- package/dist/columns/column_snapshot.cjs.map +1 -0
- package/dist/columns/column_snapshot.d.ts +39 -0
- package/dist/columns/column_snapshot.js +18 -0
- package/dist/columns/column_snapshot.js.map +1 -0
- package/dist/columns/column_snapshot_provider.cjs +112 -0
- package/dist/columns/column_snapshot_provider.cjs.map +1 -0
- package/dist/columns/column_snapshot_provider.d.ts +73 -0
- package/dist/columns/column_snapshot_provider.js +107 -0
- package/dist/columns/column_snapshot_provider.js.map +1 -0
- package/dist/columns/ctx_column_sources.cjs +84 -0
- package/dist/columns/ctx_column_sources.cjs.map +1 -0
- package/dist/columns/ctx_column_sources.d.ts +33 -0
- package/dist/columns/ctx_column_sources.js +82 -0
- package/dist/columns/ctx_column_sources.js.map +1 -0
- package/dist/columns/index.cjs +5 -0
- package/dist/columns/index.d.ts +5 -0
- package/dist/columns/index.js +5 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +111 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts +25 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +110 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -0
- package/dist/components/PlDataTable/{table.cjs → createPlDataTable/createPlDataTableV3.cjs} +54 -54
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +39 -0
- package/dist/components/PlDataTable/{table.js → createPlDataTable/createPlDataTableV3.js} +53 -53
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/index.cjs +12 -0
- package/dist/components/PlDataTable/createPlDataTable/index.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts +15 -0
- package/dist/components/PlDataTable/createPlDataTable/index.js +12 -0
- package/dist/components/PlDataTable/createPlDataTable/index.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs +18 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.d.ts +11 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.js +17 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.js.map +1 -0
- package/dist/components/PlDataTable/index.cjs +4 -1
- package/dist/components/PlDataTable/index.d.ts +5 -2
- package/dist/components/PlDataTable/index.js +4 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +2 -2
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/{v4.d.ts → typesV4.d.ts} +2 -2
- package/dist/components/PlDataTable/{v5.d.ts → typesV5.d.ts} +2 -2
- package/dist/components/index.cjs +4 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +4 -1
- package/dist/index.cjs +44 -16
- package/dist/index.d.ts +17 -5
- package/dist/index.js +15 -3
- package/dist/labels/derive_distinct_labels.cjs +156 -0
- package/dist/labels/derive_distinct_labels.cjs.map +1 -0
- package/dist/labels/derive_distinct_labels.d.ts +29 -0
- package/dist/labels/derive_distinct_labels.js +155 -0
- package/dist/labels/derive_distinct_labels.js.map +1 -0
- package/dist/labels/index.cjs +2 -0
- package/dist/labels/index.d.ts +2 -0
- package/dist/labels/index.js +2 -0
- package/dist/labels/write_labels_to_specs.cjs +15 -0
- package/dist/labels/write_labels_to_specs.cjs.map +1 -0
- package/dist/labels/write_labels_to_specs.d.ts +9 -0
- package/dist/labels/write_labels_to_specs.js +14 -0
- package/dist/labels/write_labels_to_specs.js.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/render/api.cjs +11 -2
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +9 -5
- package/dist/render/api.js +12 -3
- package/dist/render/api.js.map +1 -1
- package/dist/render/index.d.ts +2 -1
- package/dist/render/index.js +1 -1
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +5 -2
- package/dist/render/internal.js.map +1 -1
- package/dist/render/util/column_collection.cjs +3 -3
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +3 -2
- package/dist/render/util/column_collection.js +4 -4
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.d.ts +2 -1
- package/dist/render/util/index.js +1 -1
- package/dist/render/util/label.cjs +7 -134
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +5 -50
- package/dist/render/util/label.js +8 -132
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +2 -2
- package/package.json +9 -7
- package/src/block_storage.ts +0 -11
- package/src/block_storage_callbacks.ts +1 -1
- package/src/columns/column_collection_builder.test.ts +427 -0
- package/src/columns/column_collection_builder.ts +455 -0
- package/src/columns/column_selector.test.ts +472 -0
- package/src/columns/column_selector.ts +212 -0
- package/src/columns/column_snapshot.ts +55 -0
- package/src/columns/column_snapshot_provider.ts +177 -0
- package/src/columns/ctx_column_sources.ts +107 -0
- package/src/columns/expand_by_partition.test.ts +289 -0
- package/src/columns/expand_by_partition.ts +187 -0
- package/src/columns/index.ts +5 -0
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +193 -0
- package/src/components/PlDataTable/{table.ts → createPlDataTable/createPlDataTableV3.ts} +134 -70
- package/src/components/PlDataTable/createPlDataTable/index.ts +27 -0
- package/src/components/PlDataTable/createPlDataTableSheet.ts +20 -0
- package/src/components/PlDataTable/index.ts +6 -4
- package/src/components/PlDataTable/state-migration.ts +2 -2
- package/src/index.ts +2 -1
- package/src/labels/derive_distinct_labels.test.ts +461 -0
- package/src/labels/derive_distinct_labels.ts +289 -0
- package/src/labels/index.ts +2 -0
- package/src/labels/write_labels_to_specs.ts +12 -0
- package/src/render/api.ts +25 -3
- package/src/render/internal.ts +20 -1
- package/src/render/util/column_collection.ts +9 -6
- package/src/render/util/label.test.ts +1 -1
- package/src/render/util/label.ts +19 -235
- package/src/render/util/split_selectors.ts +3 -3
- package/dist/components/PlDataTable/table.cjs.map +0 -1
- package/dist/components/PlDataTable/table.d.ts +0 -30
- package/dist/components/PlDataTable/table.js.map +0 -1
- /package/src/components/PlDataTable/{v4.ts → typesV4.ts} +0 -0
- /package/src/components/PlDataTable/{v5.ts → typesV5.ts} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/columns/column_selector.ts
|
|
2
|
+
function normalizeStringMatchers(input) {
|
|
3
|
+
if (typeof input === "string") return [{
|
|
4
|
+
type: "regex",
|
|
5
|
+
value: input
|
|
6
|
+
}];
|
|
7
|
+
if (!Array.isArray(input)) return [input];
|
|
8
|
+
return input.map((v) => typeof v === "string" ? {
|
|
9
|
+
type: "regex",
|
|
10
|
+
value: v
|
|
11
|
+
} : v);
|
|
12
|
+
}
|
|
13
|
+
function normalizeRecord(input) {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const [key, value] of Object.entries(input)) result[key] = normalizeStringMatchers(value);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
function normalizeTypes(input) {
|
|
19
|
+
return Array.isArray(input) ? input : [input];
|
|
20
|
+
}
|
|
21
|
+
function normalizeAxisSelector(input) {
|
|
22
|
+
const result = {};
|
|
23
|
+
if (input.name !== void 0) result.name = normalizeStringMatchers(input.name);
|
|
24
|
+
if (input.type !== void 0) result.type = normalizeTypes(input.type);
|
|
25
|
+
if (input.domain !== void 0) result.domain = normalizeRecord(input.domain);
|
|
26
|
+
if (input.contextDomain !== void 0) result.contextDomain = normalizeRecord(input.contextDomain);
|
|
27
|
+
if (input.annotations !== void 0) result.annotations = normalizeRecord(input.annotations);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/** Normalize relaxed input to strict ColumnSelector[]. */
|
|
31
|
+
function normalizeSelectors(input) {
|
|
32
|
+
return (Array.isArray(input) ? input : [input]).map(normalizeSingleSelector);
|
|
33
|
+
}
|
|
34
|
+
function normalizeSingleSelector(input) {
|
|
35
|
+
const result = {};
|
|
36
|
+
if (input.name !== void 0) result.name = normalizeStringMatchers(input.name);
|
|
37
|
+
if (input.type !== void 0) result.type = normalizeTypes(input.type);
|
|
38
|
+
if (input.domain !== void 0) result.domain = normalizeRecord(input.domain);
|
|
39
|
+
if (input.contextDomain !== void 0) result.contextDomain = normalizeRecord(input.contextDomain);
|
|
40
|
+
if (input.annotations !== void 0) result.annotations = normalizeRecord(input.annotations);
|
|
41
|
+
if (input.axes !== void 0) result.axes = input.axes.map(normalizeAxisSelector);
|
|
42
|
+
if (input.partialAxesMatch !== void 0) result.partialAxesMatch = input.partialAxesMatch;
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function matchStringValue(value, matchers) {
|
|
46
|
+
return matchers.some((m) => {
|
|
47
|
+
if (m.type === "exact") return value === m.value;
|
|
48
|
+
return new RegExp(`^(?:${m.value})$`).test(value);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function matchRecordField(actual, required) {
|
|
52
|
+
const record = actual ?? {};
|
|
53
|
+
for (const [key, matchers] of Object.entries(required)) {
|
|
54
|
+
const value = record[key];
|
|
55
|
+
if (value === void 0) return false;
|
|
56
|
+
if (!matchStringValue(value, matchers)) return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/** Get combined domain: column's own domain merged with all axis domains. */
|
|
61
|
+
function getCombinedDomain(spec) {
|
|
62
|
+
const result = {};
|
|
63
|
+
if (spec.domain) Object.assign(result, spec.domain);
|
|
64
|
+
for (const axis of spec.axesSpec) if (axis.domain) Object.assign(result, axis.domain);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
/** Get combined context domain: column's own contextDomain merged with all axis contextDomains. */
|
|
68
|
+
function getCombinedContextDomain(spec) {
|
|
69
|
+
const result = {};
|
|
70
|
+
if (spec.contextDomain) Object.assign(result, spec.contextDomain);
|
|
71
|
+
for (const axis of spec.axesSpec) if ("contextDomain" in axis && axis.contextDomain) Object.assign(result, axis.contextDomain);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
function matchAxisSelector(axis, selector) {
|
|
75
|
+
if (selector.name !== void 0 && !matchStringValue(axis.name, selector.name)) return false;
|
|
76
|
+
if (selector.type !== void 0 && !selector.type.includes(axis.type)) return false;
|
|
77
|
+
if (selector.domain !== void 0 && !matchRecordField(axis.domain, selector.domain)) return false;
|
|
78
|
+
if (selector.contextDomain !== void 0 && !matchRecordField("contextDomain" in axis ? axis.contextDomain : void 0, selector.contextDomain)) return false;
|
|
79
|
+
if (selector.annotations !== void 0 && !matchRecordField(axis.annotations, selector.annotations)) return false;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/** Check if a PColumnSpec matches a single strict ColumnSelector. */
|
|
83
|
+
function matchColumn(spec, selector) {
|
|
84
|
+
if (selector.name !== void 0 && !matchStringValue(spec.name, selector.name)) return false;
|
|
85
|
+
if (selector.type !== void 0 && !selector.type.includes(spec.valueType)) return false;
|
|
86
|
+
if (selector.domain !== void 0) {
|
|
87
|
+
if (!matchRecordField(getCombinedDomain(spec), selector.domain)) return false;
|
|
88
|
+
}
|
|
89
|
+
if (selector.contextDomain !== void 0) {
|
|
90
|
+
if (!matchRecordField(getCombinedContextDomain(spec), selector.contextDomain)) return false;
|
|
91
|
+
}
|
|
92
|
+
if (selector.annotations !== void 0) {
|
|
93
|
+
if (!matchRecordField(spec.annotations, selector.annotations)) return false;
|
|
94
|
+
}
|
|
95
|
+
if (selector.axes !== void 0) if (selector.partialAxesMatch ?? true) {
|
|
96
|
+
for (const axisSel of selector.axes) if (!spec.axesSpec.some((axis) => matchAxisSelector(axis, axisSel))) return false;
|
|
97
|
+
} else {
|
|
98
|
+
if (spec.axesSpec.length !== selector.axes.length) return false;
|
|
99
|
+
for (let i = 0; i < selector.axes.length; i++) if (!matchAxisSelector(spec.axesSpec[i], selector.axes[i])) return false;
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
/** Check if a PColumnSpec matches any of the selectors (OR across array). */
|
|
104
|
+
function matchColumnSelectors(selectors, spec) {
|
|
105
|
+
return selectors.some((sel) => matchColumn(spec, sel));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Convert selector input to a predicate function.
|
|
109
|
+
* Normalizes relaxed form, then returns a function that OR-matches.
|
|
110
|
+
*/
|
|
111
|
+
function columnSelectorsToPredicate(input) {
|
|
112
|
+
const selectors = normalizeSelectors(input);
|
|
113
|
+
return (spec) => matchColumnSelectors(selectors, spec);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
export { columnSelectorsToPredicate, matchColumn, matchColumnSelectors, normalizeSelectors };
|
|
118
|
+
//# sourceMappingURL=column_selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_selector.js","names":[],"sources":["../../src/columns/column_selector.ts"],"sourcesContent":["import type {\n MultiAxisSelector,\n MultiColumnSelector,\n PColumnSpec,\n StringMatcher,\n ValueType,\n} from \"@milaboratories/pl-model-common\";\n\nexport type { StringMatcher } from \"@milaboratories/pl-model-common\";\n\n// --- Relaxed types ---\n\n/** Relaxed string matcher input: plain string, single matcher, or array of mixed. */\nexport type RelaxedStringMatchers = string | StringMatcher | (string | StringMatcher)[];\n\n/** Relaxed record matcher: values can be plain strings or relaxed matchers. */\nexport type RelaxedRecord = Record<string, RelaxedStringMatchers>;\n\n/** Relaxed axis selector — accepts plain strings where strict requires StringMatcher[]. */\nexport interface RelaxedAxisSelector {\n name?: RelaxedStringMatchers;\n type?: ValueType | ValueType[];\n domain?: RelaxedRecord;\n contextDomain?: RelaxedRecord;\n annotations?: RelaxedRecord;\n}\n\n/** Relaxed column selector — convenient hand-written form. */\nexport interface RelaxedColumnSelector {\n name?: RelaxedStringMatchers;\n type?: ValueType | ValueType[];\n domain?: RelaxedRecord;\n contextDomain?: RelaxedRecord;\n annotations?: RelaxedRecord;\n axes?: RelaxedAxisSelector[];\n partialAxesMatch?: boolean;\n}\n\n/** Input that normalizes to ColumnSelector[]. */\nexport type ColumnSelectorInput = RelaxedColumnSelector | RelaxedColumnSelector[];\n\n// --- Normalization ---\n\nfunction normalizeStringMatchers(input: RelaxedStringMatchers): StringMatcher[] {\n if (typeof input === \"string\") return [{ type: \"regex\", value: input }];\n if (!Array.isArray(input)) return [input];\n return input.map((v) =>\n typeof v === \"string\" ? ({ type: \"regex\", value: v } satisfies StringMatcher) : v,\n );\n}\n\nfunction normalizeRecord(input: RelaxedRecord): Record<string, StringMatcher[]> {\n const result: Record<string, StringMatcher[]> = {};\n for (const [key, value] of Object.entries(input)) {\n result[key] = normalizeStringMatchers(value);\n }\n return result;\n}\n\nfunction normalizeTypes(input: ValueType | ValueType[]): ValueType[] {\n return Array.isArray(input) ? input : [input];\n}\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\nfunction normalizeAxisSelector(input: RelaxedAxisSelector): MultiAxisSelector {\n const result: Mutable<MultiAxisSelector> = {};\n if (input.name !== undefined) result.name = normalizeStringMatchers(input.name);\n if (input.type !== undefined) result.type = normalizeTypes(input.type);\n if (input.domain !== undefined) result.domain = normalizeRecord(input.domain);\n if (input.contextDomain !== undefined)\n result.contextDomain = normalizeRecord(input.contextDomain);\n if (input.annotations !== undefined) result.annotations = normalizeRecord(input.annotations);\n return result;\n}\n\n/** Normalize relaxed input to strict ColumnSelector[]. */\nexport function normalizeSelectors(input: ColumnSelectorInput): MultiColumnSelector[] {\n const arr = Array.isArray(input) ? input : [input];\n return arr.map(normalizeSingleSelector);\n}\n\nfunction normalizeSingleSelector(input: RelaxedColumnSelector): MultiColumnSelector {\n const result: Mutable<MultiColumnSelector> = {};\n if (input.name !== undefined) result.name = normalizeStringMatchers(input.name);\n if (input.type !== undefined) result.type = normalizeTypes(input.type);\n if (input.domain !== undefined) result.domain = normalizeRecord(input.domain);\n if (input.contextDomain !== undefined)\n result.contextDomain = normalizeRecord(input.contextDomain);\n if (input.annotations !== undefined) result.annotations = normalizeRecord(input.annotations);\n if (input.axes !== undefined) result.axes = input.axes.map(normalizeAxisSelector);\n if (input.partialAxesMatch !== undefined) result.partialAxesMatch = input.partialAxesMatch;\n return result;\n}\n\n// --- Matching ---\n\nfunction matchStringValue(value: string, matchers: StringMatcher[]): boolean {\n return matchers.some((m) => {\n if (m.type === \"exact\") return value === m.value;\n return new RegExp(`^(?:${m.value})$`).test(value);\n });\n}\n\nfunction matchRecordField(\n actual: Record<string, string> | undefined,\n required: Record<string, StringMatcher[]>,\n): boolean {\n const record = actual ?? {};\n for (const [key, matchers] of Object.entries(required)) {\n const value = record[key];\n if (value === undefined) return false;\n if (!matchStringValue(value, matchers)) return false;\n }\n return true;\n}\n\n/** Get combined domain: column's own domain merged with all axis domains. */\nfunction getCombinedDomain(spec: PColumnSpec): Record<string, string> {\n const result: Record<string, string> = {};\n if (spec.domain) Object.assign(result, spec.domain);\n for (const axis of spec.axesSpec) {\n if (axis.domain) Object.assign(result, axis.domain);\n }\n return result;\n}\n\n/** Get combined context domain: column's own contextDomain merged with all axis contextDomains. */\nfunction getCombinedContextDomain(spec: PColumnSpec): Record<string, string> {\n const result: Record<string, string> = {};\n if (spec.contextDomain) Object.assign(result, spec.contextDomain);\n for (const axis of spec.axesSpec) {\n if (\"contextDomain\" in axis && axis.contextDomain) Object.assign(result, axis.contextDomain);\n }\n return result;\n}\n\nfunction matchAxisSelector(\n axis: PColumnSpec[\"axesSpec\"][number],\n selector: MultiAxisSelector,\n): boolean {\n if (selector.name !== undefined && !matchStringValue(axis.name, selector.name)) return false;\n if (selector.type !== undefined && !selector.type.includes(axis.type as ValueType)) return false;\n if (selector.domain !== undefined && !matchRecordField(axis.domain, selector.domain))\n return false;\n if (\n selector.contextDomain !== undefined &&\n !matchRecordField(\n \"contextDomain\" in axis ? (axis.contextDomain as Record<string, string>) : undefined,\n selector.contextDomain,\n )\n )\n return false;\n if (\n selector.annotations !== undefined &&\n !matchRecordField(axis.annotations, selector.annotations)\n )\n return false;\n return true;\n}\n\n/** Check if a PColumnSpec matches a single strict ColumnSelector. */\nexport function matchColumn(spec: PColumnSpec, selector: MultiColumnSelector): boolean {\n if (selector.name !== undefined && !matchStringValue(spec.name, selector.name)) return false;\n if (selector.type !== undefined && !selector.type.includes(spec.valueType)) return false;\n\n if (selector.domain !== undefined) {\n const combined = getCombinedDomain(spec);\n if (!matchRecordField(combined, selector.domain)) return false;\n }\n\n if (selector.contextDomain !== undefined) {\n const combined = getCombinedContextDomain(spec);\n if (!matchRecordField(combined, selector.contextDomain)) return false;\n }\n\n if (selector.annotations !== undefined) {\n if (!matchRecordField(spec.annotations, selector.annotations)) return false;\n }\n\n if (selector.axes !== undefined) {\n const partialMatch = selector.partialAxesMatch ?? true;\n if (partialMatch) {\n for (const axisSel of selector.axes) {\n if (!spec.axesSpec.some((axis) => matchAxisSelector(axis, axisSel))) return false;\n }\n } else {\n if (spec.axesSpec.length !== selector.axes.length) return false;\n for (let i = 0; i < selector.axes.length; i++) {\n if (!matchAxisSelector(spec.axesSpec[i], selector.axes[i])) return false;\n }\n }\n }\n\n return true;\n}\n\n/** Check if a PColumnSpec matches any of the selectors (OR across array). */\nexport function matchColumnSelectors(selectors: MultiColumnSelector[], spec: PColumnSpec): boolean {\n return selectors.some((sel) => matchColumn(spec, sel));\n}\n\n/**\n * Convert selector input to a predicate function.\n * Normalizes relaxed form, then returns a function that OR-matches.\n */\nexport function columnSelectorsToPredicate(\n input: ColumnSelectorInput,\n): (spec: PColumnSpec) => boolean {\n const selectors = normalizeSelectors(input);\n return (spec) => matchColumnSelectors(selectors, spec);\n}\n"],"mappings":";AA2CA,SAAS,wBAAwB,OAA+C;AAC9E,KAAI,OAAO,UAAU,SAAU,QAAO,CAAC;EAAE,MAAM;EAAS,OAAO;EAAO,CAAC;AACvE,KAAI,CAAC,MAAM,QAAQ,MAAM,CAAE,QAAO,CAAC,MAAM;AACzC,QAAO,MAAM,KAAK,MAChB,OAAO,MAAM,WAAY;EAAE,MAAM;EAAS,OAAO;EAAG,GAA4B,EACjF;;AAGH,SAAS,gBAAgB,OAAuD;CAC9E,MAAM,SAA0C,EAAE;AAClD,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,QAAO,OAAO,wBAAwB,MAAM;AAE9C,QAAO;;AAGT,SAAS,eAAe,OAA6C;AACnE,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;;AAK/C,SAAS,sBAAsB,OAA+C;CAC5E,MAAM,SAAqC,EAAE;AAC7C,KAAI,MAAM,SAAS,OAAW,QAAO,OAAO,wBAAwB,MAAM,KAAK;AAC/E,KAAI,MAAM,SAAS,OAAW,QAAO,OAAO,eAAe,MAAM,KAAK;AACtE,KAAI,MAAM,WAAW,OAAW,QAAO,SAAS,gBAAgB,MAAM,OAAO;AAC7E,KAAI,MAAM,kBAAkB,OAC1B,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lE,KAAI,SAAS,gBAAgB,QAC3B;MAAI,CAAC,iBAAiB,KAAK,aAAa,SAAS,YAAY,CAAE,QAAO;;AAGxE,KAAI,SAAS,SAAS,OAEpB,KADqB,SAAS,oBAAoB,MAEhD;OAAK,MAAM,WAAW,SAAS,KAC7B,KAAI,CAAC,KAAK,SAAS,MAAM,SAAS,kBAAkB,MAAM,QAAQ,CAAC,CAAE,QAAO;QAEzE;AACL,MAAI,KAAK,SAAS,WAAW,SAAS,KAAK,OAAQ,QAAO;AAC1D,OAAK,IAAI,IAAI,GAAG,IAAI,SAAS,KAAK,QAAQ,IACxC,KAAI,CAAC,kBAAkB,KAAK,SAAS,IAAI,SAAS,KAAK,GAAG,CAAE,QAAO;;AAKzE,QAAO;;;AAIT,SAAgB,qBAAqB,WAAkC,MAA4B;AACjG,QAAO,UAAU,MAAM,QAAQ,YAAY,MAAM,IAAI,CAAC;;;;;;AAOxD,SAAgB,2BACd,OACgC;CAChC,MAAM,YAAY,mBAAmB,MAAM;AAC3C,SAAQ,SAAS,qBAAqB,WAAW,KAAK"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/columns/column_snapshot.ts
|
|
3
|
+
/** Creates a ColumnData active object for a ready column. */
|
|
4
|
+
function createReadyColumnData(getData) {
|
|
5
|
+
return { get: getData };
|
|
6
|
+
}
|
|
7
|
+
/** Creates a ColumnSnapshot from parts. */
|
|
8
|
+
function createColumnSnapshot(id, spec, dataStatus, data) {
|
|
9
|
+
return {
|
|
10
|
+
id,
|
|
11
|
+
spec,
|
|
12
|
+
dataStatus,
|
|
13
|
+
data
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.createColumnSnapshot = createColumnSnapshot;
|
|
19
|
+
exports.createReadyColumnData = createReadyColumnData;
|
|
20
|
+
//# sourceMappingURL=column_snapshot.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_snapshot.cjs","names":[],"sources":["../../src/columns/column_snapshot.ts"],"sourcesContent":["import type { PColumnSpec, PObjectId } from \"@milaboratories/pl-model-common\";\nimport type { PColumnDataUniversal } from \"../render/internal\";\n\n// --- ColumnSnapshot ---\n\n/** Data status of a column snapshot. */\nexport type ColumnDataStatus = \"ready\" | \"computing\" | \"absent\";\n\n/**\n * Immutable snapshot of a column: spec, data status, and lazy data accessor.\n *\n * - `dataStatus` is readable without marking the render context unstable.\n * - `data` holds an active object when data exists (ready or computing),\n * or `undefined` when data is permanently absent.\n */\nexport interface ColumnSnapshot<Id extends PObjectId = PObjectId> {\n readonly id: Id;\n readonly spec: PColumnSpec;\n readonly dataStatus: ColumnDataStatus;\n\n /**\n * Lazy data accessor.\n * - `'ready'`: `data.get()` returns column data, context stays stable.\n * - `'computing'`: `data.get()` returns `undefined`, marks context unstable.\n * - `'absent'`: `data` is `undefined` — no active object, no instability.\n */\n readonly data: ColumnData | undefined;\n}\n\n// --- ColumnData ---\n\n/**\n * Active object wrapping lazy column data access.\n * Accessing data on a computing column marks the render context unstable.\n */\nexport interface ColumnData {\n get(): PColumnDataUniversal | undefined;\n}\n\n/** Creates a ColumnData active object for a ready column. */\nexport function createReadyColumnData(getData: () => PColumnDataUniversal | undefined): ColumnData {\n return { get: getData };\n}\n\n// --- Snapshot construction helpers ---\n\n/** Creates a ColumnSnapshot from parts. */\nexport function createColumnSnapshot<Id extends PObjectId = PObjectId>(\n id: Id,\n spec: PColumnSpec,\n dataStatus: ColumnDataStatus,\n data: ColumnData | undefined,\n): ColumnSnapshot<Id> {\n return { id, spec, dataStatus, data };\n}\n"],"mappings":";;;AAwCA,SAAgB,sBAAsB,SAA6D;AACjG,QAAO,EAAE,KAAK,SAAS;;;AAMzB,SAAgB,qBACd,IACA,MACA,YACA,MACoB;AACpB,QAAO;EAAE;EAAI;EAAM;EAAY;EAAM"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PColumnDataUniversal } from "../render/internal.js";
|
|
2
|
+
import { PColumnSpec, PObjectId } from "@milaboratories/pl-model-common";
|
|
3
|
+
|
|
4
|
+
//#region src/columns/column_snapshot.d.ts
|
|
5
|
+
/** Data status of a column snapshot. */
|
|
6
|
+
type ColumnDataStatus = "ready" | "computing" | "absent";
|
|
7
|
+
/**
|
|
8
|
+
* Immutable snapshot of a column: spec, data status, and lazy data accessor.
|
|
9
|
+
*
|
|
10
|
+
* - `dataStatus` is readable without marking the render context unstable.
|
|
11
|
+
* - `data` holds an active object when data exists (ready or computing),
|
|
12
|
+
* or `undefined` when data is permanently absent.
|
|
13
|
+
*/
|
|
14
|
+
interface ColumnSnapshot<Id extends PObjectId = PObjectId> {
|
|
15
|
+
readonly id: Id;
|
|
16
|
+
readonly spec: PColumnSpec;
|
|
17
|
+
readonly dataStatus: ColumnDataStatus;
|
|
18
|
+
/**
|
|
19
|
+
* Lazy data accessor.
|
|
20
|
+
* - `'ready'`: `data.get()` returns column data, context stays stable.
|
|
21
|
+
* - `'computing'`: `data.get()` returns `undefined`, marks context unstable.
|
|
22
|
+
* - `'absent'`: `data` is `undefined` — no active object, no instability.
|
|
23
|
+
*/
|
|
24
|
+
readonly data: ColumnData | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Active object wrapping lazy column data access.
|
|
28
|
+
* Accessing data on a computing column marks the render context unstable.
|
|
29
|
+
*/
|
|
30
|
+
interface ColumnData {
|
|
31
|
+
get(): PColumnDataUniversal | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Creates a ColumnData active object for a ready column. */
|
|
34
|
+
declare function createReadyColumnData(getData: () => PColumnDataUniversal | undefined): ColumnData;
|
|
35
|
+
/** Creates a ColumnSnapshot from parts. */
|
|
36
|
+
declare function createColumnSnapshot<Id extends PObjectId = PObjectId>(id: Id, spec: PColumnSpec, dataStatus: ColumnDataStatus, data: ColumnData | undefined): ColumnSnapshot<Id>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ColumnData, ColumnDataStatus, ColumnSnapshot, createColumnSnapshot, createReadyColumnData };
|
|
39
|
+
//# sourceMappingURL=column_snapshot.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/columns/column_snapshot.ts
|
|
2
|
+
/** Creates a ColumnData active object for a ready column. */
|
|
3
|
+
function createReadyColumnData(getData) {
|
|
4
|
+
return { get: getData };
|
|
5
|
+
}
|
|
6
|
+
/** Creates a ColumnSnapshot from parts. */
|
|
7
|
+
function createColumnSnapshot(id, spec, dataStatus, data) {
|
|
8
|
+
return {
|
|
9
|
+
id,
|
|
10
|
+
spec,
|
|
11
|
+
dataStatus,
|
|
12
|
+
data
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createColumnSnapshot, createReadyColumnData };
|
|
18
|
+
//# sourceMappingURL=column_snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_snapshot.js","names":[],"sources":["../../src/columns/column_snapshot.ts"],"sourcesContent":["import type { PColumnSpec, PObjectId } from \"@milaboratories/pl-model-common\";\nimport type { PColumnDataUniversal } from \"../render/internal\";\n\n// --- ColumnSnapshot ---\n\n/** Data status of a column snapshot. */\nexport type ColumnDataStatus = \"ready\" | \"computing\" | \"absent\";\n\n/**\n * Immutable snapshot of a column: spec, data status, and lazy data accessor.\n *\n * - `dataStatus` is readable without marking the render context unstable.\n * - `data` holds an active object when data exists (ready or computing),\n * or `undefined` when data is permanently absent.\n */\nexport interface ColumnSnapshot<Id extends PObjectId = PObjectId> {\n readonly id: Id;\n readonly spec: PColumnSpec;\n readonly dataStatus: ColumnDataStatus;\n\n /**\n * Lazy data accessor.\n * - `'ready'`: `data.get()` returns column data, context stays stable.\n * - `'computing'`: `data.get()` returns `undefined`, marks context unstable.\n * - `'absent'`: `data` is `undefined` — no active object, no instability.\n */\n readonly data: ColumnData | undefined;\n}\n\n// --- ColumnData ---\n\n/**\n * Active object wrapping lazy column data access.\n * Accessing data on a computing column marks the render context unstable.\n */\nexport interface ColumnData {\n get(): PColumnDataUniversal | undefined;\n}\n\n/** Creates a ColumnData active object for a ready column. */\nexport function createReadyColumnData(getData: () => PColumnDataUniversal | undefined): ColumnData {\n return { get: getData };\n}\n\n// --- Snapshot construction helpers ---\n\n/** Creates a ColumnSnapshot from parts. */\nexport function createColumnSnapshot<Id extends PObjectId = PObjectId>(\n id: Id,\n spec: PColumnSpec,\n dataStatus: ColumnDataStatus,\n data: ColumnData | undefined,\n): ColumnSnapshot<Id> {\n return { id, spec, dataStatus, data };\n}\n"],"mappings":";;AAwCA,SAAgB,sBAAsB,SAA6D;AACjG,QAAO,EAAE,KAAK,SAAS;;;AAMzB,SAAgB,qBACd,IACA,MACA,YACA,MACoB;AACpB,QAAO;EAAE;EAAI;EAAM;EAAY;EAAM"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/columns/column_snapshot_provider.ts
|
|
3
|
+
/**
|
|
4
|
+
* Simple provider wrapping an array of PColumns.
|
|
5
|
+
* Always complete, data status always 'ready'.
|
|
6
|
+
*/
|
|
7
|
+
var ArrayColumnProvider = class {
|
|
8
|
+
columns;
|
|
9
|
+
constructor(columns) {
|
|
10
|
+
this.columns = columns.map((col) => ({
|
|
11
|
+
id: col.id,
|
|
12
|
+
spec: col.spec,
|
|
13
|
+
dataStatus: "ready",
|
|
14
|
+
data: { get: () => col.data }
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
getAllColumns() {
|
|
18
|
+
return this.columns;
|
|
19
|
+
}
|
|
20
|
+
isColumnListComplete() {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Provider wrapping an array of ColumnSnapshots.
|
|
26
|
+
* Always complete. Data status taken from each snapshot.
|
|
27
|
+
*/
|
|
28
|
+
var SnapshotColumnProvider = class {
|
|
29
|
+
constructor(snapshots) {
|
|
30
|
+
this.snapshots = snapshots;
|
|
31
|
+
}
|
|
32
|
+
getAllColumns() {
|
|
33
|
+
return this.snapshots;
|
|
34
|
+
}
|
|
35
|
+
isColumnListComplete() {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Provider wrapping a TreeNodeAccessor (output/prerun resolve result).
|
|
41
|
+
* Detects data status from accessor readiness state.
|
|
42
|
+
*/
|
|
43
|
+
var OutputColumnProvider = class {
|
|
44
|
+
constructor(accessor, opts) {
|
|
45
|
+
this.accessor = accessor;
|
|
46
|
+
this.opts = opts;
|
|
47
|
+
}
|
|
48
|
+
getAllColumns() {
|
|
49
|
+
return this.getColumns();
|
|
50
|
+
}
|
|
51
|
+
isColumnListComplete() {
|
|
52
|
+
return this.accessor.getInputsLocked();
|
|
53
|
+
}
|
|
54
|
+
getColumns() {
|
|
55
|
+
const pColumns = this.accessor.getPColumns();
|
|
56
|
+
if (pColumns === void 0) return [];
|
|
57
|
+
const isFinal = this.accessor.getIsFinal();
|
|
58
|
+
const allowAbsence = this.opts?.allowPermanentAbsence === true;
|
|
59
|
+
return pColumns.map((col) => {
|
|
60
|
+
const dataAccessor = col.data;
|
|
61
|
+
const isReady = dataAccessor.getIsReadyOrError();
|
|
62
|
+
let dataStatus;
|
|
63
|
+
if (isReady) dataStatus = "ready";
|
|
64
|
+
else if (allowAbsence && isFinal) dataStatus = "absent";
|
|
65
|
+
else dataStatus = "computing";
|
|
66
|
+
return {
|
|
67
|
+
id: col.id,
|
|
68
|
+
spec: col.spec,
|
|
69
|
+
dataStatus,
|
|
70
|
+
data: { get: () => isReady ? dataAccessor : void 0 }
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/** Checks if a value is a ColumnSnapshotProvider (duck-typing). */
|
|
76
|
+
function isColumnSnapshotProvider(source) {
|
|
77
|
+
return typeof source === "object" && source !== null && "getAllColumns" in source && "isColumnListComplete" in source && typeof source.getAllColumns === "function" && typeof source.isColumnListComplete === "function";
|
|
78
|
+
}
|
|
79
|
+
/** Checks if a value looks like a PColumn (has id, spec, data). */
|
|
80
|
+
function isPColumnArray(source) {
|
|
81
|
+
if (!Array.isArray(source)) return false;
|
|
82
|
+
if (source.length === 0) return true;
|
|
83
|
+
const first = source[0];
|
|
84
|
+
return "id" in first && "spec" in first && "data" in first && !("dataStatus" in first);
|
|
85
|
+
}
|
|
86
|
+
/** Checks if a value looks like a ColumnSnapshot array. */
|
|
87
|
+
function isColumnSnapshotArray(source) {
|
|
88
|
+
if (!Array.isArray(source)) return false;
|
|
89
|
+
if (source.length === 0) return true;
|
|
90
|
+
const first = source[0];
|
|
91
|
+
return "id" in first && "spec" in first && "dataStatus" in first;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Normalize any ColumnSource into a ColumnSnapshotProvider.
|
|
95
|
+
* - ColumnSnapshotProvider → returned as-is
|
|
96
|
+
* - ColumnSnapshot[] → wrapped in SnapshotColumnProvider
|
|
97
|
+
* - PColumn[] → wrapped in ArrayColumnProvider
|
|
98
|
+
*/
|
|
99
|
+
function toColumnSnapshotProvider(source) {
|
|
100
|
+
if (isColumnSnapshotProvider(source)) return source;
|
|
101
|
+
if (isColumnSnapshotArray(source)) return new SnapshotColumnProvider(source);
|
|
102
|
+
if (isPColumnArray(source)) return new ArrayColumnProvider(source);
|
|
103
|
+
throw new Error("Unknown ColumnSource type");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
exports.ArrayColumnProvider = ArrayColumnProvider;
|
|
108
|
+
exports.OutputColumnProvider = OutputColumnProvider;
|
|
109
|
+
exports.SnapshotColumnProvider = SnapshotColumnProvider;
|
|
110
|
+
exports.isColumnSnapshotProvider = isColumnSnapshotProvider;
|
|
111
|
+
exports.toColumnSnapshotProvider = toColumnSnapshotProvider;
|
|
112
|
+
//# sourceMappingURL=column_snapshot_provider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_snapshot_provider.cjs","names":[],"sources":["../../src/columns/column_snapshot_provider.ts"],"sourcesContent":["import { PColumn } from \"@milaboratories/pl-model-common\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport type { PColumnDataUniversal } from \"../render/internal\";\nimport type { ColumnDataStatus, ColumnSnapshot } from \"./column_snapshot\";\n\n// --- ColumnProvider ---\n\n/**\n * Data source interface for column enumeration.\n *\n * Knows nothing about the render framework, stability tracking, labels,\n * anchoring, or splitting. All that complexity lives in the collection layer.\n */\nexport interface ColumnSnapshotProvider {\n /** Returns all currently known columns. */\n getAllColumns(): ColumnSnapshot[];\n\n /** Whether the provider has finished enumerating all its columns.\n * Calling this may mark the render context unstable — it touches\n * the reactive tree to check field resolution state. */\n isColumnListComplete(): boolean;\n}\n\n// --- ColumnSource ---\n\n/**\n * Union of types that can serve as column sources for helpers and builders.\n * Does NOT include TreeNodeAccessor — call `.toColumnSource()` on it first.\n */\nexport type ColumnSource =\n | ColumnSnapshotProvider\n | ColumnSnapshot[]\n | PColumn<PColumnDataUniversal | undefined>[];\n\n// --- ArrayColumnProvider ---\n\n/**\n * Simple provider wrapping an array of PColumns.\n * Always complete, data status always 'ready'.\n */\nexport class ArrayColumnProvider implements ColumnSnapshotProvider {\n private readonly columns: ColumnSnapshot[];\n\n constructor(columns: PColumn<PColumnDataUniversal | undefined>[]) {\n this.columns = columns.map((col) => ({\n id: col.id,\n spec: col.spec,\n dataStatus: \"ready\" as const,\n data: { get: () => col.data },\n }));\n }\n\n getAllColumns(): ColumnSnapshot[] {\n return this.columns;\n }\n\n isColumnListComplete(): boolean {\n return true;\n }\n}\n\n// --- SnapshotColumnProvider ---\n\n/**\n * Provider wrapping an array of ColumnSnapshots.\n * Always complete. Data status taken from each snapshot.\n */\nexport class SnapshotColumnProvider implements ColumnSnapshotProvider {\n constructor(private readonly snapshots: ColumnSnapshot[]) {}\n\n getAllColumns(): ColumnSnapshot[] {\n return this.snapshots;\n }\n\n isColumnListComplete(): boolean {\n return true;\n }\n}\n\n// --- OutputColumnProvider ---\n\nexport interface OutputColumnProviderOpts {\n /** When true and the accessor is final, columns with no ready data get status 'absent'. */\n allowPermanentAbsence?: boolean;\n}\n\n/**\n * Provider wrapping a TreeNodeAccessor (output/prerun resolve result).\n * Detects data status from accessor readiness state.\n */\nexport class OutputColumnProvider implements ColumnSnapshotProvider {\n constructor(\n private readonly accessor: TreeNodeAccessor,\n private readonly opts?: OutputColumnProviderOpts,\n ) {}\n\n getAllColumns(): ColumnSnapshot[] {\n return this.getColumns();\n }\n\n isColumnListComplete(): boolean {\n return this.accessor.getInputsLocked();\n }\n\n private getColumns(): ColumnSnapshot[] {\n const pColumns = this.accessor.getPColumns();\n if (pColumns === undefined) return [];\n\n const isFinal = this.accessor.getIsFinal();\n const allowAbsence = this.opts?.allowPermanentAbsence === true;\n\n return pColumns.map((col) => {\n const dataAccessor = col.data;\n const isReady = dataAccessor.getIsReadyOrError();\n\n let dataStatus: ColumnDataStatus;\n if (isReady) {\n dataStatus = \"ready\";\n } else if (allowAbsence && isFinal) {\n dataStatus = \"absent\";\n } else {\n dataStatus = \"computing\";\n }\n\n return {\n id: col.id,\n spec: col.spec,\n dataStatus,\n data: { get: () => (isReady ? dataAccessor : undefined) },\n };\n });\n }\n}\n\n// --- Source normalization ---\n\n/** Checks if a value is a ColumnSnapshotProvider (duck-typing). */\nexport function isColumnSnapshotProvider(source: unknown): source is ColumnSnapshotProvider {\n return (\n typeof source === \"object\" &&\n source !== null &&\n \"getAllColumns\" in source &&\n \"isColumnListComplete\" in source &&\n typeof (source as ColumnSnapshotProvider).getAllColumns === \"function\" &&\n typeof (source as ColumnSnapshotProvider).isColumnListComplete === \"function\"\n );\n}\n\n/** Checks if a value looks like a PColumn (has id, spec, data). */\nfunction isPColumnArray(source: unknown): source is PColumn<PColumnDataUniversal | undefined>[] {\n if (!Array.isArray(source)) return false;\n if (source.length === 0) return true; // empty array — treat as PColumn[]\n const first = source[0];\n return \"id\" in first && \"spec\" in first && \"data\" in first && !(\"dataStatus\" in first);\n}\n\n/** Checks if a value looks like a ColumnSnapshot array. */\nfunction isColumnSnapshotArray(source: unknown): source is ColumnSnapshot[] {\n if (!Array.isArray(source)) return false;\n if (source.length === 0) return true; // empty array — treat as snapshots\n const first = source[0];\n return \"id\" in first && \"spec\" in first && \"dataStatus\" in first;\n}\n\n/**\n * Normalize any ColumnSource into a ColumnSnapshotProvider.\n * - ColumnSnapshotProvider → returned as-is\n * - ColumnSnapshot[] → wrapped in SnapshotColumnProvider\n * - PColumn[] → wrapped in ArrayColumnProvider\n */\nexport function toColumnSnapshotProvider(source: ColumnSource): ColumnSnapshotProvider {\n if (isColumnSnapshotProvider(source)) return source;\n if (isColumnSnapshotArray(source)) return new SnapshotColumnProvider(source);\n if (isPColumnArray(source)) return new ArrayColumnProvider(source);\n // Should not reach here given the type union, but be safe\n throw new Error(\"Unknown ColumnSource type\");\n}\n"],"mappings":";;;;;;AAwCA,IAAa,sBAAb,MAAmE;CACjE,AAAiB;CAEjB,YAAY,SAAsD;AAChE,OAAK,UAAU,QAAQ,KAAK,SAAS;GACnC,IAAI,IAAI;GACR,MAAM,IAAI;GACV,YAAY;GACZ,MAAM,EAAE,WAAW,IAAI,MAAM;GAC9B,EAAE;;CAGL,gBAAkC;AAChC,SAAO,KAAK;;CAGd,uBAAgC;AAC9B,SAAO;;;;;;;AAUX,IAAa,yBAAb,MAAsE;CACpE,YAAY,AAAiB,WAA6B;EAA7B;;CAE7B,gBAAkC;AAChC,SAAO,KAAK;;CAGd,uBAAgC;AAC9B,SAAO;;;;;;;AAeX,IAAa,uBAAb,MAAoE;CAClE,YACE,AAAiB,UACjB,AAAiB,MACjB;EAFiB;EACA;;CAGnB,gBAAkC;AAChC,SAAO,KAAK,YAAY;;CAG1B,uBAAgC;AAC9B,SAAO,KAAK,SAAS,iBAAiB;;CAGxC,AAAQ,aAA+B;EACrC,MAAM,WAAW,KAAK,SAAS,aAAa;AAC5C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
import { TreeNodeAccessor } from "../render/accessor.js";
|
|
3
|
+
import { ColumnSnapshot } from "./column_snapshot.js";
|
|
4
|
+
import { PColumn } from "@milaboratories/pl-model-common";
|
|
5
|
+
|
|
6
|
+
//#region src/columns/column_snapshot_provider.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Data source interface for column enumeration.
|
|
9
|
+
*
|
|
10
|
+
* Knows nothing about the render framework, stability tracking, labels,
|
|
11
|
+
* anchoring, or splitting. All that complexity lives in the collection layer.
|
|
12
|
+
*/
|
|
13
|
+
interface ColumnSnapshotProvider {
|
|
14
|
+
/** Returns all currently known columns. */
|
|
15
|
+
getAllColumns(): ColumnSnapshot[];
|
|
16
|
+
/** Whether the provider has finished enumerating all its columns.
|
|
17
|
+
* Calling this may mark the render context unstable — it touches
|
|
18
|
+
* the reactive tree to check field resolution state. */
|
|
19
|
+
isColumnListComplete(): boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Union of types that can serve as column sources for helpers and builders.
|
|
23
|
+
* Does NOT include TreeNodeAccessor — call `.toColumnSource()` on it first.
|
|
24
|
+
*/
|
|
25
|
+
type ColumnSource = ColumnSnapshotProvider | ColumnSnapshot[] | PColumn<PColumnDataUniversal | undefined>[];
|
|
26
|
+
/**
|
|
27
|
+
* Simple provider wrapping an array of PColumns.
|
|
28
|
+
* Always complete, data status always 'ready'.
|
|
29
|
+
*/
|
|
30
|
+
declare class ArrayColumnProvider implements ColumnSnapshotProvider {
|
|
31
|
+
private readonly columns;
|
|
32
|
+
constructor(columns: PColumn<PColumnDataUniversal | undefined>[]);
|
|
33
|
+
getAllColumns(): ColumnSnapshot[];
|
|
34
|
+
isColumnListComplete(): boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Provider wrapping an array of ColumnSnapshots.
|
|
38
|
+
* Always complete. Data status taken from each snapshot.
|
|
39
|
+
*/
|
|
40
|
+
declare class SnapshotColumnProvider implements ColumnSnapshotProvider {
|
|
41
|
+
private readonly snapshots;
|
|
42
|
+
constructor(snapshots: ColumnSnapshot[]);
|
|
43
|
+
getAllColumns(): ColumnSnapshot[];
|
|
44
|
+
isColumnListComplete(): boolean;
|
|
45
|
+
}
|
|
46
|
+
interface OutputColumnProviderOpts {
|
|
47
|
+
/** When true and the accessor is final, columns with no ready data get status 'absent'. */
|
|
48
|
+
allowPermanentAbsence?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Provider wrapping a TreeNodeAccessor (output/prerun resolve result).
|
|
52
|
+
* Detects data status from accessor readiness state.
|
|
53
|
+
*/
|
|
54
|
+
declare class OutputColumnProvider implements ColumnSnapshotProvider {
|
|
55
|
+
private readonly accessor;
|
|
56
|
+
private readonly opts?;
|
|
57
|
+
constructor(accessor: TreeNodeAccessor, opts?: OutputColumnProviderOpts | undefined);
|
|
58
|
+
getAllColumns(): ColumnSnapshot[];
|
|
59
|
+
isColumnListComplete(): boolean;
|
|
60
|
+
private getColumns;
|
|
61
|
+
}
|
|
62
|
+
/** Checks if a value is a ColumnSnapshotProvider (duck-typing). */
|
|
63
|
+
declare function isColumnSnapshotProvider(source: unknown): source is ColumnSnapshotProvider;
|
|
64
|
+
/**
|
|
65
|
+
* Normalize any ColumnSource into a ColumnSnapshotProvider.
|
|
66
|
+
* - ColumnSnapshotProvider → returned as-is
|
|
67
|
+
* - ColumnSnapshot[] → wrapped in SnapshotColumnProvider
|
|
68
|
+
* - PColumn[] → wrapped in ArrayColumnProvider
|
|
69
|
+
*/
|
|
70
|
+
declare function toColumnSnapshotProvider(source: ColumnSource): ColumnSnapshotProvider;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { ArrayColumnProvider, ColumnSnapshotProvider, ColumnSource, OutputColumnProvider, OutputColumnProviderOpts, SnapshotColumnProvider, isColumnSnapshotProvider, toColumnSnapshotProvider };
|
|
73
|
+
//# sourceMappingURL=column_snapshot_provider.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//#region src/columns/column_snapshot_provider.ts
|
|
2
|
+
/**
|
|
3
|
+
* Simple provider wrapping an array of PColumns.
|
|
4
|
+
* Always complete, data status always 'ready'.
|
|
5
|
+
*/
|
|
6
|
+
var ArrayColumnProvider = class {
|
|
7
|
+
columns;
|
|
8
|
+
constructor(columns) {
|
|
9
|
+
this.columns = columns.map((col) => ({
|
|
10
|
+
id: col.id,
|
|
11
|
+
spec: col.spec,
|
|
12
|
+
dataStatus: "ready",
|
|
13
|
+
data: { get: () => col.data }
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
getAllColumns() {
|
|
17
|
+
return this.columns;
|
|
18
|
+
}
|
|
19
|
+
isColumnListComplete() {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Provider wrapping an array of ColumnSnapshots.
|
|
25
|
+
* Always complete. Data status taken from each snapshot.
|
|
26
|
+
*/
|
|
27
|
+
var SnapshotColumnProvider = class {
|
|
28
|
+
constructor(snapshots) {
|
|
29
|
+
this.snapshots = snapshots;
|
|
30
|
+
}
|
|
31
|
+
getAllColumns() {
|
|
32
|
+
return this.snapshots;
|
|
33
|
+
}
|
|
34
|
+
isColumnListComplete() {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Provider wrapping a TreeNodeAccessor (output/prerun resolve result).
|
|
40
|
+
* Detects data status from accessor readiness state.
|
|
41
|
+
*/
|
|
42
|
+
var OutputColumnProvider = class {
|
|
43
|
+
constructor(accessor, opts) {
|
|
44
|
+
this.accessor = accessor;
|
|
45
|
+
this.opts = opts;
|
|
46
|
+
}
|
|
47
|
+
getAllColumns() {
|
|
48
|
+
return this.getColumns();
|
|
49
|
+
}
|
|
50
|
+
isColumnListComplete() {
|
|
51
|
+
return this.accessor.getInputsLocked();
|
|
52
|
+
}
|
|
53
|
+
getColumns() {
|
|
54
|
+
const pColumns = this.accessor.getPColumns();
|
|
55
|
+
if (pColumns === void 0) return [];
|
|
56
|
+
const isFinal = this.accessor.getIsFinal();
|
|
57
|
+
const allowAbsence = this.opts?.allowPermanentAbsence === true;
|
|
58
|
+
return pColumns.map((col) => {
|
|
59
|
+
const dataAccessor = col.data;
|
|
60
|
+
const isReady = dataAccessor.getIsReadyOrError();
|
|
61
|
+
let dataStatus;
|
|
62
|
+
if (isReady) dataStatus = "ready";
|
|
63
|
+
else if (allowAbsence && isFinal) dataStatus = "absent";
|
|
64
|
+
else dataStatus = "computing";
|
|
65
|
+
return {
|
|
66
|
+
id: col.id,
|
|
67
|
+
spec: col.spec,
|
|
68
|
+
dataStatus,
|
|
69
|
+
data: { get: () => isReady ? dataAccessor : void 0 }
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/** Checks if a value is a ColumnSnapshotProvider (duck-typing). */
|
|
75
|
+
function isColumnSnapshotProvider(source) {
|
|
76
|
+
return typeof source === "object" && source !== null && "getAllColumns" in source && "isColumnListComplete" in source && typeof source.getAllColumns === "function" && typeof source.isColumnListComplete === "function";
|
|
77
|
+
}
|
|
78
|
+
/** Checks if a value looks like a PColumn (has id, spec, data). */
|
|
79
|
+
function isPColumnArray(source) {
|
|
80
|
+
if (!Array.isArray(source)) return false;
|
|
81
|
+
if (source.length === 0) return true;
|
|
82
|
+
const first = source[0];
|
|
83
|
+
return "id" in first && "spec" in first && "data" in first && !("dataStatus" in first);
|
|
84
|
+
}
|
|
85
|
+
/** Checks if a value looks like a ColumnSnapshot array. */
|
|
86
|
+
function isColumnSnapshotArray(source) {
|
|
87
|
+
if (!Array.isArray(source)) return false;
|
|
88
|
+
if (source.length === 0) return true;
|
|
89
|
+
const first = source[0];
|
|
90
|
+
return "id" in first && "spec" in first && "dataStatus" in first;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Normalize any ColumnSource into a ColumnSnapshotProvider.
|
|
94
|
+
* - ColumnSnapshotProvider → returned as-is
|
|
95
|
+
* - ColumnSnapshot[] → wrapped in SnapshotColumnProvider
|
|
96
|
+
* - PColumn[] → wrapped in ArrayColumnProvider
|
|
97
|
+
*/
|
|
98
|
+
function toColumnSnapshotProvider(source) {
|
|
99
|
+
if (isColumnSnapshotProvider(source)) return source;
|
|
100
|
+
if (isColumnSnapshotArray(source)) return new SnapshotColumnProvider(source);
|
|
101
|
+
if (isPColumnArray(source)) return new ArrayColumnProvider(source);
|
|
102
|
+
throw new Error("Unknown ColumnSource type");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { ArrayColumnProvider, OutputColumnProvider, SnapshotColumnProvider, isColumnSnapshotProvider, toColumnSnapshotProvider };
|
|
107
|
+
//# sourceMappingURL=column_snapshot_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_snapshot_provider.js","names":[],"sources":["../../src/columns/column_snapshot_provider.ts"],"sourcesContent":["import { PColumn } from \"@milaboratories/pl-model-common\";\nimport { TreeNodeAccessor } from \"../render/accessor\";\nimport type { PColumnDataUniversal } from \"../render/internal\";\nimport type { ColumnDataStatus, ColumnSnapshot } from \"./column_snapshot\";\n\n// --- ColumnProvider ---\n\n/**\n * Data source interface for column enumeration.\n *\n * Knows nothing about the render framework, stability tracking, labels,\n * anchoring, or splitting. All that complexity lives in the collection layer.\n */\nexport interface ColumnSnapshotProvider {\n /** Returns all currently known columns. */\n getAllColumns(): ColumnSnapshot[];\n\n /** Whether the provider has finished enumerating all its columns.\n * Calling this may mark the render context unstable — it touches\n * the reactive tree to check field resolution state. */\n isColumnListComplete(): boolean;\n}\n\n// --- ColumnSource ---\n\n/**\n * Union of types that can serve as column sources for helpers and builders.\n * Does NOT include TreeNodeAccessor — call `.toColumnSource()` on it first.\n */\nexport type ColumnSource =\n | ColumnSnapshotProvider\n | ColumnSnapshot[]\n | PColumn<PColumnDataUniversal | undefined>[];\n\n// --- ArrayColumnProvider ---\n\n/**\n * Simple provider wrapping an array of PColumns.\n * Always complete, data status always 'ready'.\n */\nexport class ArrayColumnProvider implements ColumnSnapshotProvider {\n private readonly columns: ColumnSnapshot[];\n\n constructor(columns: PColumn<PColumnDataUniversal | undefined>[]) {\n this.columns = columns.map((col) => ({\n id: col.id,\n spec: col.spec,\n dataStatus: \"ready\" as const,\n data: { get: () => col.data },\n }));\n }\n\n getAllColumns(): ColumnSnapshot[] {\n return this.columns;\n }\n\n isColumnListComplete(): boolean {\n return true;\n }\n}\n\n// --- SnapshotColumnProvider ---\n\n/**\n * Provider wrapping an array of ColumnSnapshots.\n * Always complete. Data status taken from each snapshot.\n */\nexport class SnapshotColumnProvider implements ColumnSnapshotProvider {\n constructor(private readonly snapshots: ColumnSnapshot[]) {}\n\n getAllColumns(): ColumnSnapshot[] {\n return this.snapshots;\n }\n\n isColumnListComplete(): boolean {\n return true;\n }\n}\n\n// --- OutputColumnProvider ---\n\nexport interface OutputColumnProviderOpts {\n /** When true and the accessor is final, columns with no ready data get status 'absent'. */\n allowPermanentAbsence?: boolean;\n}\n\n/**\n * Provider wrapping a TreeNodeAccessor (output/prerun resolve result).\n * Detects data status from accessor readiness state.\n */\nexport class OutputColumnProvider implements ColumnSnapshotProvider {\n constructor(\n private readonly accessor: TreeNodeAccessor,\n private readonly opts?: OutputColumnProviderOpts,\n ) {}\n\n getAllColumns(): ColumnSnapshot[] {\n return this.getColumns();\n }\n\n isColumnListComplete(): boolean {\n return this.accessor.getInputsLocked();\n }\n\n private getColumns(): ColumnSnapshot[] {\n const pColumns = this.accessor.getPColumns();\n if (pColumns === undefined) return [];\n\n const isFinal = this.accessor.getIsFinal();\n const allowAbsence = this.opts?.allowPermanentAbsence === true;\n\n return pColumns.map((col) => {\n const dataAccessor = col.data;\n const isReady = dataAccessor.getIsReadyOrError();\n\n let dataStatus: ColumnDataStatus;\n if (isReady) {\n dataStatus = \"ready\";\n } else if (allowAbsence && isFinal) {\n dataStatus = \"absent\";\n } else {\n dataStatus = \"computing\";\n }\n\n return {\n id: col.id,\n spec: col.spec,\n dataStatus,\n data: { get: () => (isReady ? dataAccessor : undefined) },\n };\n });\n }\n}\n\n// --- Source normalization ---\n\n/** Checks if a value is a ColumnSnapshotProvider (duck-typing). */\nexport function isColumnSnapshotProvider(source: unknown): source is ColumnSnapshotProvider {\n return (\n typeof source === \"object\" &&\n source !== null &&\n \"getAllColumns\" in source &&\n \"isColumnListComplete\" in source &&\n typeof (source as ColumnSnapshotProvider).getAllColumns === \"function\" &&\n typeof (source as ColumnSnapshotProvider).isColumnListComplete === \"function\"\n );\n}\n\n/** Checks if a value looks like a PColumn (has id, spec, data). */\nfunction isPColumnArray(source: unknown): source is PColumn<PColumnDataUniversal | undefined>[] {\n if (!Array.isArray(source)) return false;\n if (source.length === 0) return true; // empty array — treat as PColumn[]\n const first = source[0];\n return \"id\" in first && \"spec\" in first && \"data\" in first && !(\"dataStatus\" in first);\n}\n\n/** Checks if a value looks like a ColumnSnapshot array. */\nfunction isColumnSnapshotArray(source: unknown): source is ColumnSnapshot[] {\n if (!Array.isArray(source)) return false;\n if (source.length === 0) return true; // empty array — treat as snapshots\n const first = source[0];\n return \"id\" in first && \"spec\" in first && \"dataStatus\" in first;\n}\n\n/**\n * Normalize any ColumnSource into a ColumnSnapshotProvider.\n * - ColumnSnapshotProvider → returned as-is\n * - ColumnSnapshot[] → wrapped in SnapshotColumnProvider\n * - PColumn[] → wrapped in ArrayColumnProvider\n */\nexport function toColumnSnapshotProvider(source: ColumnSource): ColumnSnapshotProvider {\n if (isColumnSnapshotProvider(source)) return source;\n if (isColumnSnapshotArray(source)) return new SnapshotColumnProvider(source);\n if (isPColumnArray(source)) return new ArrayColumnProvider(source);\n // Should not reach here given the type union, but be safe\n throw new Error(\"Unknown ColumnSource type\");\n}\n"],"mappings":";;;;;AAwCA,IAAa,sBAAb,MAAmE;CACjE,AAAiB;CAEjB,YAAY,SAAsD;AAChE,OAAK,UAAU,QAAQ,KAAK,SAAS;GACnC,IAAI,IAAI;GACR,MA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AAgB;;;AAIlF,SAAS,sBAAsB,QAA6C;AAC1E,KAAI,CAAC,MAAM,QAAQ,OAAO,CAAE,QAAO;AACnC,KAAI,OAAO,WAAW,EAAG,QAAO;CAChC,MAAM,QAAQ,OAAO;AACrB,QAAO,QAAQ,SAAS,UAAU,SAAS,gBAAgB;;;;;;;;AAS7D,SAAgB,yBAAyB,QAA8C;AACrF,KAAI,yBAAyB,OAAO,CAAE,QAAO;AAC7C,KAAI,sBAAsB,OAAO,CAAE,QAAO,IAAI,uBAAuB,OAAO;AAC5E,KAAI,eAAe,OAAO,CAAE,QAAO,IAAI,oBAAoB,OAAO;AAElE,OAAM,IAAI,MAAM,4BAA4B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_column_snapshot_provider = require('./column_snapshot_provider.cjs');
|
|
3
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
|
+
|
|
5
|
+
//#region src/columns/ctx_column_sources.ts
|
|
6
|
+
/**
|
|
7
|
+
* Collect ColumnSnapshotProviders from all render context sources:
|
|
8
|
+
*
|
|
9
|
+
* - **resultPool** — all upstream columns (always included)
|
|
10
|
+
* - **outputs** — PFrame fields from block execution outputs
|
|
11
|
+
* - **prerun** — PFrame fields from prerun/staging results
|
|
12
|
+
*
|
|
13
|
+
* Returns an array of providers suitable for `ColumnCollectionBuilder.addSource()`.
|
|
14
|
+
*/
|
|
15
|
+
function collectCtxColumnSnapshotProviders(ctx) {
|
|
16
|
+
const providers = [];
|
|
17
|
+
providers.push(new ResultPoolColumnSnapshotProvider(ctx.resultPool));
|
|
18
|
+
const outputs = ctx.outputs;
|
|
19
|
+
if (outputs) providers.push(...collectPFrameProviders(outputs));
|
|
20
|
+
const prerun = ctx.prerun;
|
|
21
|
+
if (prerun) providers.push(...collectPFrameProviders(prerun));
|
|
22
|
+
return providers;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Adapter wrapping ResultPool into the new ColumnSnapshotProvider interface.
|
|
26
|
+
*
|
|
27
|
+
* - `isColumnListComplete()` always returns true — the result pool
|
|
28
|
+
* is a stable snapshot within a single render cycle.
|
|
29
|
+
* - Data status is derived from the underlying TreeNodeAccessor:
|
|
30
|
+
* ready (getIsReadyOrError), computing, or absent (no data resource).
|
|
31
|
+
*/
|
|
32
|
+
var ResultPoolColumnSnapshotProvider = class {
|
|
33
|
+
constructor(pool) {
|
|
34
|
+
this.pool = pool;
|
|
35
|
+
}
|
|
36
|
+
getAllColumns() {
|
|
37
|
+
return this.pool.selectColumns(() => true).map((col) => toSnapshot(col.id, col.spec, col.data));
|
|
38
|
+
}
|
|
39
|
+
isColumnListComplete() {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function toSnapshot(id, spec, accessor) {
|
|
44
|
+
if (accessor === void 0) return {
|
|
45
|
+
id,
|
|
46
|
+
spec,
|
|
47
|
+
dataStatus: "absent",
|
|
48
|
+
data: void 0
|
|
49
|
+
};
|
|
50
|
+
const isReady = accessor.getIsReadyOrError();
|
|
51
|
+
return {
|
|
52
|
+
id,
|
|
53
|
+
spec,
|
|
54
|
+
dataStatus: isReady ? "ready" : "computing",
|
|
55
|
+
data: { get: () => isReady ? accessor : void 0 }
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Recursively walk the output tree starting from `accessor`.
|
|
60
|
+
* - If a node's resourceType is PFrame → wrap it as OutputColumnProvider.
|
|
61
|
+
* - If a node's resourceType is StdMap/std/map → recurse into its output fields.
|
|
62
|
+
* - Otherwise → skip (leaf of unknown type).
|
|
63
|
+
*/
|
|
64
|
+
function collectPFrameProviders(accessor) {
|
|
65
|
+
const out = [];
|
|
66
|
+
walkTree(accessor, out);
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
function walkTree(node, out) {
|
|
70
|
+
const typeName = node.resourceType.name;
|
|
71
|
+
if (typeName === _milaboratories_pl_model_common.ResourceTypeName.PFrame) {
|
|
72
|
+
out.push(new require_column_snapshot_provider.OutputColumnProvider(node));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (typeName === _milaboratories_pl_model_common.ResourceTypeName.StdMap || typeName === _milaboratories_pl_model_common.ResourceTypeName.StdMapSlash) for (const field of node.listInputFields()) {
|
|
76
|
+
const child = node.resolve(field);
|
|
77
|
+
if (child) walkTree(child, out);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
exports.ResultPoolColumnSnapshotProvider = ResultPoolColumnSnapshotProvider;
|
|
83
|
+
exports.collectCtxColumnSnapshotProviders = collectCtxColumnSnapshotProviders;
|
|
84
|
+
//# sourceMappingURL=ctx_column_sources.cjs.map
|