@platforma-open/milaboratories.sequence-properties.model 1.2.1 → 1.2.3

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/bundle.js CHANGED
@@ -4973,6 +4973,9 @@
4973
4973
  Sequence: "pl7.app/vdj/sequence"
4974
4974
  }
4975
4975
  };
4976
+ function isLabelColumn(column) {
4977
+ return column.axesSpec.length === 1 && column.name === PColumnName.Label;
4978
+ }
4976
4979
  /** Get column id and spec from a column */
4977
4980
  function getColumnIdAndSpec(column) {
4978
4981
  return {
@@ -5545,47 +5548,6 @@
5545
5548
  return v === null || v === void 0;
5546
5549
  }
5547
5550
  Array.isArray;
5548
- function isObject(value) {
5549
- return typeof value === "object" && value !== null;
5550
- }
5551
- /**
5552
- * Checks if the given value is a plain object.
5553
- *
5554
- * A plain object is defined as an object created by the `{}` literal,
5555
- * an object created with `Object.create(null)`, or an object with a
5556
- * prototype that resolves to `Object.prototype`.
5557
- *
5558
- * @param value - The value to check.
5559
- * @returns `true` if the value is a plain object, otherwise `false`.
5560
- *
5561
- * @example
5562
- * ```typescript
5563
- * isPlainObject({}); // true
5564
- * isPlainObject(Object.create(null)); // true
5565
- * isPlainObject(new Date()); // false
5566
- * isPlainObject(null); // false
5567
- * isPlainObject([]); // false
5568
- * ```
5569
- */
5570
- function isPlainObject(value) {
5571
- if (!isObject(value)) return false;
5572
- const prototype = Object.getPrototypeOf(value);
5573
- return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
5574
- }
5575
- /**
5576
- * Reads a property from a union-typed object where the key may exist only on some members of the union.
5577
- *
5578
- * `K` is constrained to keys of the union's intersection, so any key present on at least one union
5579
- * member is accepted. The return type resolves to `T[K]` when `K` is a key of `T`, otherwise `undefined`
5580
- * — matching the runtime behavior of reading a missing property.
5581
- *
5582
- * @param obj - source object (may be a union of shapes)
5583
- * @param prop - property name, must be a key of at least one union member
5584
- * @returns the property value if present, otherwise `undefined`
5585
- */
5586
- function getField(obj, prop) {
5587
- return obj[prop];
5588
- }
5589
5551
  //#endregion
5590
5552
  //#region ../node_modules/.pnpm/@milaboratories+helpers@1.14.2/node_modules/@milaboratories/helpers/dist/error.js
5591
5553
  function throwError(v) {
@@ -5600,22 +5562,6 @@
5600
5562
  }
5601
5563
  createGetIncrementalId();
5602
5564
  //#endregion
5603
- //#region ../node_modules/.pnpm/@milaboratories+pl-model-common@1.41.2/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/spec/discovered_column.js
5604
- function distillDiscoveredPColumn(props) {
5605
- return {
5606
- column: props.column,
5607
- path: Array.isArray(props.path) && props.path.length > 0 ? props.path : void 0,
5608
- columnQualifications: Array.isArray(props.columnQualifications) && props.columnQualifications.length > 0 ? props.columnQualifications : void 0,
5609
- queriesQualifications: props.queriesQualifications && Object.keys(props.queriesQualifications).length > 0 ? props.queriesQualifications : void 0
5610
- };
5611
- }
5612
- function createDiscoveredPColumnId(props) {
5613
- return stringifyDiscoveredPColumnId(props);
5614
- }
5615
- function stringifyDiscoveredPColumnId(id) {
5616
- return canonicalizeJson(distillDiscoveredPColumn(id));
5617
- }
5618
- //#endregion
5619
5565
  //#region ../node_modules/.pnpm/@milaboratories+pl-model-common@1.41.2/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/linker_columns.js
5620
5566
  var LinkerMap = class LinkerMap {
5621
5567
  /** Graph of linkers connected by axes (single or grouped by parents) */
@@ -5849,47 +5795,6 @@
5849
5795
  } : voe;
5850
5796
  }
5851
5797
  //#endregion
5852
- //#region ../node_modules/.pnpm/@milaboratories+pl-model-common@1.41.2/node_modules/@milaboratories/pl-model-common/dist/resource_types.js
5853
- /** Well-known resource type names used across the platform. */
5854
- const ResourceTypeName = {
5855
- StreamManager: "StreamManager",
5856
- StdMap: "StdMap",
5857
- StdMapSlash: "std/map",
5858
- EphStdMap: "EphStdMap",
5859
- PFrame: "PFrame",
5860
- ParquetChunk: "ParquetChunk",
5861
- BContext: "BContext",
5862
- BlockPackCustom: "BlockPackCustom",
5863
- BinaryMap: "BinaryMap",
5864
- BinaryValue: "BinaryValue",
5865
- BlobMap: "BlobMap",
5866
- BResolveSingle: "BResolveSingle",
5867
- BResolveSingleNoResult: "BResolveSingleNoResult",
5868
- BQueryResult: "BQueryResult",
5869
- TengoTemplate: "TengoTemplate",
5870
- TengoLib: "TengoLib",
5871
- SoftwareInfo: "SoftwareInfo",
5872
- Dummy: "Dummy",
5873
- JsonResourceError: "json/resourceError",
5874
- JsonObject: "json/object",
5875
- JsonGzObject: "json-gz/object",
5876
- JsonString: "json/string",
5877
- JsonArray: "json/array",
5878
- JsonNumber: "json/number",
5879
- BContextEnd: "BContextEnd",
5880
- FrontendFromUrl: "Frontend/FromUrl",
5881
- FrontendFromFolder: "Frontend/FromFolder",
5882
- BObjectSpec: "BObjectSpec",
5883
- Blob: "Blob",
5884
- Null: "Null",
5885
- Binary: "binary",
5886
- LSProvider: "LSProvider",
5887
- WorkingDirectory: "WorkingDirectory",
5888
- UserProject: "UserProject",
5889
- Projects: "Projects",
5890
- ClientRoot: "ClientRoot"
5891
- };
5892
- //#endregion
5893
5798
  //#region ../node_modules/.pnpm/@milaboratories+pl-model-common@1.41.2/node_modules/@milaboratories/pl-model-common/dist/services/service_types.js
5894
5799
  const SERVICE_ID_PATTERN = /^[a-zA-Z][a-zA-Z0-9]*$/;
5895
5800
  const { service, isNodeService, isWasmService, isMainService, getServiceKind, getServiceModelMethods, getServiceUiMethods } = (() => {
@@ -6286,13 +6191,9 @@
6286
6191
  }
6287
6192
  }
6288
6193
  //#endregion
6289
- //#region ../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/function/flow.mjs
6290
- function flow(...funcs) {
6291
- return function(...args) {
6292
- let result = funcs.length ? funcs[0].apply(this, args) : args[0];
6293
- for (let i = 1; i < funcs.length; i++) result = funcs[i].call(this, result);
6294
- return result;
6295
- };
6194
+ //#region ../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/function/identity.mjs
6195
+ function identity(x) {
6196
+ return x;
6296
6197
  }
6297
6198
  //#endregion
6298
6199
  //#region ../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
@@ -6386,7 +6287,7 @@
6386
6287
  qualifications: entry.qualifications
6387
6288
  };
6388
6289
  }
