@pythia-software/query-table-core 0.7.1 → 0.9.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/index.d.ts CHANGED
@@ -40,9 +40,13 @@ type CellDisplay = JsonCellDisplay | ({
40
40
  kind: "chip";
41
41
  labels?: Record<string, string>;
42
42
  tones?: Record<string, "neutral" | "success" | "warning" | "danger">;
43
- } | {
43
+ }
44
+ /** `truncate` keeps one line with an ellipsis. `lines` (1–20) wraps the text
45
+ * and clamps it to that many lines with an ellipsis; it takes precedence. */
46
+ | {
44
47
  kind: "text";
45
48
  truncate?: boolean;
49
+ lines?: number;
46
50
  };
47
51
 
48
52
  type FieldType = "text" | "number" | "enum" | "datetime" | "bool" | "textarray";
@@ -96,7 +100,8 @@ type FilterValues = {
96
100
  source: "freeform";
97
101
  };
98
102
  interface FilterConfig {
99
- /** Opt into the native multi-value editor for textarray fields. */
103
+ /** Opt into the native multi-value editor: ANY/ALL/NONE/EMPTY for textarray
104
+ * fields; ANY/NONE for enum fields and text fields with static options. */
100
105
  editor?: "set";
101
106
  /** Preserve case when matching textarray values. Default false. */
102
107
  arrayCaseSensitive?: boolean;
@@ -351,6 +356,12 @@ interface MetricBoxSummary {
351
356
  whiskers: "minmax" | "tukey";
352
357
  method: "exact-linear";
353
358
  }
359
+ /** One histogram bin: `min <= value < max`, or `<= max` for the final bin. */
360
+ interface MetricHistogramBin {
361
+ min: number;
362
+ max: number;
363
+ inclusiveMax: boolean;
364
+ }
354
365
  type MetricDistributionResult = {
355
366
  kind: "box";
356
367
  summary: MetricBoxSummary | null;
@@ -384,6 +395,10 @@ interface MetricCapabilities {
384
395
  shownRows?: boolean;
385
396
  distributions?: boolean;
386
397
  computedFields?: boolean;
398
+ /** Executes AggregationClause.where. Clauses using it are refused otherwise. */
399
+ filters?: boolean;
400
+ /** Executes AggregationClause.minCount and reports hiddenGroups. */
401
+ minCount?: boolean;
387
402
  maxGroups?: number;
388
403
  profile?: string;
389
404
  }
@@ -467,6 +482,45 @@ declare function readObjectReference<Row>(field: FieldDef<Row>, fields: FieldDef
467
482
  /** Only unambiguous, fully mapped constraints become links. Explicit metadata wins. */
468
483
  declare function discoverFieldRelationships<Row>(fields: FieldDef<Row>[], keys: ForeignKey[], types: ObjectTypeDefinition[]): FieldDef<Row>[];
469
484
 
485
+ type QueryFacet = "filters" | "columns" | "order" | "grouping" | "metrics" | "limit";
486
+ interface QueryPatch {
487
+ /** Host identity for the patch; not interpreted. */
488
+ id: string;
489
+ /** Facets this patch controls. Facets not listed are never touched. */
490
+ owns: QueryFacet[];
491
+ /** Values for the owned facets. A `grouping` value makes this a group-stage
492
+ * patch: its `where` is HAVING and its filters are `grouping.source.where`. */
493
+ query: Partial<QueryState>;
494
+ }
495
+ interface QueryPatchMatch {
496
+ status: "active" | "modified" | "inactive";
497
+ /** Owned facets that differ; only populated when `status` is "modified". */
498
+ modified: QueryFacet[];
499
+ }
500
+ interface ApplyPatchOptions {
501
+ /** A previously applied patch to remove first (see `removePatch`). */
502
+ replacing?: QueryPatch;
503
+ }
504
+ /** Compare a query with a patch. Both are normalized first; column widths,
505
+ * `fitToScreen`, labels, metric display/layout and metric IDs are ignored.
506
+ *
507
+ * - `active`: every owned facet matches.
508
+ * - `modified`: some owned facet differs, but the patch is still recognizable:
509
+ * at least one owned facet matches (an owned `filters` facet with no terms
510
+ * does not count), or at least one of its filter units is still present.
511
+ * - `inactive`: otherwise. */
512
+ declare function matchPatch(query: QueryState, patch: QueryPatch): QueryPatchMatch;
513
+ /** Remove a patch: its filter units that are still fully present are removed;
514
+ * each other owned facet that still matches the patch is reset (columns and
515
+ * order to the schema defaults, metrics to none, grouping exited). Facets the
516
+ * user has since changed, and `limit`, are left alone. Resets offsets to 0. */
517
+ declare function removePatch(query: QueryState, patch: QueryPatch): QueryState;
518
+ /** Apply a patch. Facets it does not own are untouched. Owned non-filter
519
+ * facets are replaced; owned filters are additive: units already present are
520
+ * not duplicated and user-authored terms are never removed. With `replacing`,
521
+ * that patch is first removed with `removePatch`. Resets offsets to 0. */
522
+ declare function applyPatch(query: QueryState, patch: QueryPatch, options?: ApplyPatchOptions): QueryState;
523
+
470
524
  /** Portable datetime/offset bound in milliseconds (also below MAX_SAFE_INTEGER). */
471
525
  declare const MAX_RELATIVE_TIME_MS = 8640000000000000;
472
526
  /** A signed elapsed offset, e.g. -1h or +8d2h10m. The sign applies to the
@@ -481,7 +535,7 @@ interface QueryEvaluationOptions {
481
535
 
482
536
  type GroupedRow = Record<string, unknown>;
483
537
  type Row = GroupedRow;
484
- type SummaryOp = AggOp | "row" | "formula";
538
+ type SummaryOp = AggOp | "row" | "formula" | "link";
485
539
  interface RepresentativeOrder {
486
540
  field: string;
487
541
  dir: "asc" | "desc";
@@ -496,7 +550,63 @@ interface SummaryColumn {
496
550
  field?: string;
497
551
  expression?: string;
498
552
  label?: string;
553
+ /** Cell format for this output column (for example `{ kind: "percent" }` for
554
+ * a weighted rate). Replaces any render/display inherited from the source
555
+ * field; metrics measuring the column default their value format from it. */
556
+ display?: CellDisplay;
557
+ /** Required for `op: "link"`; ignored otherwise. */
558
+ link?: LinkSpec;
559
+ }
560
+ /** Where a link column points. Placeholders and key filters read the group
561
+ * row: its keys and non-link summaries. */
562
+ type LinkDestination =
563
+ /** `{field:name}` placeholders over keys and summaries; values are
564
+ * percent-encoded. The result must be an HTTP(S) or relative URL. */
565
+ {
566
+ kind: "template";
567
+ template: string;
568
+ }
569
+ /** A query composed by query-table and routed by the host's
570
+ * `linkTargets[target](query, params)`. */
571
+ | {
572
+ kind: "query";
573
+ target: string;
574
+ /** "source" (default) starts from `grouping.source`, keeping its
575
+ * filters, columns and order; "empty" starts from `EMPTY_QUERY`. */
576
+ base?: "source" | "empty";
577
+ /** Add `=`/`is_null` per group key, as `groupSourceQuery` does. Default true. */
578
+ keyFilters?: boolean;
579
+ /** Applied last, with `applyPatch`. */
580
+ patch?: QueryPatch;
581
+ /** Static parameters passed to the host target. */
582
+ params?: Record<string, string>;
583
+ };
584
+ /** A group-grain link column (`SummaryColumn` with `op: "link"`). Computed on
585
+ * the client from the returned group row; never sent to a server. */
586
+ interface LinkSpec {
587
+ /** Static text, or the value of a group key or summary column. */
588
+ label: string | {
589
+ column: string;
590
+ };
591
+ to: LinkDestination;
499
592
  }
593
+ /** The value of a link column for one group row: everything that depends on
594
+ * the row. `resolveGroupLink` combines it with the current query and the
595
+ * host's link targets. */
596
+ interface GroupLinkValue {
597
+ kind: "group-link";
598
+ label: string;
599
+ to: LinkDestination | null;
600
+ /** Template links: the substituted, not yet safety-checked href. */
601
+ href?: string;
602
+ /** Query links with key filters: the group's key predicates. */
603
+ terms?: WhereClause[];
604
+ /** Why the link cannot be followed for this row. */
605
+ problem?: string;
606
+ }
607
+ declare const GROUP_LINK_RENDER = "qt_group_link";
608
+ declare function isGroupLinkValue(value: unknown): value is GroupLinkValue;
609
+ declare function isGroupLinkField(field: Pick<FieldDef, "render"> | undefined): boolean;
500
610
  interface GroupingView {
501
611
  version: 2;
502
612
  mode: "rows" | "groups";
@@ -523,6 +633,15 @@ declare const MAX_REPRESENTATIVE_SORTS = 8;
523
633
  declare const MAX_SUMMARY_COLUMNS = 64;
524
634
  declare const MAX_RESULT_GROUPS = 10000;
525
635
  declare function withoutGrouping(query: QueryState): QueryState;
636
+ /** Leave the grouping stage: the source snapshot restores the record WHERE,
637
+ * layout, ordering, paging, metrics and item details. Ungrouped queries are
638
+ * returned unchanged. */
639
+ declare function exitGrouping(query: QueryState): QueryState;
640
+ /** The grouping-key transition behind the grouping controls. Empty keys exit
641
+ * the stage; an ungrouped query becomes the source of a new stage that shows
642
+ * only its keys; a grouped query swaps keys, dropping result columns, HAVING
643
+ * terms and sorts on removed keys and clearing group metrics. */
644
+ declare function withGroupingKeys(query: QueryState, keys: string[]): QueryState;
526
645
  declare const OP_LABEL: Record<SummaryOp, string>;
527
646
  /** Bind aggregation helpers to this instance's source catalogue. */
528
647
  declare function createGroupingModel<InputRow>(inputSchema: FieldSchema<InputRow>): {
@@ -536,6 +655,8 @@ declare function createGroupingModel<InputRow>(inputSchema: FieldSchema<InputRow
536
655
  summaryExpression: (column: SummaryColumn) => string;
537
656
  summaryProblem: (column: SummaryColumn) => string | null;
538
657
  summaryLabel: (column: SummaryColumn) => string;
658
+ linkProblem: (column: SummaryColumn, keys: string[], summaries: SummaryColumn[]) => string | null;
659
+ linkDiagnostics: (definition: Pick<GroupingDefinition, "keys" | "summaries">) => string[];
539
660
  resultSchema: (keys: string[], summaries: SummaryColumn[]) => FieldSchema<Row>;
540
661
  groupRows: (rows: InputRow[], schema: FieldSchema<InputRow>, keys: string[], summaries: SummaryColumn[], rule?: RepresentativeRow | null) => Row[];
541
662
  filteredInput: (rows: InputRow[], query: QueryState, schema: FieldSchema<InputRow>, options?: QueryEvaluationOptions) => InputRow[];
@@ -624,6 +745,10 @@ interface SelectColumn {
624
745
  field: string;
625
746
  /** Pixel width override. Omitted = FieldDef.select.width, else the type default. */
626
747
  width?: number;
748
+ /** Table-cell presentation for this column in this layout, e.g.
749
+ * `{ kind: "text", lines: 3 }`. Takes precedence over the field's `render`
750
+ * and `display`; other surfaces (details, menus, metrics) keep the field's. */
751
+ display?: CellDisplay;
627
752
  }
628
753
  /** A single aggregate operation. `count` is the only op that needs no measure
629
754
  * column (it counts rows); the rest reduce one column's values. The server-side
@@ -661,6 +786,15 @@ interface AggregationClause {
661
786
  groupBy: string[];
662
787
  /** Panel header override; defaults to a derived label like "avg total". */
663
788
  label?: string;
789
+ /** This metric's own row predicate (CNF, like `QueryState.where`), ANDed with
790
+ * the table WHERE before grouping. The table rows are unchanged. In grouped
791
+ * mode it refers to grouped-result fields. Shown-row metrics apply it inside
792
+ * the shown page. */
793
+ where?: WhereTerm[];
794
+ /** Drop groups with fewer than this many rows (counted after `where`) before
795
+ * sorting, `groupLimit` and Other. Requires at least one grouping field;
796
+ * integer 1–1,000,000. Removed groups are reported as `hiddenGroups`. */
797
+ minCount?: number;
664
798
  }
665
799
  /** Detail affordances are presentation state, never backend SELECT fields. */
666
800
  type ItemPropertyMode = "hover" | "modal" | "expand";
@@ -736,7 +870,6 @@ declare function normalizeQueryState(input: unknown, fallback?: QueryState): Que
736
870
  * refetch is actually needed (avoids history spam / redundant fetches). */
737
871
  declare function queriesEqual(a: QueryState, b: QueryState): boolean;
738
872
 
739
- /** Literal templates only: substitution never evaluates code or nested paths. */
740
873
  declare function itemPageFields(template: string): string[];
741
874
  declare function validateItemPageTemplate<Row>(template: string, schema: FieldSchema<Row>): string | null;
742
875
  declare function renderItemPageTemplate<Row>(template: string, schema: FieldSchema<Row>, row: Row, id: RowId | null, query: string): string | null;
@@ -858,6 +991,10 @@ interface AggregationBucket {
858
991
  nullCount?: number;
859
992
  inputErrorCount?: number;
860
993
  distribution?: MetricDistributionResult;
994
+ /** Client-side only: set by the metric UI when one histogram bin of this
995
+ * cohort is inspected (`count`/`value` are then the bin's count). Never part
996
+ * of a transport result. */
997
+ bin?: MetricHistogramBin;
861
998
  /** The metric: a number for count/sum/avg, or the column's value for min/max
862
999
  * (which may be a string for text/datetime). null when undefined (e.g. avg of
863
1000
  * an all-null column). */
@@ -874,6 +1011,9 @@ interface AggregationResultEntry {
874
1011
  processedRows?: number;
875
1012
  groupCount?: number;
876
1013
  coverage?: "exact" | "partial";
1014
+ /** Groups removed by AggregationClause.minCount (present whenever it is set).
1015
+ * They are not part of `groupCount`, `buckets` or `other`. */
1016
+ hiddenGroups?: number;
877
1017
  /** Echoes AggregationClause.id. */
878
1018
  id: string;
879
1019
  buckets: AggregationBucket[];
@@ -1054,6 +1194,14 @@ declare function metricExpression(clause: AggregationClause): string;
1054
1194
  declare function hasRegex(plan: FormulaPlan): boolean;
1055
1195
  declare function metricPlans(c: AggregationClause, schema: FieldSchema, resolve?: (name: string) => FormulaPlan | undefined): FormulaPlan[];
1056
1196
  declare function validateMetric(c: AggregationClause, schema: FieldSchema, resolve?: (name: string) => FormulaPlan | undefined): FormulaDiagnostic[];
1197
+ /** Executor support for population controls, from either capability handshake. */
1198
+ interface MetricPopulationSupport {
1199
+ filters?: boolean | undefined;
1200
+ minCount?: boolean | undefined;
1201
+ }
1202
+ /** A clause the executor cannot run exactly gets its own error; it is never
1203
+ * sent with `where`/`minCount` silently dropped. */
1204
+ declare function metricPopulationError(clause: Pick<AggregationClause, "where" | "minCount">, support: MetricPopulationSupport): string | undefined;
1057
1205
  declare function metricDependencies(c: AggregationClause, schema: FieldSchema, resolve?: (name: string) => FormulaPlan | undefined): string[];
1058
1206
  declare function metricComputationKey(clauses: readonly AggregationClause[]): string;
1059
1207
  declare function toMetricQuery<Row>(q: QueryState, schema: FieldSchema<Row>, execution?: ComputedExecution): MetricQuery;
@@ -1134,6 +1282,10 @@ interface QueryCapabilitiesV3 {
1134
1282
  regex: boolean;
1135
1283
  regexSourceFilters?: boolean;
1136
1284
  regexAggregateExpressions?: boolean;
1285
+ /** Executes AggregationClause.where; clauses using it are refused otherwise. */
1286
+ metricFilters?: boolean;
1287
+ /** Executes AggregationClause.minCount and reports hiddenGroups. */
1288
+ metricMinCount?: boolean;
1137
1289
  maxRows: number;
1138
1290
  maxGroups: number;
1139
1291
  maxPopulation: number;
@@ -1280,8 +1432,18 @@ declare function memoryStorageAdapter(): StorageAdapter;
1280
1432
  * datasets. Falls back to no persistence when storage is unavailable. */
1281
1433
  declare function localStorageAdapter(): StorageAdapter;
1282
1434
 
1283
- /** Compile an explicitly identified editor into existing CNF predicates. */
1284
- declare function createSetFilter(field: string, mode: SetFilterMode, values: string[], id: string): WhereTerm[];
1435
+ /** What a set editor compiles to: array membership (`includes`) for textarray
1436
+ * fields, or scalar equality (`=` / `!=`) for enum and static-option text fields. */
1437
+ type SetFilterTarget = "array" | "scalar";
1438
+ /** The set editor a field opted into with `filter.editor: "set"`, or null.
1439
+ * Text fields qualify only with static `filter.values.options`. */
1440
+ declare function setFilterTarget(field: FieldDef): SetFilterTarget | null;
1441
+ /** Modes a target supports. ALL and EMPTY describe arrays; a scalar holds one value. */
1442
+ declare function setFilterModes(target: SetFilterTarget): SetFilterMode[];
1443
+ /** Compile an explicitly identified editor into existing CNF predicates.
1444
+ * Scalar NONE keeps NULL rows: one `(is_null OR != v)` group per value, because
1445
+ * a bare `!=` is null-exclusive. */
1446
+ declare function createSetFilter(field: string, mode: SetFilterMode, values: string[], id: string, target?: SetFilterTarget): WhereTerm[];
1285
1447
  /** Remove presentation metadata at transport boundaries, including inner literals. */
1286
1448
  declare function stripSetFilter(term: WhereTerm): WhereTerm;
1287
1449
  /** Only collapse explicitly marked, intact editor output. Never infer from predicates. */
@@ -1289,6 +1451,7 @@ declare function readSetFilter(where: WhereTerm[], index: number): {
1289
1451
  field: string;
1290
1452
  metadata: SetFilterMetadata;
1291
1453
  count: number;
1454
+ target: SetFilterTarget;
1292
1455
  } | null;
1293
1456
  /** Canonicalize consumer-owned value aliases without disconnecting editor metadata. */
1294
1457
  declare function mapSetFilterValues(where: WhereTerm[], canonicalize: (field: string, value: string) => string): WhereTerm[];
@@ -1352,4 +1515,55 @@ interface SourceDependencies {
1352
1515
  * inputs and transitive computed/derived dependencies, even when not selected. */
1353
1516
  declare function sourceDependencies<Row>(query: QueryState, schema: FieldSchema<Row>, resolveComputed?: (name: string) => FormulaPlan | undefined): SourceDependencies;
1354
1517
 
1355
- export { AGG_OPS_BY_TYPE, AGG_OPS_NEEDING_FIELD, type AggOp, type AggregateConfig, type AggregationBucket, type AggregationClause, type AggregationRequest, type AggregationResult, type AggregationResultEntry, type Align, type ApplyResult, type BackendField, COMPUTED_PREFIX, type CellDisplay, type CellRenderer, type ColumnPreview, type ComputedCellError, type ComputedColumn, type ComputedColumnDraft, type ComputedColumnStore, type ComputedExecution, type ComputedFieldCapabilities, type DerivedField, type DistinctValuesQuery, type DistinctValuesResult, EMPTY_QUERY, FORMULA_FUNCTIONS, type FetchRowsResult, type FetchRowsResultV2, type FieldDef, type FieldOrigin, type FieldRelationship, type FieldSchema, type FieldSource, type FieldStats, type FieldType, type FilterConfig, type FilterOp, type FilterValues, type ForeignKey, type FormulaDiagnostic, FormulaError, type FormulaFunction, type FormulaNode, type FormulaPlan, type FormulaResult, type FormulaType, type FormulaValue, GROUP_ID_FIELD, type GroupedRow, type GroupingDefinition, type GroupingModel, type GroupingState, type GroupingView, ITEM_DETAILS_COLUMN, type ItemDetailMode, type ItemDetailsState, type ItemPageOptions, type ItemPropertyMode, type JsonCellDisplay, MAX_AGGREGATIONS, MAX_GROUP_BY_FIELDS, MAX_ORDER_BY_TERMS, MAX_PROPERTIES, MAX_QUERY_LIMIT, MAX_QUERY_OFFSET, MAX_QUERY_STATE_BYTES, MAX_QUERY_TOKEN_LENGTH, MAX_RELATIVE_TIME_MS, MAX_REPRESENTATIVE_SORTS, MAX_RESULT_GROUPS, MAX_SELECT_COLUMNS, MAX_SUMMARY_COLUMNS, MAX_WHERE_CLAUSES, METRIC_DATE_INTERVALS, METRIC_FUNCTIONS, type MetricAxisScale, type MetricBoxSummary, type MetricCapabilities, type MetricDateGrouping, type MetricDiagnostic, type MetricDisplay, type MetricDistribution, type MetricDistributionResult, type MetricEvaluationOptions, type MetricKey, type MetricLayout, type MetricPlan, type MetricQuery, type MetricReductionOptions, type MetricScope, type MetricSort, type MetricValue, type MetricValueFormat, NULLARY_OPS, OPS_BY_TYPE, OP_LABEL, type ObjectReference, type ObjectTypeDefinition, type OpChoice, type OpPair, type OrGroup, type OrderByClause, type PreviewGroup, type PropertyFieldConfig, type PropertyFormat, type PropertySelection, type PropertyViewState, type PropertyViewStorage, type QueryCapabilitiesV3, QueryDecodeError, type QueryEvaluationOptions, type QueryLink, type QueryLinkOptions, type QueryLinkService, type QueryRequestV3, type QueryResultV3, type QuerySnapshot, type QuerySnapshotCache, QuerySnapshotHttpError, type QuerySnapshotHttpErrorCode, type QuerySnapshotStore, type QueryState, type RegexInspection, type RelationshipAdapter, type RepresentativeOrder, type RepresentativeRow, type ResolvedObjectReference, type RowComputedValues, type RowId, type SavedPropertyView, type SavedQuery, type SelectColumn, type SelectConfig, type ServerQuery, type ServerQueryV2, type SetFilterMetadata, type SetFilterMode, type SortConfig, type SourceDependencies, type StorageAdapter, type SummaryColumn, type SummaryOp, type Transport, type WhereClause, type WhereTerm, aggOpAllowedForType, aggOpNeedsField, aggOpsForField, applyAggregations, applyQuery, boxSummary, coerceValue, compareMetricValues, compileFormula, compileMetric, computedFieldName, createGroupingModel, createPropertyView, createQueryLinkService, createSetFilter, decodeQuery, decodeQueryStrict, discoverFieldRelationships, encodeQuery, evaluateMetricReductions, evaluateMetrics, filterValues, formulaRuntime, groupPreview, hasRegex, histogramCounts, histogramEdges, httpComputedColumnStore, httpQuerySnapshotStore, indexFields, isComputedCellError, isComputedField, isFilterable, isGroupable, isMeasurable, isNegativePredicate, isOrGroup, isPushdownFilter, isSelectable, isSortable, itemPageFields, jsonPropertyViewStorage, loadSchema, localPropertyViewStorage, localQuerySnapshotCache, localStorageAdapter, mapSetFilterValues, matchesClause, memoryComputedColumnStore, memoryPropertyViewStorage, memoryQuerySnapshotCache, memoryStorageAdapter, metricAggregatePlans, metricComputationKey, metricDateFloor, metricDateNext, metricDateRange, metricDateTime, metricDependencies, metricExpression, metricPlans, negateClause, normalizePropertyFormat, normalizePropertyView, normalizeQueryState, objectReferenceKey, opAllowedForType, opPairsForField, opsForField, parseRelativeDuration, percentile, predicatesOf, prepareGrouping, queriesEqual, readFieldValue, readObjectReference, readSetFilter, reduceMetricValues, renderItemPageTemplate, resolveFieldName, selectMetricShownRows, selectedFields, sourceDependencies, sourceExecutionSchema, stripSetFilter, toAggregationQuery, toMetricQuery, toQueryRequestV3, toServerQuery, toServerQueryV2, validateComputedColumn, validateDateGrouping, validateItemPageTemplate, validateMetric, validateQueryResultV3, validateQuerySnapshot, withoutGrouping };
1518
+ /** The query selecting the records behind one metric bucket, or null when no
1519
+ * exact query exists.
1520
+ *
1521
+ * - Each `clause.groupBy` key adds `=`; a null key adds `is_null` (legacy
1522
+ * aggregates already place empty text in that bucket).
1523
+ * - A date-grouped key becomes `>= start` and `< next`, using the clause's
1524
+ * interval and timezone.
1525
+ * - A histogram bin (`bucket.bin`) adds `>= min` and `< max` (`<= max` for
1526
+ * the final bin) on the distribution input, which must be a field reference.
1527
+ * Box cohorts are their group keys.
1528
+ * - The clause's own `where` is added first, so the records match the metric's
1529
+ * population. Groups hidden by `minCount` have no bucket to inspect.
1530
+ * - Over a grouped query the filters are HAVING terms on the group rows.
1531
+ * - `scope: "shownRows"`, a remainder bucket (keys that do not match the
1532
+ * grouping) and keys on fields that cannot be filtered return null.
1533
+ *
1534
+ * Existing terms are kept, duplicates are not added and the offset resets. */
1535
+ declare function inspectBucketQuery(query: QueryState, bucket: AggregationBucket, clause: AggregationClause, schema: FieldSchema): QueryState | null;
1536
+ /** The record query behind one grouped row, or null when the query is not
1537
+ * grouped or a key cannot be matched exactly (textarray, unknown or
1538
+ * unfilterable fields, unparseable datetimes).
1539
+ *
1540
+ * Starts from the grouping source, as leaving the grouping stage does, so its
1541
+ * WHERE, columns, order and item details are kept. Each key adds `=` (or
1542
+ * `is_null` for a null key) and the offset resets. */
1543
+ declare function groupSourceQuery(query: QueryState, group: GroupedRow, schema: FieldSchema): QueryState | null;
1544
+
1545
+ /** Host routes for query-kind links, keyed by `LinkSpec.to.target`. Each
1546
+ * returns an href; it is safety-checked before rendering. */
1547
+ type LinkTargets = Record<string, (query: QueryState, params: Record<string, string>) => string>;
1548
+ interface ResolvedGroupLink {
1549
+ label: string;
1550
+ /** Not yet safety-checked; null when the link cannot be followed. */
1551
+ href: string | null;
1552
+ problem?: string;
1553
+ }
1554
+ /** Link columns are computed on the client. Server requests carry only the
1555
+ * keys and summaries they read. */
1556
+ declare function withoutLinkSummaries(summaries: readonly SummaryColumn[]): SummaryColumn[];
1557
+ /** The query a query-kind link opens, or null for template links, invalid
1558
+ * links and ungrouped queries.
1559
+ *
1560
+ * Starts from `grouping.source` (or `EMPTY_QUERY` for `base: "empty"`), adds
1561
+ * the group's key predicates unless `keyFilters` is false, resets the offset
1562
+ * and finally applies the link's patch. With the defaults this is
1563
+ * `groupSourceQuery` followed by the patch. */
1564
+ declare function groupLinkQuery(query: QueryState, value: GroupLinkValue): QueryState | null;
1565
+ /** Resolve a link cell to its label and href. Unregistered targets, failing
1566
+ * routes and unresolvable values return `href: null` with a `problem`. */
1567
+ declare function resolveGroupLink(query: QueryState, value: GroupLinkValue, targets?: LinkTargets): ResolvedGroupLink;
1568
+
1569
+ export { AGG_OPS_BY_TYPE, AGG_OPS_NEEDING_FIELD, type AggOp, type AggregateConfig, type AggregationBucket, type AggregationClause, type AggregationRequest, type AggregationResult, type AggregationResultEntry, type Align, type ApplyPatchOptions, type ApplyResult, type BackendField, COMPUTED_PREFIX, type CellDisplay, type CellRenderer, type ColumnPreview, type ComputedCellError, type ComputedColumn, type ComputedColumnDraft, type ComputedColumnStore, type ComputedExecution, type ComputedFieldCapabilities, type DerivedField, type DistinctValuesQuery, type DistinctValuesResult, EMPTY_QUERY, FORMULA_FUNCTIONS, type FetchRowsResult, type FetchRowsResultV2, type FieldDef, type FieldOrigin, type FieldRelationship, type FieldSchema, type FieldSource, type FieldStats, type FieldType, type FilterConfig, type FilterOp, type FilterValues, type ForeignKey, type FormulaDiagnostic, FormulaError, type FormulaFunction, type FormulaNode, type FormulaPlan, type FormulaResult, type FormulaType, type FormulaValue, GROUP_ID_FIELD, GROUP_LINK_RENDER, type GroupLinkValue, type GroupedRow, type GroupingDefinition, type GroupingModel, type GroupingState, type GroupingView, ITEM_DETAILS_COLUMN, type ItemDetailMode, type ItemDetailsState, type ItemPageOptions, type ItemPropertyMode, type JsonCellDisplay, type LinkDestination, type LinkSpec, type LinkTargets, MAX_AGGREGATIONS, MAX_GROUP_BY_FIELDS, MAX_ORDER_BY_TERMS, MAX_PROPERTIES, MAX_QUERY_LIMIT, MAX_QUERY_OFFSET, MAX_QUERY_STATE_BYTES, MAX_QUERY_TOKEN_LENGTH, MAX_RELATIVE_TIME_MS, MAX_REPRESENTATIVE_SORTS, MAX_RESULT_GROUPS, MAX_SELECT_COLUMNS, MAX_SUMMARY_COLUMNS, MAX_WHERE_CLAUSES, METRIC_DATE_INTERVALS, METRIC_FUNCTIONS, type MetricAxisScale, type MetricBoxSummary, type MetricCapabilities, type MetricDateGrouping, type MetricDiagnostic, type MetricDisplay, type MetricDistribution, type MetricDistributionResult, type MetricEvaluationOptions, type MetricHistogramBin, type MetricKey, type MetricLayout, type MetricPlan, type MetricPopulationSupport, type MetricQuery, type MetricReductionOptions, type MetricScope, type MetricSort, type MetricValue, type MetricValueFormat, NULLARY_OPS, OPS_BY_TYPE, OP_LABEL, type ObjectReference, type ObjectTypeDefinition, type OpChoice, type OpPair, type OrGroup, type OrderByClause, type PreviewGroup, type PropertyFieldConfig, type PropertyFormat, type PropertySelection, type PropertyViewState, type PropertyViewStorage, type QueryCapabilitiesV3, QueryDecodeError, type QueryEvaluationOptions, type QueryFacet, type QueryLink, type QueryLinkOptions, type QueryLinkService, type QueryPatch, type QueryPatchMatch, type QueryRequestV3, type QueryResultV3, type QuerySnapshot, type QuerySnapshotCache, QuerySnapshotHttpError, type QuerySnapshotHttpErrorCode, type QuerySnapshotStore, type QueryState, type RegexInspection, type RelationshipAdapter, type RepresentativeOrder, type RepresentativeRow, type ResolvedGroupLink, type ResolvedObjectReference, type RowComputedValues, type RowId, type SavedPropertyView, type SavedQuery, type SelectColumn, type SelectConfig, type ServerQuery, type ServerQueryV2, type SetFilterMetadata, type SetFilterMode, type SetFilterTarget, type SortConfig, type SourceDependencies, type StorageAdapter, type SummaryColumn, type SummaryOp, type Transport, type WhereClause, type WhereTerm, aggOpAllowedForType, aggOpNeedsField, aggOpsForField, applyAggregations, applyPatch, applyQuery, boxSummary, coerceValue, compareMetricValues, compileFormula, compileMetric, computedFieldName, createGroupingModel, createPropertyView, createQueryLinkService, createSetFilter, decodeQuery, decodeQueryStrict, discoverFieldRelationships, encodeQuery, evaluateMetricReductions, evaluateMetrics, exitGrouping, filterValues, formulaRuntime, groupLinkQuery, groupPreview, groupSourceQuery, hasRegex, histogramCounts, histogramEdges, httpComputedColumnStore, httpQuerySnapshotStore, indexFields, inspectBucketQuery, isComputedCellError, isComputedField, isFilterable, isGroupLinkField, isGroupLinkValue, isGroupable, isMeasurable, isNegativePredicate, isOrGroup, isPushdownFilter, isSelectable, isSortable, itemPageFields, jsonPropertyViewStorage, loadSchema, localPropertyViewStorage, localQuerySnapshotCache, localStorageAdapter, mapSetFilterValues, matchPatch, matchesClause, memoryComputedColumnStore, memoryPropertyViewStorage, memoryQuerySnapshotCache, memoryStorageAdapter, metricAggregatePlans, metricComputationKey, metricDateFloor, metricDateNext, metricDateRange, metricDateTime, metricDependencies, metricExpression, metricPlans, metricPopulationError, negateClause, normalizePropertyFormat, normalizePropertyView, normalizeQueryState, objectReferenceKey, opAllowedForType, opPairsForField, opsForField, parseRelativeDuration, percentile, predicatesOf, prepareGrouping, queriesEqual, readFieldValue, readObjectReference, readSetFilter, reduceMetricValues, removePatch, renderItemPageTemplate, resolveFieldName, resolveGroupLink, selectMetricShownRows, selectedFields, setFilterModes, setFilterTarget, sourceDependencies, sourceExecutionSchema, stripSetFilter, toAggregationQuery, toMetricQuery, toQueryRequestV3, toServerQuery, toServerQueryV2, validateComputedColumn, validateDateGrouping, validateItemPageTemplate, validateMetric, validateQueryResultV3, validateQuerySnapshot, withGroupingKeys, withoutGrouping, withoutLinkSummaries };