6389
- function formatQualification$1(q) {
6290
+ function formatQualification(q) {
6390
6291
  const ctx = q.contextDomain ?? {};
6391
6292
  const keys = Object.keys(ctx);
6392
6293
  if (keys.length === 0) return q.axis.name;
@@ -6394,7 +6295,7 @@
6394
6295
  return Object.prototype.hasOwnProperty.call(ctx, q.axis.name) ? pairs : `${q.axis.name} ${pairs}`;
6395
6296
  }
6396
6297
  function formatQualifications(qs) {
6397
- return qs.map(formatQualification$1).join("; ");
6298
+ return qs.map(formatQualification).join("; ");
6398
6299
  }
6399
6300
  function computeStepLabel(step, stepIndex, formatters) {
6400
6301
  const base = (readAnnotation(step.spec, Annotation.LinkLabel) ?? readAnnotation(step.spec, Annotation.Label))?.trim();
@@ -6871,7 +6772,7 @@
6871
6772
  /**
6872
6773
  * A simple implementation of {@link ColumnProvider} backed by a pre-defined array of columns.
6873
6774
  */
6874
- var ArrayColumnProvider$1 = class {
6775
+ var ArrayColumnProvider = class {
6875
6776
  constructor(columns) {
6876
6777
  this.columns = columns;
6877
6778
  }
@@ -6922,7 +6823,7 @@
6922
6823
  }
6923
6824
  var PColumnCollection = class {
6924
6825
  defaultProviderStore = [];
6925
- providers = [new ArrayColumnProvider$1(this.defaultProviderStore)];
6826
+ providers = [new ArrayColumnProvider(this.defaultProviderStore)];
6926
6827
  axisLabelProviders = [];
6927
6828
  constructor() {}
6928
6829
  addColumnProvider(provider) {
@@ -8170,471 +8071,196 @@
8170
8071
  }
8171
8072
  };
8172
8073
  //#endregion
8173
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/columns/column_selector.js
8174
- function normalizeStringMatchers(input) {
8175
- if (typeof input === "string") return [{
8176
- type: "regex",
8177
- value: input
8178
- }];
8179
- if (!Array.isArray(input)) return [input];
8180
- return input.map((v) => typeof v === "string" ? {
8181
- type: "regex",
8182
- value: v
8183
- } : v);
8184
- }
8185
- function normalizeRecord(input) {
8186
- const result = {};
8187
- for (const [key, value] of Object.entries(input)) result[key] = normalizeStringMatchers(value);
8188
- return result;
8189
- }
8190
- function normalizeTypes(input) {
8191
- return Array.isArray(input) ? input : [input];
8192
- }
8193
- function convertRelaxedAxisSelectorToMultiAxisSelector(input) {
8194
- const result = {};
8195
- if (input.name !== void 0) result.name = normalizeStringMatchers(input.name);
8196
- if (input.type !== void 0) result.type = normalizeTypes(input.type);
8197
- if (input.domain !== void 0) result.domain = normalizeRecord(input.domain);
8198
- if (input.contextDomain !== void 0) result.contextDomain = normalizeRecord(input.contextDomain);
8199
- if (input.annotations !== void 0) result.annotations = normalizeRecord(input.annotations);
8074
+ //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/pframe_utils/axes.js
8075
+ /** Create id for column copy with added keys in axes domains */
8076
+ const colId = (id, domains, contextDomains) => {
8077
+ let wid = id.toString();
8078
+ domains?.forEach((domain) => {
8079
+ if (domain) for (const [k, v] of Object.entries(domain)) {
8080
+ wid += k;
8081
+ wid += v;
8082
+ }
8083
+ });
8084
+ contextDomains?.forEach((contextDomain) => {
8085
+ if (contextDomain) for (const [k, v] of Object.entries(contextDomain)) {
8086
+ wid += k;
8087
+ wid += v;
8088
+ }
8089
+ });
8090
+ return wid;
8091
+ };
8092
+ /** All combinations with 1 key from each list */
8093
+ function getKeysCombinations(idsLists) {
8094
+ if (!idsLists.length) return [];
8095
+ let result = [[]];
8096
+ idsLists.forEach((list) => {
8097
+ const nextResult = [];
8098
+ list.forEach((key) => {
8099
+ nextResult.push(...result.map((resultItem) => [...resultItem, key]));
8100
+ });
8101
+ result = nextResult;
8102
+ });
8200
8103
  return result;
8201
8104
  }
8202
- function convertRelaxedColumnSelectorToMultiColumnSelector(input) {
8203
- const result = {};
8204
- if (input.name !== void 0) result.name = normalizeStringMatchers(input.name);
8205
- if (input.type !== void 0) result.type = normalizeTypes(input.type);
8206
- if (input.domain !== void 0) result.domain = normalizeRecord(input.domain);
8207
- if (input.contextDomain !== void 0) result.contextDomain = normalizeRecord(input.contextDomain);
8208
- if (input.annotations !== void 0) result.annotations = normalizeRecord(input.annotations);
8209
- if (input.axes !== void 0) result.axes = input.axes.map(convertRelaxedAxisSelectorToMultiAxisSelector);
8210
- if (input.partialAxesMatch !== void 0) result.partialAxesMatch = input.partialAxesMatch;
8211
- return result;
8105
+ function getAvailableWithLinkersAxes(linkerColumns, blockAxes) {
8106
+ const availableAxes = LinkerMap.fromColumns(linkerColumns.map(getColumnIdAndSpec)).getReachableByLinkersAxesFromAxesNormalized([...blockAxes.values()], (linkerKeyId, sourceAxisId) => matchAxisId(sourceAxisId, linkerKeyId));
8107
+ return new Map(availableAxes.map((axisSpec) => {
8108
+ return [canonicalizeJson(getAxisId(axisSpec)), axisSpec];
8109
+ }));
8212
8110
  }
8213
- function convertColumnSelectorToMultiColumnSelector(input) {
8214
- return (Array.isArray(input) ? input : [input]).map(convertRelaxedColumnSelectorToMultiColumnSelector);
8111
+ /** Add columns with fully compatible axes created from partial compatible ones */
8112
+ function enrichCompatible(blockAxes, columns) {
8113
+ return columns.flatMap((column) => getAdditionalColumnsForColumn(blockAxes, column));
8215
8114
  }
8216
- //#endregion
8217
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/columns/column_snapshot_provider.js
8218
- /**
8219
- * Simple provider wrapping an array of PColumns.
8220
- * Always complete, data status always 'ready'.
8221
- */
8222
- var ArrayColumnProvider = class {
8223
- columns;
8224
- constructor(columns) {
8225
- this.columns = columns.map((col) => ({
8226
- id: col.id,
8227
- spec: col.spec,
8228
- data: { get: () => col.data },
8229
- dataStatus: this.getStatus(col.data)
8230
- }));
8231
- }
8232
- getAllColumns() {
8233
- return this.columns;
8234
- }
8235
- isColumnListComplete() {
8236
- return true;
8237
- }
8238
- getStatus(d) {
8239
- if (d == null) return "absent";
8240
- if (typeof d === "function") return this.getStatus(d());
8241
- if (d instanceof TreeNodeAccessor) {
8242
- if (d.getIsReadyOrError()) return "ready";
8243
- if (d.getIsFinal()) return "absent";
8244
- return "computing";
8245
- }
8246
- if (isDataInfo(d)) {
8247
- let ready = true;
8248
- let final = true;
8249
- visitDataInfo(d, (v) => {
8250
- ready &&= v.getIsReadyOrError();
8251
- final &&= v.getIsFinal();
8115
+ function getAdditionalColumnsForColumn(blockAxes, column) {
8116
+ const columnAxesIds = column.spec.axesSpec.map(getAxisId);
8117
+ if (columnAxesIds.every((id) => blockAxes.has(canonicalizeJson(id)))) return [column];
8118
+ const secondaryIdsVariants = getKeysCombinations(columnAxesIds.map((id) => {
8119
+ const result = [];
8120
+ for (const [_, mainId] of blockAxes) if (matchAxisId(mainId, id) && !matchAxisId(id, mainId)) result.push(mainId);
8121
+ return result;
8122
+ }));
8123
+ const allAddedDomainValues = /* @__PURE__ */ new Set();
8124
+ const addedNotToAllVariantsDomainValues = /* @__PURE__ */ new Set();
8125
+ const addedByVariantsDomainValues = secondaryIdsVariants.map((idsList) => {
8126
+ const addedSet = /* @__PURE__ */ new Set();
8127
+ idsList.map((axisId, idx) => {
8128
+ const d1 = column.spec.axesSpec[idx].domain;
8129
+ const d2 = axisId.domain;
8130
+ Object.entries(d2 ?? {}).forEach(([key, value]) => {
8131
+ if (d1?.[key] === void 0) {
8132
+ const item = JSON.stringify([key, value]);
8133
+ addedSet.add(item);
8134
+ allAddedDomainValues.add(item);
8135
+ }
8136
+ });
8137
+ const cd1 = column.spec.axesSpec[idx].contextDomain;
8138
+ const cd2 = axisId.contextDomain;
8139
+ Object.entries(cd2 ?? {}).forEach(([key, value]) => {
8140
+ if (cd1?.[key] === void 0) {
8141
+ const item = JSON.stringify(["ctx:" + key, value]);
8142
+ addedSet.add(item);
8143
+ allAddedDomainValues.add(item);
8144
+ }
8252
8145
  });
8253
- if (ready) return "ready";
8254
- if (final) return "absent";
8255
- return "computing";
8256
- }
8257
- return "ready";
8258
- }
8259
- };
8260
- /**
8261
- * Provider wrapping an array of ColumnSnapshots.
8262
- * Always complete. Data status taken from each snapshot.
8263
- */
8264
- var SnapshotColumnProvider = class {
8265
- constructor(snapshots) {
8266
- this.snapshots = snapshots;
8267
- }
8268
- getAllColumns() {
8269
- return this.snapshots;
8270
- }
8271
- isColumnListComplete() {
8272
- return true;
8273
- }
8274
- };
8275
- /**
8276
- * Provider wrapping a TreeNodeAccessor (output/prerun resolve result).
8277
- * Detects data status from accessor readiness state.
8278
- */
8279
- var OutputColumnProvider = class {
8280
- constructor(accessor, opts) {
8281
- this.accessor = accessor;
8282
- this.opts = opts;
8283
- }
8284
- getAllColumns() {
8285
- return this.getColumns();
8286
- }
8287
- isColumnListComplete() {
8288
- return this.accessor.getInputsLocked();
8289
- }
8290
- getColumns() {
8291
- const pColumns = this.accessor.getPColumns();
8292
- if (pColumns === void 0) return [];
8293
- const isFinal = this.accessor.getIsFinal();
8294
- const allowAbsence = this.opts?.allowPermanentAbsence === true;
8295
- return pColumns.map((col) => {
8296
- const dataAccessor = col.data;
8297
- const isReady = dataAccessor.getIsReadyOrError();
8298
- let dataStatus;
8299
- if (isReady) dataStatus = "ready";
8300
- else if (allowAbsence && isFinal) dataStatus = "absent";
8301
- else dataStatus = "computing";
8302
8146
  return {
8303
- id: col.id,
8304
- spec: col.spec,
8305
- dataStatus,
8306
- data: { get: () => isReady ? dataAccessor : void 0 }
8147
+ ...axisId,
8148
+ annotations: column.spec.axesSpec[idx].annotations
8307
8149
  };
8308
8150
  });
8309
- }
8310
- };
8311
- /** Checks if a value is a ColumnSnapshotProvider (duck-typing). */
8312
- function isColumnSnapshotProvider(source) {
8313
- return typeof source === "object" && source !== null && "getAllColumns" in source && "isColumnListComplete" in source && typeof source.getAllColumns === "function" && typeof source.isColumnListComplete === "function";
8314
- }
8315
- /** Checks if a value looks like a PColumn (has id, spec, data). */
8316
- function isPColumnArray(source) {
8317
- if (!Array.isArray(source)) return false;
8318
- if (source.length === 0) return true;
8319
- const first = source[0];
8320
- return "id" in first && "spec" in first && "data" in first && !("dataStatus" in first);
8321
- }
8322
- /** Checks if a value looks like a ColumnSnapshot array. */
8323
- function isColumnSnapshotArray(source) {
8324
- if (!Array.isArray(source)) return false;
8325
- if (source.length === 0) return true;
8326
- const first = source[0];
8327
- return "id" in first && "spec" in first && "dataStatus" in first;
8328
- }
8329
- /**
8330
- * Normalize any ColumnSource into a ColumnSnapshotProvider.
8331
- * - ColumnSnapshotProvider → returned as-is
8332
- * - ColumnSnapshot<PObjectId>[] → wrapped in SnapshotColumnProvider
8333
- * - PColumn[] → wrapped in ArrayColumnProvider
8334
- */
8335
- function toColumnSnapshotProvider(source) {
8336
- if (isColumnSnapshotProvider(source)) return source;
8337
- if (isColumnSnapshotArray(source)) return new SnapshotColumnProvider(source);
8338
- if (isPColumnArray(source)) return new ArrayColumnProvider(source);
8339
- throw new Error("Unknown ColumnSource type");
8151
+ return addedSet;
8152
+ });
8153
+ [...allAddedDomainValues].forEach((addedPart) => {
8154
+ if (addedByVariantsDomainValues.some((s) => !s.has(addedPart))) addedNotToAllVariantsDomainValues.add(addedPart);
8155
+ });
8156
+ return [column, ...secondaryIdsVariants.map((idsList, idx) => {
8157
+ const id = colId(column.id, idsList.map((id) => id.domain), idsList.map((id) => id.contextDomain));
8158
+ const label = readAnnotation(column.spec, Annotation.Label) ?? "";
8159
+ const labelDomainPart = [...addedByVariantsDomainValues[idx]].filter((str) => addedNotToAllVariantsDomainValues.has(str)).sort().map((v) => JSON.parse(v)?.[1]).join(" / ");
8160
+ const annotations = {
8161
+ ...column.spec.annotations,
8162
+ [Annotation.Graph.IsVirtual]: stringifyJson(true)
8163
+ };
8164
+ if (label || labelDomainPart) annotations[Annotation.Label] = label && labelDomainPart ? label + " / " + labelDomainPart : label + labelDomainPart;
8165
+ return {
8166
+ ...column,
8167
+ id,
8168
+ spec: {
8169
+ ...column.spec,
8170
+ axesSpec: idsList.map((axisId, idx) => ({
8171
+ ...axisId,
8172
+ annotations: column.spec.axesSpec[idx].annotations
8173
+ })),
8174
+ annotations
8175
+ }
8176
+ };
8177
+ })];
8340
8178
  }
8341
8179
  //#endregion
8342
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/columns/column_collection_builder.js
8343
- /**
8344
- * Mutable builder that accumulates column sources, then produces
8345
- * a ColumnCollection (plain) or AnchoredColumnCollection (with anchors).
8346
- *
8347
- * Each output lambda creates its own builder — a constraint of the
8348
- * computable framework where each output tracks its own dependencies.
8349
- */
8350
- var ColumnCollectionBuilder = class {
8351
- providers = [];
8352
- constructor(specDriver = getService("pframeSpec")) {
8353
- this.specDriver = specDriver;
8354
- }
8355
- /**
8356
- * Register a column source. Sources added first take precedence for dedup.
8357
- * Does NOT accept undefined — if a source isn't available yet,
8358
- * the caller should return undefined from the output lambda.
8359
- */
8360
- addSource(source) {
8361
- if (source instanceof TreeNodeAccessor) {
8362
- const columns = source.getPColumns();
8363
- if (columns) this.providers.push(new ArrayColumnProvider(columns));
8364
- } else this.providers.push(toColumnSnapshotProvider(source));
8365
- return this;
8366
- }
8367
- addSources(sources) {
8368
- for (const source of sources) this.addSource(source);
8369
- return this;
8370
- }
8371
- build(options) {
8372
- const allowPartial = options?.allowPartialColumnList === true;
8373
- if (!this.providers.every((p) => p.isColumnListComplete()) && !allowPartial) return void 0;
8374
- const columns = collectColumns(this.providers);
8375
- if (options !== void 0 && "anchors" in options) return new AnchoredColumnCollectionImpl(this.specDriver, {
8376
- anchors: options.anchors,
8377
- columns
8378
- });
8379
- else return new ColumnCollectionImpl(this.specDriver, { columns });
8380
- }
8381
- };
8382
- var ColumnCollectionImpl = class {
8383
- columns;
8384
- specFrameEntry;
8385
- constructor(specDriver, options) {
8386
- this.specDriver = specDriver;
8387
- this.columns = new Map(options.columns.map((col) => [col.id, col]));
8388
- this.specFrameEntry = this.specDriver.createSpecFrame(Object.fromEntries(options.columns.map((col) => [col.id, col.spec])));
8389
- }
8390
- dispose() {
8391
- this.specFrameEntry.unref();
8392
- }
8393
- [Symbol.dispose]() {
8394
- this.dispose();
8395
- }
8396
- findColumns(options) {
8397
- const includeColumns = options?.include ? toMultiColumnSelectors(options.include) : void 0;
8398
- const excludeColumns = options?.exclude ? toMultiColumnSelectors(options.exclude) : void 0;
8399
- return this.specDriver.discoverColumns(this.specFrameEntry.key, {
8400
- includeColumns,
8401
- excludeColumns,
8402
- axes: [],
8403
- maxHops: 0,
8404
- constraints: matchingModeToConstraints("enrichment")
8405
- }).hits.map((hit) => this.columns.get(hit.hit.columnId)).filter((col) => col !== void 0);
8406
- }
8407
- };
8408
- var AnchoredColumnCollectionImpl = class {
8409
- anchorsMap;
8410
- columnsMap;
8411
- specFrameEntry;
8412
- constructor(specDriver, options) {
8413
- this.specDriver = specDriver;
8414
- this.specFrameEntry = this.specDriver.createSpecFrame(Object.fromEntries(options.columns.map((col) => [col.id, col.spec])));
8415
- this.columnsMap = new Map(options.columns.map((col) => [col.id, col]));
8416
- this.anchorsMap = resolveAnchorMap(options.anchors, options.columns, this.specDriver.discoverColumns.bind(this.specDriver, this.specFrameEntry.key));
8417
- }
8418
- dispose() {
8419
- this.specFrameEntry.unref();
8420
- }
8421
- [Symbol.dispose]() {
8422
- this.dispose();
8423
- }
8424
- getAnchors() {
8425
- return this.anchorsMap;
8426
- }
8427
- findColumns(options) {
8428
- const constraints = matchingModeToConstraints(options?.mode ?? "enrichment");
8429
- const includeColumns = options?.include ? toMultiColumnSelectors(options.include) : void 0;
8430
- const excludeColumns = options?.exclude ? toMultiColumnSelectors(options.exclude) : void 0;
8431
- const anchors = Array.from(this.anchorsMap.values());
8432
- const byColumn = this.specDriver.discoverColumns(this.specFrameEntry.key, {
8433
- includeColumns,
8434
- excludeColumns,
8435
- constraints,
8436
- maxHops: options?.maxHops ?? 4,
8437
- axes: anchors.map((anchor) => ({
8438
- axesSpec: anchor.spec.axesSpec,
8439
- qualifications: []
8440
- }))
8441
- }).hits.reduce((acc, hit) => {
8442
- const origId = hit.hit.columnId;
8443
- const col = this.columnsMap.get(origId) ?? throwError(`Column with id ${origId} not found in collection`);
8444
- const path = hit.path.map((step) => {
8445
- if (step.type !== "linker") throw new Error(`Unexpected discover-columns step type: ${step.type}`);
8446
- return { linker: this.columnsMap.get(step.linker.columnId) ?? throwError(`Linker column with id ${step.linker.columnId} not found in collection`) };
8447
- });
8448
- const variants = hit.mappingVariants.map((v) => ({
8449
- path,
8450
- qualifications: remapFromIdxToId(v.qualifications, anchors)
8451
- }));
8452
- const existing = acc.get(origId);
8453
- return acc.set(origId, existing === void 0 ? {
8454
- column: col,
8455
- variants
8456
- } : {
8457
- ...existing,
8458
- variants: [...existing.variants, ...variants]
8459
- });
8460
- }, /* @__PURE__ */ new Map());
8461
- return Array.from(byColumn.values());
8462
- }
8463
- findColumnVariants(options) {
8464
- return this.findColumns(options).flatMap((match) => match.variants.map((variant) => ({
8465
- column: match.column,
8466
- path: variant.path,
8467
- qualifications: variant.qualifications
8468
- })));
8469
- }
8470
- };
8471
- /**
8472
- * Collect all columns from all providers, dedup by NativePObjectId.
8473
- * First source wins.
8474
- */
8475
- function collectColumns(providers) {
8476
- const seen = /* @__PURE__ */ new Set();
8477
- const result = [];
8478
- for (const provider of providers) {
8479
- const columns = provider.getAllColumns();
8480
- for (const col of columns) {
8481
- const nativeId = deriveNativeId(col.spec);
8482
- if (seen.has(nativeId)) continue;
8483
- seen.add(nativeId);
8484
- result.push(col);
8485
- }
8486
- }
8487
- return result;
8488
- }
8489
- /** Normalize ColumnSelector (relaxed, single or array) to MultiColumnSelector[]. */
8490
- function toMultiColumnSelectors(input) {
8491
- return convertColumnSelectorToMultiColumnSelector(input);
8492
- }
8493
- /**
8494
- * Resolve each anchor entry to a ColumnSnapshot from the collected columns.
8495
- * - PObjectId (string): looked up by id in the collected columns
8496
- * - PColumnSpec: matched by deriveNativeId against collected columns
8497
- * - RelaxedColumnSelector: resolved via discoverColumns in "exact" mode;
8498
- * must match exactly one column
8499
- * Throws on unresolved, ambiguous, or duplicated matches. Requires at least one
8500
- * anchor to resolve.
8501
- */
8502
- function resolveAnchorMap(anchors, columns, discoverColumns) {
8503
- const result = /* @__PURE__ */ new Map();
8504
- const resovedIds = /* @__PURE__ */ new Set();
8505
- const getDuplicateError = (key) => `Anchor "${key}": selector matched a column that was already matched by another anchor; please refine the selector to match a different column`;
8506
- for (const [name, anchor] of Object.entries(anchors)) if (typeof anchor === "string") {
8507
- const found = columns.find((col) => col.id === anchor) ?? throwError(`Anchor "${name}": column with id "${anchor}" not found in sources`);
8508
- if (resovedIds.has(found.id)) throwError(getDuplicateError(name));
8509
- result.set(name, found);
8510
- resovedIds.add(found.id);
8511
- } else if ("kind" in anchor) {
8512
- if (!isPColumnSpec(anchor)) throwError(`Anchor "${name}": invalid PColumnSpec`);
8513
- const nativeId = deriveNativeId(anchor);
8514
- const found = columns.find((col) => deriveNativeId(col.spec) === nativeId) ?? throwError(`Anchor "${name}": no column matching spec found in sources`);
8515
- if (resovedIds.has(found.id)) throwError(getDuplicateError(name));
8516
- result.set(name, found);
8517
- resovedIds.add(found.id);
8518
- } else {
8519
- const matched = discoverColumns({
8520
- includeColumns: toMultiColumnSelectors(anchor),
8521
- excludeColumns: void 0,
8522
- axes: [],
8523
- maxHops: 0,
8524
- constraints: matchingModeToConstraints("related")
8525
- });
8526
- if (matched.hits.length === 0) throwError(`Anchor "${name}": no columns matched selector`);
8527
- if (matched.hits.length > 1) throwError(`Anchor "${name}": selector is ambiguous and matched multiple columns; please refine the selector to match exactly one column`);
8528
- if (resovedIds.has(matched.hits[0].hit.columnId)) throwError(getDuplicateError(name));
8529
- const id = matched.hits[0].hit.columnId;
8530
- const snap = columns.find((col) => col.id === id) ?? throwError(`Anchor "${name}": matched column with id "${id}" not found in sources`);
8531
- result.set(name, snap);
8532
- resovedIds.add(snap.id);
8533
- }
8534
- if (resovedIds.size === 0) throwError("At least one anchor must be resolved to a valid column");
8535
- return result;
8536
- }
8537
- function remapFromIdxToId(qualifications, anchors) {
8538
- const forQueries = qualifications.forQueries.reduce((acc, qs, i) => anchors[i] && qs.length > 0 ? acc.set(anchors[i].id, qs) : acc, /* @__PURE__ */ new Map());
8539
- return {
8540
- forQueries: forQueries.size > 0 ? Object.fromEntries(forQueries) : void 0,
8541
- forHit: qualifications.forHit.length > 0 ? qualifications.forHit : void 0
8542
- };
8543
- }
8544
- function matchingModeToConstraints(mode) {
8545
- switch (mode) {
8546
- case "enrichment": return {
8547
- allowFloatingSourceAxes: true,
8548
- allowFloatingHitAxes: false,
8549
- allowSourceQualifications: true,
8550
- allowHitQualifications: true
8551
- };
8552
- case "related": return {
8553
- allowFloatingSourceAxes: true,
8554
- allowFloatingHitAxes: true,
8555
- allowSourceQualifications: true,
8556
- allowHitQualifications: true
8557
- };
8558
- case "exact": return {
8559
- allowFloatingSourceAxes: false,
8560
- allowFloatingHitAxes: false,
8561
- allowSourceQualifications: false,
8562
- allowHitQualifications: false
8563
- };
8564
- }
8180
+ //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/pframe_utils/columns.js
8181
+ function getAllRelatedColumns(ctx, predicate) {
8182
+ const columns = new PColumnCollection();
8183
+ columns.addColumnProvider(ctx.resultPool);
8184
+ const allColumns = columns.getColumns(predicate, {
8185
+ dontWaitAllData: true,
8186
+ overrideLabelAnnotation: false
8187
+ }) ?? [];
8188
+ return enrichCompatible(new Map(allColumns.flatMap((column) => getNormalizedAxesList(column.spec.axesSpec)).map((axisSpec) => {
8189
+ return [canonicalizeJson(getAxisId(axisSpec)), axisSpec];
8190
+ })), allColumns);
8191
+ }
8192
+ function getRelatedColumns(ctx, { columns: rootColumns, predicate }) {
8193
+ const columns = new PColumnCollection();
8194
+ columns.addColumnProvider(ctx.resultPool);
8195
+ columns.addColumns(rootColumns);
8196
+ const blockAxes = /* @__PURE__ */ new Map();
8197
+ const allAxes = /* @__PURE__ */ new Map();
8198
+ for (const c of rootColumns) for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
8199
+ const aid = getAxisId(spec);
8200
+ blockAxes.set(canonicalizeJson(aid), spec);
8201
+ allAxes.set(canonicalizeJson(aid), spec);
8202
+ }
8203
+ const availableWithLinkersAxes = getAvailableWithLinkersAxes(columns.getColumns((spec) => predicate(spec) && isLinkerColumn(spec), { dontWaitAllData: true }) ?? [], blockAxes);
8204
+ for (const item of availableWithLinkersAxes) {
8205
+ blockAxes.set(...item);
8206
+ allAxes.set(...item);
8207
+ }
8208
+ const blockAxesArr = Array.from(blockAxes.values());
8209
+ let compatibleWithoutLabels = (columns.getColumns((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
8210
+ const axisId = getAxisId(axisSpec);
8211
+ return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
8212
+ }), {
8213
+ dontWaitAllData: true,
8214
+ overrideLabelAnnotation: false
8215
+ }) ?? []).filter((column) => !isLabelColumn(column.spec));
8216
+ for (const c of compatibleWithoutLabels) for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {
8217
+ const aid = getAxisId(spec);
8218
+ allAxes.set(canonicalizeJson(aid), spec);
8219
+ }
8220
+ const allAxesArr = Array.from(allAxes.values());
8221
+ compatibleWithoutLabels = (columns.getColumns((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {
8222
+ const axisId = getAxisId(axisSpec);
8223
+ return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
8224
+ }), {
8225
+ dontWaitAllData: true,
8226
+ overrideLabelAnnotation: false
8227
+ }) ?? []).filter((column) => !isLabelColumn(column.spec));
8228
+ const compatibleLabels = (columns.getColumns((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {
8229
+ const axisId = getAxisId(axisSpec);
8230
+ return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));
8231
+ }), {
8232
+ dontWaitAllData: true,
8233
+ overrideLabelAnnotation: false
8234
+ }) ?? []).filter((column) => isLabelColumn(column.spec));
8235
+ return enrichCompatible(blockAxes, [...compatibleWithoutLabels, ...compatibleLabels]);
8565
8236
  }
8566
8237
  //#endregion
8567
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/columns/ctx_column_sources.js
8568
- /**
8569
- * Collect ColumnSnapshotProviders from `outputs`, `prerun`, and
8570
- * `resultPool` in that order. Dedup keeps the first occurrence per
8571
- * `NativePObjectId`, so a block re-publishing its own columns keeps
8572
- * the `outputs`-rooted canonical id instead of the result-pool variant.
8573
- */
8574
- function collectCtxColumnSnapshotProviders(ctx) {
8575
- const providers = [];
8576
- const outputs = ctx.outputs;
8577
- if (outputs) providers.push(...collectPFrameProviders(outputs));
8578
- const prerun = ctx.prerun;
8579
- if (prerun) providers.push(...collectPFrameProviders(prerun));
8580
- providers.push(new ResultPoolColumnSnapshotProvider(ctx.resultPool));
8581
- return providers;
8238
+ //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PFrameForGraphs.js
8239
+ function isHiddenFromGraphColumn(column) {
8240
+ return !!readAnnotationJson(column, Annotation.HideDataFromGraphs);
8582
8241
  }
8583
- /**
8584
- * Adapter wrapping ResultPool into the new ColumnSnapshotProvider interface.
8585
- *
8586
- * - `isColumnListComplete()` always returns true — the result pool
8587
- * is a stable snapshot within a single render cycle.
8588
- * - Data status is derived from the underlying TreeNodeAccessor:
8589
- * ready (getIsReadyOrError), computing, or absent (no data resource).
8590
- */
8591
- var ResultPoolColumnSnapshotProvider = class {
8592
- constructor(pool) {
8593
- this.pool = pool;
8594
- }
8595
- getAllColumns() {
8596
- return this.pool.selectColumns(() => true).map((col) => toSnapshot(col.id, col.spec, col.data));
8597
- }
8598
- isColumnListComplete() {
8599
- return true;
8600
- }
8601
- };
8602
- function toSnapshot(id, spec, accessor) {
8603
- if (accessor === void 0) return {
8604
- id,
8605
- spec,
8606
- dataStatus: "absent",
8607
- data: void 0
8608
- };
8609
- const isReady = accessor.getIsReadyOrError();
8610
- return {
8611
- id,
8612
- spec,
8613
- dataStatus: isReady ? "ready" : "computing",
8614
- data: { get: () => isReady ? accessor : void 0 }
8615
- };
8242
+ function isHiddenFromUIColumn(column) {
8243
+ return !!readAnnotationJson(column, Annotation.HideDataFromUi);
8616
8244
  }
8617
8245
  /**
8618
- * Recursively walk the output tree starting from `accessor`.
8619
- * - If a node's resourceType is PFrame → wrap it as OutputColumnProvider.
8620
- * - If a node's resourceType is StdMap/std/map recurse into its output fields.
8621
- * - Otherwise skip (leaf of unknown type).
8246
+ The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool
8247
+ (including linker columns and all label columns).
8248
+ Block’s columns are added to pframe as is.
8249
+ Other columns are added basing on set of axes of block’s columns, considering available with linker columns.
8250
+ Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from
8251
+ result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values
8252
+ among existing ones).
8253
+ In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case
8254
+ of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)
8255
+ and modified label (with added domain values in case if more than one copy with different domains exist).
8622
8256
  */
8623
- function collectPFrameProviders(accessor) {
8624
- const out = [];
8625
- walkTree(accessor, out);
8626
- return out;
8627
- }
8628
- function walkTree(node, out) {
8629
- const typeName = node.resourceType.name;
8630
- if (typeName === ResourceTypeName.PFrame) {
8631
- out.push(new OutputColumnProvider(node));
8632
- return;
8633
- }
8634
- if (typeName === ResourceTypeName.StdMap || typeName === ResourceTypeName.StdMapSlash) for (const field of node.listInputFields()) {
8635
- const child = node.resolve(field);
8636
- if (child) walkTree(child, out);
8637
- }
8257
+ function createPFrameForGraphs(ctx, blockColumns) {
8258
+ const suitableSpec = (spec) => !isHiddenFromUIColumn(spec) && !isHiddenFromGraphColumn(spec);
8259
+ if (!blockColumns) return ctx.createPFrame(getAllRelatedColumns(ctx, suitableSpec));
8260
+ return ctx.createPFrame(getRelatedColumns(ctx, {
8261
+ columns: blockColumns,
8262
+ predicate: suitableSpec
8263
+ }));
8638
8264
  }
8639
8265
  //#endregion
8640
8266
  //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/filters/traverse.js
@@ -9325,283 +8951,64 @@
9325
8951
  };
9326
8952
  }
9327
8953
  //#endregion
9328
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/labels/derive_distinct_tooltips.js
9329
- /** Format tooltip strings for each entry. Returns `undefined` when nothing useful. */
9330
- function deriveDistinctTooltips(entries) {
9331
- return entries.map(formatTooltip);
9332
- }
9333
- function formatTooltip(entry) {
9334
- const sections = [];
9335
- const header = formatHeader(entry);
9336
- if (header !== void 0) sections.push(header);
9337
- const origin = formatOriginPath(entry);
9338
- if (origin !== void 0) sections.push(origin);
9339
- const anchors = formatAnchors(entry.qualifications);
9340
- if (anchors !== void 0) sections.push(anchors);
9341
- const hit = formatHit(entry.qualifications);
9342
- if (hit !== void 0) sections.push(hit);
9343
- if (sections.length <= 1) return void 0;
9344
- return sections.join("\n\n");
9345
- }
9346
- const BULLET_1 = " • ";
9347
- function formatHeader(entry) {
9348
- const lines = [];
9349
- if (entry.variantCount !== void 0 && entry.variantCount > 1) lines.push(`Variant: ${entry.variantIndex ?? "?"} of ${entry.variantCount}`);
9350
- return lines.join("\n");
9351
- }
9352
- function formatOriginPath(entry) {
9353
- const path = entry.linkerPath ?? [];
9354
- if (path.length === 0) return void 0;
9355
- const lines = ["Origin path"];
9356
- path.forEach((step, i) => {
9357
- const label = readAnnotation(step.linker.spec, Annotation.LinkLabel) ?? readAnnotation(step.linker.spec, Annotation.Label) ?? step.linker.spec.name;
9358
- lines.push(`${BULLET_1}linker ${i + 1}: ${label}`);
9359
- });
9360
- const hitName = readAnnotation(entry.spec, Annotation.Label) ?? entry.spec.name;
9361
- lines.push(`${BULLET_1}hit column: ${hitName}`);
9362
- return lines.join("\n");
9363
- }
9364
- function formatAnchors(q) {
9365
- if (isNil(q)) return void 0;
9366
- if (isNil(q.forQueries)) return void 0;
9367
- const ids = Object.keys(q.forQueries);
9368
- if (ids.length === 0) return void 0;
9369
- const lines = [];
9370
- for (const id of ids) {
9371
- const item = q.forQueries[id];
9372
- if (item.length === 0) continue;
9373
- const rendered = formatAxisQualifications(item);
9374
- lines.push(`${BULLET_1}${id}${rendered !== void 0 ? ` ${rendered}` : ""}`);
9375
- }
9376
- return lines.length > 0 ? ["Anchors (bound via this variant)"].concat(lines).join("\n") : void 0;
9377
- }
9378
- function formatHit(q) {
9379
- if (isNil(q) || isNil(q.forHit) || q.forHit.length === 0) return void 0;
9380
- const rendered = formatAxisQualifications(q.forHit);
9381
- if (rendered === void 0) return void 0;
9382
- return ["Hit column qualifications", `${BULLET_1}${rendered}`].join("\n");
9383
- }
9384
- function formatAxisQualifications(qs) {
9385
- if (qs.length === 0) return void 0;
9386
- return qs.map(formatQualification).join("; ");
9387
- }
9388
- function formatQualification(q) {
9389
- const axisName = typeof q.axis === "string" ? q.axis : q.axis.name ?? JSON.stringify(q.axis);
9390
- const entries = Object.entries(q.contextDomain);
9391
- if (entries.length === 0) return axisName;
9392
- return `${axisName} context: ${entries.map(([k, v]) => `${k}=${v}`).join(", ")}`;
9393
- }
9394
- //#endregion
9395
8954
  //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/createPlDataTable/utils.js
9396
- /** Check if column should be omitted from the table */
9397
- function isColumnHidden(spec) {
9398
- return readAnnotation(spec, Annotation.Table.Visibility) === "hidden";
9399
- }
9400
8955
  /** Check if column is hidden by default */
9401
8956
  function isColumnOptional(spec) {
9402
8957
  return readAnnotation(spec, Annotation.Table.Visibility) === "optional";
9403
8958
  }
9404
- /** Get effective visibility for a column. Rule map lookup first, then annotation fallback. */
9405
- function getEffectiveVisibility(col, visibilityByColId) {
9406
- const rule = visibilityByColId?.get(col.id);
9407
- if (rule !== void 0) return rule.visibility;
9408
- if (isColumnHidden(col.spec)) return "hidden";
9409
- if (isColumnOptional(col.spec)) return "optional";
9410
- }
9411
- /** Get ordering priority for a column. Rule map lookup first, then annotation fallback. */
9412
- function getOrderPriority(col, orderByColId) {
9413
- const rule = orderByColId?.get(col.id);
9414
- if (rule !== void 0) return rule.priority;
9415
- const annotation = Number(readAnnotation(col.spec, Annotation.Table.OrderPriority));
9416
- return isNaN(annotation) ? void 0 : annotation;
9417
- }
9418
- /**
9419
- * Evaluate display rules against a set of columns and return a map of `colId → winning rule`
9420
- * (first-match-wins, preserving original rule order).
9421
- *
9422
- * Predicate-based rules (`ColumnMatcher`) are evaluated directly on the spec.
9423
- * Selector-based rules (`ColumnSelector`) are matched via `PFrameSpecDriver.discoverColumns`
9424
- * using the same engine as `ColumnCollection.findColumns` — no client-side matcher.
9425
- */
9426
- function evaluateRules(rules, columns, pframeSpec) {
9427
- const result = /* @__PURE__ */ new Map();
9428
- if (rules.length === 0 || columns.length === 0) return result;
9429
- const hasSelectorRules = rules.some((rule) => typeof rule.match !== "function");
9430
- const selectorHitsByRule = /* @__PURE__ */ new Map();
9431
- if (hasSelectorRules) {
9432
- const pColumns = dedupeById(columns).map((c) => ({
9433
- id: c.id,
9434
- spec: c.spec,
9435
- data: void 0
9436
- }));
9437
- const collection = new ColumnCollectionBuilder(pframeSpec).addSource(new ArrayColumnProvider(pColumns)).build();
9438
- if (collection === void 0) return result;
9439
- try {
9440
- for (const rule of rules) {
9441
- if (typeof rule.match === "function") continue;
9442
- const hits = collection.findColumns({ include: rule.match });
9443
- selectorHitsByRule.set(rule, new Set(hits.map((h) => h.id)));
9444
- }
9445
- } finally {
9446
- collection.dispose();
8959
+ //#endregion
8960
+ //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/labels.js
8961
+ /** Get label columns matching the provided columns from the result pool */
8962
+ function getMatchingLabelColumns(columns, allLabelColumns) {
8963
+ const inputLabelColumns = [];
8964
+ const inputValueColumns = [];
8965
+ for (const column of columns) if (isLabelColumn(column.spec)) inputLabelColumns.push(column);
8966
+ else inputValueColumns.push(column);
8967
+ const unlabeledAxes = [];
8968
+ for (const column of inputValueColumns) for (const axis of column.spec.axesSpec) {
8969
+ const axisId = getAxisId(axis);
8970
+ if (!unlabeledAxes.some((id) => matchAxisId(id, axisId))) unlabeledAxes.push(axisId);
8971
+ }
8972
+ for (const labelColumn of inputLabelColumns) {
8973
+ const labelAxisId = getAxisId(labelColumn.spec.axesSpec[0]);
8974
+ const labelMatch = unlabeledAxes.findIndex((axisId) => matchAxisId(axisId, labelAxisId));
8975
+ if (labelMatch !== -1) unlabeledAxes.splice(labelMatch, 1);
8976
+ }
8977
+ const colId = (id, domain, contextDomain) => {
8978
+ let wid = id.toString();
8979
+ if (domain) for (const k in domain) {
8980
+ wid += k;
8981
+ wid += domain[k];
8982
+ }
8983
+ if (contextDomain) for (const k in contextDomain) {
8984
+ wid += k;
8985
+ wid += contextDomain[k];
8986
+ }
8987
+ return wid;
8988
+ };
8989
+ const labelColumns = [];
8990
+ for (const labelColumn of allLabelColumns) {
8991
+ const labelAxis = labelColumn.spec.axesSpec[0];
8992
+ const labelAxisId = getAxisId(labelAxis);
8993
+ const labelMatch = unlabeledAxes.findIndex((axisId) => matchAxisId(axisId, labelAxisId));
8994
+ if (labelMatch !== -1) {
8995
+ const axisId = unlabeledAxes[labelMatch];
8996
+ if (Object.keys(axisId.domain ?? {}).length + Object.keys(axisId.contextDomain ?? {}).length > Object.keys(labelAxis.domain ?? {}).length + Object.keys(labelAxis.contextDomain ?? {}).length) labelColumns.push({
8997
+ id: colId(labelColumn.id, axisId.domain, axisId.contextDomain),
8998
+ spec: {
8999
+ ...labelColumn.spec,
9000
+ axesSpec: [{
9001
+ ...axisId,
9002
+ annotations: labelAxis.annotations
9003
+ }]
9004
+ },
9005
+ data: labelColumn.data
9006
+ });
9007
+ else labelColumns.push(labelColumn);
9008
+ unlabeledAxes.splice(labelMatch, 1);
9447
9009
  }
9448
9010
  }
9449
- for (const col of columns) for (const rule of rules) if (typeof rule.match === "function" ? rule.match(col.spec) : selectorHitsByRule.get(rule)?.has(col.id) ?? false) {
9450
- result.set(col.id, rule);
9451
- break;
9452
- }
9453
- return result;
9454
- }
9455
- function dedupeById(columns) {
9456
- const seen = /* @__PURE__ */ new Set();
9457
- const result = [];
9458
- for (const col of columns) {
9459
- if (seen.has(col.id)) continue;
9460
- seen.add(col.id);
9461
- result.push(col);
9462
- }
9463
- return result;
9464
- }
9465
- /**
9466
- * Writes derived labels into column and axis annotations.
9467
- * Returns new column objects with modified specs — original columns are not mutated.
9468
- *
9469
- * For each column: writes derived label into Annotation.Label (if present in derivedLabels).
9470
- * For each axis in column specs: writes derived axis label into AxisSpec annotations.
9471
- */
9472
- function withLabelAnnotations(derivedLabels, columns) {
9473
- if (derivedLabels === void 0) return columns;
9474
- return columns.map((col) => {
9475
- const colLabel = derivedLabels[col.id];
9476
- return {
9477
- ...col,
9478
- spec: {
9479
- ...col.spec,
9480
- ...isNil(colLabel) ? {} : { annotations: {
9481
- ...col.spec.annotations,
9482
- [Annotation.Label]: colLabel
9483
- } },
9484
- axesSpec: col.spec.axesSpec.map((axis) => {
9485
- const label = derivedLabels[canonicalizeAxisId(axis)];
9486
- return isNil(label) ? axis : {
9487
- ...axis,
9488
- annotations: {
9489
- ...axis.annotations,
9490
- [Annotation.Label]: label
9491
- }
9492
- };
9493
- })
9494
- }
9495
- };
9496
- });
9497
- }
9498
- function withDataStatusAnnotations(columns) {
9499
- return columns.map((col) => {
9500
- return {
9501
- ...col,
9502
- spec: {
9503
- ...col.spec,
9504
- annotations: {
9505
- ...col.spec.annotations,
9506
- [Annotation.DataStatus]: col.dataStatus
9507
- }
9508
- }
9509
- };
9510
- });
9511
- }
9512
- /**
9513
- * Writes effective display properties (OrderPriority, Visibility) from precomputed rule maps
9514
- * into column annotations. Returns new column objects — originals are not mutated.
9515
- */
9516
- function withTableVisualAnnotations(visibilityByColId, orderByColId, columns) {
9517
- if (visibilityByColId === void 0 && orderByColId === void 0) return columns;
9518
- return columns.map((col) => {
9519
- const annotations = { ...col.spec.annotations };
9520
- const visibility = getEffectiveVisibility(col, visibilityByColId);
9521
- if (!isNil(visibility)) annotations[Annotation.Table.Visibility] = visibility;
9522
- const orderPriority = getOrderPriority(col, orderByColId);
9523
- if (!isNil(orderPriority)) annotations[Annotation.Table.OrderPriority] = String(orderPriority);
9524
- return {
9525
- ...col,
9526
- spec: {
9527
- ...col.spec,
9528
- annotations
9529
- }
9530
- };
9531
- });
9532
- }
9533
- /**
9534
- * Writes derived info annotations into column annotations.
9535
- * Columns without an info entry are passed through unchanged.
9536
- */
9537
- function withInfoAnnotations(infoById, columns) {
9538
- if (isNil(infoById)) return columns;
9539
- return columns.map((col) => {
9540
- const info = infoById[col.id];
9541
- if (isNil(info)) return col;
9542
- return {
9543
- ...col,
9544
- spec: {
9545
- ...col.spec,
9546
- annotations: {
9547
- ...col.spec.annotations,
9548
- [Annotation.Table.Info]: info
9549
- }
9550
- }
9551
- };
9552
- });
9553
- }
9554
- function withHidenAxesAnnotations(columns) {
9555
- return columns.map((col) => ({
9556
- ...col,
9557
- spec: {
9558
- ...col.spec,
9559
- axesSpec: col.spec.axesSpec.map((axis) => ({
9560
- ...axis,
9561
- annotations: {
9562
- ...axis.annotations,
9563
- [Annotation.Table.Visibility]: "hidden"
9564
- }
9565
- }))
9566
- }
9567
- }));
9568
- }
9569
- /** Derive labels for all table elements: columns via deriveDistinctLabels, axes from label columns. */
9570
- function deriveAllLabels(options) {
9571
- const { columns, deriveLabelsOptions } = options;
9572
- return deriveDistinctLabels(columns.map((c) => ({
9573
- spec: c.spec,
9574
- linkerPath: c.linkerPath?.map((step) => ({ spec: step.linker.spec })),
9575
- qualifications: c.qualifications
9576
- })), deriveLabelsOptions).reduce((acc, label, index) => (acc[columns[index].id] = label, acc), {});
9577
- }
9578
- /** Derive origin tooltips for columns whose qualifications or linker path carry info. */
9579
- function deriveAllTooltips(options) {
9580
- const { columns } = options;
9581
- const variantCountByOriginal = columns.reduce((acc, c) => {
9582
- return acc.set(getField(c, "originalId") ?? c.id, (acc.get(c.originalId ?? c.id) ?? 0) + 1);
9583
- }, /* @__PURE__ */ new Map());
9584
- const { entries } = columns.reduce(({ entries, variantSeen }, c) => {
9585
- const id = getField(c, "originalId") ?? c.id;
9586
- const variantCount = variantCountByOriginal.get(id);
9587
- const variantIndex = (variantSeen.set(id, (variantSeen.get(id) ?? 0) + 1), variantSeen.get(id));
9588
- entries.push({
9589
- spec: c.spec,
9590
- linkerPath: c.linkerPath,
9591
- qualifications: c.qualifications,
9592
- variantIndex,
9593
- variantCount
9594
- });
9595
- return {
9596
- entries,
9597
- variantSeen
9598
- };
9599
- }, {
9600
- entries: [],
9601
- variantSeen: /* @__PURE__ */ new Map()
9602
- });
9603
- const tooltips = deriveDistinctTooltips(entries);
9604
- return Object.fromEntries(tooltips.flatMap((t, i) => isNil(t) ? [] : [[columns[i].id, t]]));
9011
+ return labelColumns;
9605
9012
  }
9606
9013
  //#endregion
9607
9014
  //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.js
@@ -9675,387 +9082,126 @@
9675
9082
  };
9676
9083
  }
9677
9084
  //#endregion
9678
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/createPlDataTable/discoverColumns.js
9679
- /** Discover columns from sources/anchors and normalize into a flat TableColumnVariant list. */
9680
- function discoverTableColumnSnaphots(ctx, options) {
9681
- const resolvedOptions = {
9682
- ...options,
9683
- anchors: resolveAnchors$1(ctx, options.anchors)
9684
- };
9685
- const providers = resolveProviders(ctx, resolvedOptions.sources);
9686
- if (providers.length === 0) return void 0;
9687
- const collection = new ColumnCollectionBuilder(ctx.getService("pframeSpec")).addSources(providers).build(resolvedOptions);
9688
- if (collection === void 0) return void 0;
9689
- try {
9690
- return mapToTableColumnVariants(collection.findColumnVariants(resolvedOptions.selector), collection.getAnchors());
9691
- } finally {
9692
- collection.dispose();
9693
- }
9085
+ //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.js
9086
+ function createPTableDefV2(params) {
9087
+ let coreColumns = params.columns;
9088
+ const secondaryColumns = [];
9089
+ if (isFunction(params.coreColumnPredicate)) {
9090
+ coreColumns = [];
9091
+ for (const c of params.columns) if (params.coreColumnPredicate(getColumnIdAndSpec(c))) coreColumns.push(c);
9092
+ else secondaryColumns.push(c);
9093
+ }
9094
+ secondaryColumns.push(...params.labelColumns);
9095
+ return createPTableDefV3({
9096
+ primary: coreColumns.map((column) => ({ column })),
9097
+ secondary: secondaryColumns.map((column) => ({ entries: [{ column }] })),
9098
+ primaryJoinType: params.coreJoinType,
9099
+ filters: params.filters,
9100
+ sorting: params.sorting
9101
+ });
9694
9102
  }
9103
+ //#endregion
9104
+ //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js
9695
9105
  /**
9696
- * Discover label columns matching the axes of the given value columns from
9697
- * ctx providers. Returns label snapshots wrapped as direct TableColumnVariants
9698
- * (path: [], empty qualifications, isPrimary: false).
9106
+ * Create p-table spec and handle given ui table state
9107
+ *
9108
+ * @deprecated This version of createPlDataTable is deprecated and will be removed in future. Please migrate to v3 by switching to the new options format and providing necessary information for column discovery and display configuration. See createPlDataTableOptionsV3 for details.
9109
+ * @param ctx context
9110
+ * @param columns column list
9111
+ * @param tableState table ui state
9112
+ * @returns PlAgDataTableV2 table source
9699
9113
  */
9700
- function discoverLabelColumnVariants(ctx, columns) {
9701
- if (columns.length === 0) return [];
9702
- const collection = new ColumnCollectionBuilder(ctx.getService("pframeSpec")).addSources(collectCtxColumnSnapshotProviders(ctx)).addSource(columns.map((c) => c.column)).build({
9703
- allowPartialColumnList: true,
9704
- anchors: Object.fromEntries(columns.filter((col) => (col.path?.length ?? 0) === 0 && col.isPrimary).map((col, i) => [`anchor_${i}`, col.column.spec]))
9705
- });
9706
- try {
9707
- const axes = columns.flatMap((col) => col.column.spec.axesSpec);
9708
- return collection.findColumnVariants({
9709
- include: axes.map((a) => ({
9710
- name: {
9711
- type: "exact",
9712
- value: PColumnName.Label
9713
- },
9714
- axes: [{ name: {
9715
- type: "exact",
9716
- value: a.name
9717
- } }]
9718
- })),
9719
- maxHops: columns.reduce((acc, c) => Math.max(acc, c.path?.length ?? 0), 0)
9720
- }).map((variant) => ({
9721
- ...variant,
9722
- column: {
9723
- ...variant.column,
9724
- id: createDiscoveredPColumnId({
9725
- column: variant.column.id,
9726
- path: variant.path?.map((p) => ({
9727
- type: "linker",
9728
- column: p.linker.id
9729
- })),
9730
- columnQualifications: variant.qualifications?.forHit,
9731
- queriesQualifications: variant.qualifications?.forQueries
9732
- }),
9733
- originalId: variant.column.id
9734
- }
9735
- }));
9736
- } finally {
9737
- collection.dispose();
9738
- }
9739
- }
9740
- /** Resolve PlRef values in anchors to PColumnSpec via the result pool. */
9741
- function resolveAnchors$1(ctx, anchors) {
9742
- const result = {};
9743
- for (const [key, value] of Object.entries(anchors)) if (isPlRef(value)) result[key] = ctx.resultPool.getPColumnSpecByRef(value) ?? throwError(`Anchor ${key} with ref ${JSON.stringify(value)} could not be resolved to a PColumnSpec`);
9744
- else result[key] = value;
9745
- return result;
9746
- }
9747
- /** Resolve column snapshot providers from explicit sources or context. */
9748
- function resolveProviders(ctx, sources) {
9749
- return sources !== void 0 ? sources.map(toColumnSnapshotProvider) : collectCtxColumnSnapshotProviders(ctx);
9750
- }
9751
- /** Map column variants into TableColumnVariant list with anchor-derived isPrimary flag. */
9752
- function mapToTableColumnVariants(variants, anchors) {
9753
- const columnIdToAnchorName = new Map(Array.from(anchors.entries(), ([key, { id }]) => [id, key]));
9754
- return variants.map((variant) => {
9755
- const snap = variant.column;
9756
- const isPrimary = columnIdToAnchorName.get(snap.id) !== void 0;
9114
+ function createPlDataTableV2(ctx, columns, tableState, options) {
9115
+ if (columns.length === 0) return void 0;
9116
+ const tableStateNormalized = upgradePlDataTableStateV2(tableState);
9117
+ const allLabelColumns = getAllLabelColumns(ctx.resultPool) ?? [];
9118
+ let fullLabelColumns = getMatchingLabelColumns(columns, allLabelColumns);
9119
+ fullLabelColumns = deriveLabels(fullLabelColumns, identity, { includeNativeLabel: true }).map((v) => {
9757
9120
  return {
9758
- column: {
9759
- id: createDiscoveredPColumnId({
9760
- column: snap.id,
9761
- path: variant.path?.map((p) => ({
9762
- type: "linker",
9763
- column: p.linker.id
9764
- })),
9765
- columnQualifications: variant.qualifications?.forHit,
9766
- queriesQualifications: variant.qualifications?.forQueries
9767
- }),
9768
- spec: snap.spec,
9769
- data: snap.data,
9770
- dataStatus: snap.dataStatus
9771
- },
9772
- path: variant.path,
9773
- qualifications: variant.qualifications,
9774
- originalId: snap.id,
9775
- isPrimary
9121
+ ...v.value,
9122
+ spec: {
9123
+ ...v.value.spec,
9124
+ annotations: {
9125
+ ...v.value.spec.annotations,
9126
+ [Annotation.Label]: v.label
9127
+ }
9128
+ }
9776
9129
  };
9777
9130
  });
9778
- }
9779
- //#endregion
9780
- //#region ../node_modules/.pnpm/@platforma-sdk+model@1.75.5/node_modules/@platforma-sdk/model/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js
9781
- function createPlDataTableV3(ctx, options) {
9782
- const pframeSpec = ctx.getService("pframeSpec");
9783
- const state = upgradePlDataTableStateV2(options.tableState);
9784
- const primaryJoinType = options.primaryJoinType ?? "full";
9785
- const discovered = isPlainObject(options.columns) ? discoverTableColumnSnaphots(ctx, options.columns) : isNil$1(options.columns) ? options.columns : uniqueBy([...options.columns, ...discoverLabelColumnVariants(ctx, options.columns)], (c) => c.column.id);
9786
- if (isNil$1(discovered) || discovered.length === 0) return void 0;
9787
- const splited = splitDiscoveredColumns(discovered);
9788
- const derivedLabels = deriveAllLabels({
9789
- columns: discovered.map((dc) => ({
9790
- id: dc.column.id,
9791
- spec: dc.column.spec,
9792
- linkerPath: dc.path,
9793
- qualifications: dc.qualifications
9794
- })).filter((v) => !isColumnHidden(v.spec)),
9795
- deriveLabelsOptions: {
9796
- includeNativeLabel: true,
9797
- ...options.labelsOptions
9798
- }
9799
- });
9800
- const derivedTooltips = deriveAllTooltips({ columns: discovered.map((dc) => ({
9801
- id: dc.column.id,
9802
- originalId: getField(dc, "originalId"),
9803
- spec: dc.column.spec,
9804
- linkerPath: dc.path,
9805
- qualifications: dc.qualifications
9806
- })) });
9807
- const annotated = annotateColumnGroups({
9808
- pframeSpec,
9809
- ...splited,
9810
- derivedLabels,
9811
- derivedTooltips,
9812
- displayOptions: options.displayOptions
9813
- });
9814
- const primarySnapshots = annotated.direct.filter((c) => c.isPrimary);
9815
- const secondarySnapshots = annotated.direct.filter((c) => !c.isPrimary);
9816
- if (primarySnapshots.length === 0) return void 0;
9817
- const columnIsAvailable = createColumnValidationById([...annotated.direct.map((v) => v.column), ...annotated.linked.flatMap((lc) => [...(lc.path ?? []).map((s) => s.linker), lc.column])]);
9818
- const remapedDefaultFilters = remapFilterColumnIds(options.filters, discovered);
9819
- const filters = filterFilters(concatFilters(state.pTableParams.filters, state.pTableParams.defaultFilters ?? remapedDefaultFilters), columnIsAvailable);
9820
- const sorting = filterSorting(resolveSorting(state.pTableParams.sorting, remapSortingColumnIds(options.sorting, discovered)), columnIsAvailable);
9821
- const primaryEntries = primarySnapshots.map((v) => ({ column: resolveSnapshot(v.column) }));
9822
- const fullDef = createPTableDefV3({
9823
- primaryJoinType,
9824
- primary: primaryEntries,
9825
- secondary: buildSecondaryGroups(secondarySnapshots, annotated.linked),
9131
+ const fullColumns = [...columns, ...fullLabelColumns];
9132
+ const fullColumnsIds = [...uniqueBy(fullColumns.flatMap((c) => c.spec.axesSpec.map((a) => getAxisId(a))), (a) => canonicalizeJson(a)).map((a) => ({
9133
+ type: "axis",
9134
+ id: a
9135
+ })), ...fullColumns.map((c) => ({
9136
+ type: "column",
9137
+ id: c.id
9138
+ }))];
9139
+ const fullColumnsIdsSet = new Set(fullColumnsIds.map((c) => canonicalizeJson(c)));
9140
+ const isValidColumnId = (id) => fullColumnsIdsSet.has(id);
9141
+ const filters = tableStateNormalized.pTableParams.filters;
9142
+ const defaultFilters = options?.filters ?? void 0;
9143
+ const firstInvalidFilterColumn = (filters !== null ? collectFilterSpecColumns(filters) : []).find((col) => !isValidColumnId(col));
9144
+ if (firstInvalidFilterColumn) throw new Error(`Invalid filter column ${firstInvalidFilterColumn}: column reference does not match the table columns`);
9145
+ const firstInvalidDefaultFilterColumn = (defaultFilters !== void 0 ? collectFilterSpecColumns(defaultFilters) : []).find((col) => !isValidColumnId(col));
9146
+ if (firstInvalidDefaultFilterColumn) throw new Error(`Invalid default filter column ${firstInvalidDefaultFilterColumn}: column reference does not match the table columns`);
9147
+ const userSorting = tableStateNormalized.pTableParams.sorting;
9148
+ const sorting = (isEmpty(userSorting) ? options?.sorting : userSorting) ?? [];
9149
+ const firstInvalidSortingColumn = sorting.find((s) => !isValidColumnId(canonicalizeJson(s.column)));
9150
+ if (firstInvalidSortingColumn) throw new Error(`Invalid sorting column ${JSON.stringify(firstInvalidSortingColumn.column)}: column reference does not match the table columns`);
9151
+ const coreJoinType = options?.coreJoinType ?? "full";
9152
+ const fullDef = createPTableDefV2({
9153
+ columns,
9154
+ labelColumns: fullLabelColumns,
9155
+ coreJoinType,
9826
9156
  filters,
9827
- sorting
9157
+ sorting,
9158
+ coreColumnPredicate: options?.coreColumnPredicate
9828
9159
  });
9829
9160
  const fullHandle = ctx.createPTableV2(fullDef);
9830
- const pframeHandle = ctx.createPFrame([
9831
- ...annotated.direct.map((v) => resolveSnapshot(v.column)),
9832
- ...annotated.linked.map((v) => resolveSnapshot(v.column)),
9833
- ...collectLinkerSnapshots(annotated.linked).map(resolveSnapshot)
9834
- ]);
9835
- const hiddenSpecs = state.pTableParams.hiddenColIds;
9836
- const visible = buildVisibleColumns(annotated, computeHiddenColumns([...annotated.direct, ...annotated.linked].map((v) => v.column), sorting, filters, hiddenSpecs));
9837
- const visibleDef = createPTableDefV3({
9838
- primaryJoinType,
9839
- primary: primaryEntries,
9840
- secondary: buildSecondaryGroups(visible.direct.filter((c) => !c.isPrimary), visible.linked),
9161
+ const pframeHandle = ctx.createPFrame(fullColumns);
9162
+ if (!fullHandle || !pframeHandle) return void 0;
9163
+ const hiddenColumns = new Set((() => {
9164
+ if (coreJoinType === "inner") return [];
9165
+ const hiddenColIds = tableStateNormalized.pTableParams.hiddenColIds;
9166
+ if (hiddenColIds !== null) return hiddenColIds.filter((s) => s.type === "column").map((s) => s.id);
9167
+ return columns.filter((c) => isColumnOptional(c.spec)).map((c) => c.id);
9168
+ })());
9169
+ columns.filter((c) => isLinkerColumn(c.spec)).forEach((c) => hiddenColumns.delete(c.id));
9170
+ const coreColumnPredicate = options?.coreColumnPredicate;
9171
+ if (coreColumnPredicate) columns.flatMap((c) => coreColumnPredicate(getColumnIdAndSpec(c)) ? [c.id] : []).forEach((c) => hiddenColumns.delete(c));
9172
+ sorting.map((s) => s.column).filter((c) => c.type === "column").forEach((c) => hiddenColumns.delete(c.id));
9173
+ if (filters) collectFilterSpecColumns(filters).flatMap((c) => {
9174
+ const obj = parseJson(c);
9175
+ return obj.type === "column" ? [obj.id] : [];
9176
+ }).forEach((c) => hiddenColumns.delete(c));
9177
+ const visibleColumns = columns.filter((c) => !hiddenColumns.has(c.id));
9178
+ const visibleLabelColumns = getMatchingLabelColumns(visibleColumns.map(getColumnIdAndSpec), allLabelColumns);
9179
+ if (!allPColumnsReady([...visibleColumns, ...visibleLabelColumns])) return void 0;
9180
+ const visibleDef = createPTableDefV2({
9181
+ columns: visibleColumns,
9182
+ labelColumns: visibleLabelColumns,
9183
+ coreJoinType,
9841
9184
  filters,
9842
- sorting
9185
+ sorting,
9186
+ coreColumnPredicate
9843
9187
  });
9844
9188
  const visibleHandle = ctx.createPTableV2(visibleDef);
9189
+ if (!visibleHandle) return void 0;
9845
9190
  return {
9846
- sourceId: state.pTableParams.sourceId,
9191
+ sourceId: tableStateNormalized.pTableParams.sourceId,
9847
9192
  fullTableHandle: fullHandle,
9848
9193
  fullPframeHandle: pframeHandle,
9849
9194
  visibleTableHandle: visibleHandle,
9850
- defaultFilters: remapedDefaultFilters
9851
- };
9852
- }
9853
- /** Split discovered columns into direct (no linker path) and linked (with linker path). */
9854
- function splitDiscoveredColumns(columns) {
9855
- return {
9856
- direct: columns.filter((dc) => (dc.path?.length ?? 0) === 0),
9857
- linked: columns.filter((dc) => (dc.path?.length ?? 0) > 0)
9858
- };
9859
- }
9860
- /** All linker snapshots across the given linked columns, deduped by id. */
9861
- function collectLinkerSnapshots(linked) {
9862
- return uniqueBy(linked.flatMap((lc) => (lc.path ?? []).map((s) => s.linker)), (c) => c.id);
9863
- }
9864
- /**
9865
- * Annotate all column groups with derived labels and display-rule annotations.
9866
- * Evaluates `displayOptions` rules against all discovered columns (direct,
9867
- * linked, labels, linkers) and writes the winning visibility/priority into
9868
- * column annotations via `withTableVisualAnnotations`.
9869
- */
9870
- function annotateColumnGroups(params) {
9871
- const { direct, linked, derivedLabels, derivedTooltips, displayOptions, pframeSpec } = params;
9872
- const allColumnsForRules = [
9873
- ...direct.map((v) => v.column),
9874
- ...linked.map((v) => v.column),
9875
- ...collectLinkerSnapshots(linked)
9876
- ];
9877
- const visibilityByColId = evaluateRules(displayOptions?.visibility ?? [], allColumnsForRules, pframeSpec);
9878
- const orderByColId = evaluateRules(displayOptions?.ordering ?? [], allColumnsForRules, pframeSpec);
9879
- return {
9880
- direct: liftToVariantColumns(direct, flow((cols) => withDataStatusAnnotations(cols), (cols) => withLabelAnnotations(derivedLabels, cols), (cols) => withInfoAnnotations(derivedTooltips, cols), (cols) => withTableVisualAnnotations(visibilityByColId, orderByColId, cols))),
9881
- linked: liftToVariantColumns(linked, flow((cols) => withDataStatusAnnotations(cols), (cols) => withHidenAxesAnnotations(cols), (cols) => withLabelAnnotations(derivedLabels, cols), (cols) => withInfoAnnotations(derivedTooltips, cols), (cols) => withTableVisualAnnotations(visibilityByColId, orderByColId, cols))).map((lc) => ({
9882
- ...lc,
9883
- path: annotateLinkerPath(derivedLabels, lc.path)
9884
- }))
9885
- };
9886
- }
9887
- /** Lift a snapshot-array transform so it runs on the inner `column` of each variant. */
9888
- function liftToVariantColumns(variants, fn) {
9889
- const cols = fn(variants.map((v) => v.column));
9890
- if (cols.length !== variants.length) throw new Error(`liftToVariantColumns: fn must preserve array length (got ${cols.length}, expected ${variants.length})`);
9891
- return variants.map((v, i) => ({
9892
- ...v,
9893
- column: cols[i]
9894
- }));
9895
- }
9896
- function annotateLinkerPath(derivedLabels, path) {
9897
- if (isNil$1(path) || path.length === 0) return path;
9898
- const annotatedLinkers = withHidenAxesAnnotations(withLabelAnnotations(derivedLabels, path.map((s) => s.linker)));
9899
- return path.map((s, i) => ({
9900
- ...s,
9901
- linker: annotatedLinkers[i]
9902
- }));
9903
- }
9904
- /** Build an index of all valid column IDs (axes + columns) for filter/sorting validation. */
9905
- function createColumnValidationById(fullColumns) {
9906
- const allIds = [...uniqueBy(fullColumns.flatMap((c) => c.spec.axesSpec.map(getAxisId)), (a) => canonicalizeJson(a)).map((a) => ({
9907
- type: "axis",
9908
- id: a
9909
- })), ...fullColumns.map((c) => ({
9910
- type: "column",
9911
- id: c.id
9912
- }))];
9913
- const validIdSet = new Set(allIds.map((c) => canonicalizeJson(c)));
9914
- return (id) => {
9915
- return validIdSet.has(id);
9916
- };
9917
- }
9918
- /** Drop filter leaves whose column references are not available in the table. */
9919
- function filterFilters(filters, isValidColumnId) {
9920
- if (isNil$1(filters)) return filters;
9921
- const isLeafValid = (leaf) => {
9922
- if (leaf.type === void 0) return true;
9923
- if ("column" in leaf && !isValidColumnId(leaf.column)) return false;
9924
- if ("rhs" in leaf && !isValidColumnId(leaf.rhs)) return false;
9925
- return true;
9926
- };
9927
- const prune = (node) => {
9928
- if (node.type === "and" || node.type === "or") {
9929
- const kept = node.filters.map((f) => prune(f)).filter((f) => !isNil$1(f));
9930
- return {
9931
- type: node.type,
9932
- filters: kept
9933
- };
9934
- }
9935
- if (node.type === "not") {
9936
- const inner = prune(node.filter);
9937
- return isNil$1(inner) ? void 0 : {
9938
- type: "not",
9939
- filter: inner
9940
- };
9941
- }
9942
- return isLeafValid(node) ? node : void 0;
9943
- };
9944
- return prune(filters);
9945
- }
9946
- /** Merge two filter trees into one AND-combined tree. Returns the non-nil one if the other is nil. */
9947
- function concatFilters(a, b) {
9948
- if (isNil$1(a)) return b;
9949
- if (isNil$1(b)) return a;
9950
- return {
9951
- ...a,
9952
- filters: [...a.filters, ...b.filters]
9953
- };
9954
- }
9955
- /** Pick user sorting from state if non-empty, otherwise fall back to options default. */
9956
- function resolveSorting(userSorting, defaultSorting) {
9957
- return (isEmpty(userSorting) ? defaultSorting : userSorting) ?? [];
9958
- }
9959
- /** Drop sorting entries whose column is not available in the table. */
9960
- function filterSorting(sorting, isValidColumnId) {
9961
- return sorting.filter((s) => isValidColumnId(canonicalizeJson(s.column)));
9962
- }
9963
- function buildSecondaryGroups(direct, linked) {
9964
- return [...direct.map((c) => ({
9965
- entries: [{
9966
- column: resolveSnapshot(c.column),
9967
- qualifications: c.qualifications?.forHit
9968
- }],
9969
- primaryQualifications: c.qualifications?.forQueries
9970
- })), ...linked.map((lc) => ({
9971
- entries: [{
9972
- column: resolveSnapshot(lc.column),
9973
- linkers: lc.path?.map((s) => resolveSnapshot(s.linker)),
9974
- qualifications: lc.qualifications?.forHit
9975
- }],
9976
- primaryQualifications: lc.qualifications?.forQueries
9977
- }))];
9978
- }
9979
- /** Determine which columns should be hidden based on state or optional-column defaults. */
9980
- function computeHiddenColumns(columns, sorting, filters, hiddenSpecs) {
9981
- const alwaysHidden = columns.filter((c) => isColumnHidden(c.spec)).map((c) => c.id);
9982
- const optionalHidden = !isNil$1(hiddenSpecs) ? hiddenSpecs.filter((s) => s.type === "column").map((s) => s.id) : columns.filter((c) => isColumnOptional(c.spec)).map((c) => c.id);
9983
- const initial = [...alwaysHidden, ...optionalHidden];
9984
- const preserved = collectPreservedColumnIds(sorting, filters);
9985
- return new Set(initial.filter((id) => !preserved.has(id)));
9986
- }
9987
- /** Collect IDs of columns that must remain visible (sorted, filtered). */
9988
- function collectPreservedColumnIds(sorting, filters) {
9989
- const sortedIds = (sorting ?? []).map((s) => s.column).filter((c) => c.type === "column").map((c) => c.id);
9990
- const filterIds = !isNil$1(filters) ? collectFilterSpecColumns(filters).flatMap((c) => {
9991
- const obj = parseJson(c);
9992
- return obj.type === "column" ? [obj.id] : [];
9993
- }) : [];
9994
- return new Set([...sortedIds, ...filterIds]);
9995
- }
9996
- /** Filter annotated columns to only visible ones, re-matching label columns for the visible subset. */
9997
- function buildVisibleColumns(annotated, hiddenColumns) {
9998
- return {
9999
- direct: annotated.direct.filter((c) => !hiddenColumns.has(c.column.id)),
10000
- linked: annotated.linked.filter((c) => !hiddenColumns.has(c.column.id))
10001
- };
10002
- }
10003
- /** Resolve a ColumnSnapshot to a PColumn with lazily-evaluated data. */
10004
- function resolveSnapshot(snap) {
10005
- return {
10006
- id: snap.id,
10007
- spec: snap.spec,
10008
- data: snap.data?.get()
9195
+ defaultFilters
10009
9196
  };
10010
9197
  }
10011
- /** Remap column references in sorting entries. */
10012
- function remapSortingColumnIds(sorting, columns) {
10013
- return sorting?.flatMap((s) => {
10014
- if (s.column.type === "axis") return [s];
10015
- const id = s.column.id;
10016
- const column = columns.find((c) => (getField(c, "originalId") ?? c.column.id) === id);
10017
- if (column === void 0) return [];
10018
- return [{
10019
- ...s,
10020
- column: {
10021
- type: "column",
10022
- id: column.column.id
10023
- }
10024
- }];
10025
- });
10026
- }
10027
- /** Remap column references in a filter tree. */
10028
- function remapFilterColumnIds(filters, columns) {
10029
- if (isNil$1(filters)) return filters;
10030
- const map = (tableColumnId) => {
10031
- const parsed = parseJson(tableColumnId);
10032
- if (parsed.type === "axis") return tableColumnId;
10033
- const originalId = parsed.id;
10034
- return canonicalizeJson({
10035
- type: "column",
10036
- id: (columns.find((c) => (getField(c, "originalId") ?? c.column.id) === originalId) ?? throwError(`Column ID "${parsed.id}" in filters does not match any discovered column`)).column.id
10037
- });
10038
- };
10039
- return traverseFilterSpec(filters, {
10040
- leaf: (leaf) => {
10041
- if (leaf.type === void 0) return leaf;
10042
- const result = { ...leaf };
10043
- if ("column" in result) result.column = map(result.column);
10044
- if ("rhs" in result) result.rhs = map(result.rhs);
10045
- return result;
10046
- },
10047
- and: (results) => ({
10048
- type: "and",
10049
- filters: results
10050
- }),
10051
- or: (results) => ({
10052
- type: "or",
10053
- filters: results
10054
- }),
10055
- not: (result) => ({
10056
- type: "not",
10057
- filter: result
10058
- })
9198
+ function getAllLabelColumns(resultPool) {
9199
+ return new PColumnCollection().addAxisLabelProvider(resultPool).addColumnProvider(resultPool).getColumns({
9200
+ name: PColumnName.Label,
9201
+ axes: [{}]
9202
+ }, {
9203
+ dontWaitAllData: true,
9204
+ overrideLabelAnnotation: false
10059
9205
  });
10060
9206
  }
10061
9207
  (/* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -10158,38 +9304,7 @@
10158
9304
  if (ctx.data.inputAnchor === void 0) return void 0;
10159
9305
  const ownCols = ctx.outputs?.resolve("propertiesPf")?.getPColumns();
10160
9306
  if (ownCols === void 0) return void 0;
10161
- const info = ctx.outputs?.resolve("info")?.getDataAsJson();
10162
- if (info === void 0) return void 0;
10163
- const tier = info.coverageTier;
10164
- const sources = [new ArrayColumnProvider(ctx.resultPool.selectColumns((spec) => !spec.annotations?.[Annotation.Trace]?.includes("milaboratories.sequence-properties"))), new ArrayColumnProvider(ownCols)];
10165
- return createPlDataTableV3(ctx, {
10166
- tableState: ctx.data.tableState,
10167
- columns: {
10168
- sources,
10169
- anchors: { main: ctx.data.inputAnchor },
10170
- selector: { mode: "enrichment" }
10171
- },
10172
- displayOptions: { visibility: [{
10173
- match: (spec) => {
10174
- if (spec.domain?.["pl7.app/vdj/scClonotypeChain/index"] === "secondary") return false;
10175
- if (spec.domain?.["pl7.app/alphabet"] !== "aminoacid") return false;
10176
- const isVdj = spec.name === "pl7.app/vdj/sequence";
10177
- const isUniversal = spec.name === "pl7.app/sequence";
10178
- if (!isVdj && !isUniversal) return false;
10179
- const feature = isVdj ? spec.domain?.["pl7.app/vdj/feature"] : spec.domain?.["pl7.app/feature"];
10180
- if (tier === "peptide") return isUniversal && feature === "peptide";
10181
- const chain = spec.domain?.["pl7.app/vdj/scClonotypeChain"];
10182
- if (chain !== void 0 && chain !== "A") return false;
10183
- if (tier === "full_chain") return feature === "VDJRegion" || feature === "VDJRegionInFrame";
10184
- if (tier === "cdr3_only" || tier === "partial") return feature === "CDR3";
10185
- return false;
10186
- },
10187
- visibility: "default"
10188
- }, {
10189
- match: (spec) => !spec.annotations?.[Annotation.Trace]?.includes("milaboratories.sequence-properties") && spec.annotations?.["pl7.app/isLinkerColumn"] !== "true",
10190
- visibility: "optional"
10191
- }] }
10192
- });
9307
+ return createPlDataTableV2(ctx, ownCols.filter((c) => c.spec.axesSpec.length === 1), ctx.data.tableState);
10193
9308
  }).outputWithStatus("propertiesPfHandle", (ctx) => {
10194
9309
  const allPCols = ctx.outputs?.resolve("propertiesPf")?.getPColumns();
10195
9310
  if (allPCols === void 0) return void 0;
@@ -10202,7 +9317,7 @@
10202
9317
  anchor: "main",
10203
9318
  idx: 1
10204
9319
  }] }]) ?? []).filter((c) => !c.spec.annotations?.[Annotation.Trace]?.includes("milaboratories.sequence-properties")) : [];
10205
- return ctx.createPFrame([...pCols, ...upstreamMeta]);
9320
+ return createPFrameForGraphs(ctx, [...pCols, ...upstreamMeta]);
10206
9321
  }).output("propertiesPfCols", (ctx) => {
10207
9322
  const pCols = ctx.outputs?.resolve("propertiesPf")?.getPColumns();
10208
9323
  if (pCols === void 0) return void 0;