@toclocoinc/lattice-grid 1.26.0 → 1.27.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/lattice-grid.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.26.0, type declarations
2
+ * Lattice Grid 1.27.0, type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -642,6 +642,12 @@ export interface Column {
642
642
  * `'filtered'` ranks within what the filters left.
643
643
  */
644
644
  scope?: 'all' | 'filtered';
645
+ /**
646
+ * For `kind: 'anomalyFlag'`, the modified-z score a row must clear to be
647
+ * flagged an anomaly. Default 3.5 (Iglewicz & Hoaglin). Ignored by
648
+ * `anomalyScore`, which reports the raw score, and by the other kinds.
649
+ */
650
+ threshold?: number;
645
651
  /**
646
652
  * For `kind: 'specStatus'`, the hard specification the row is judged
647
653
  * against. `lower`/`upper` are the pass limits (a value beyond either
@@ -1328,6 +1334,19 @@ export interface GridConfig {
1328
1334
  */
1329
1335
  columnTagFilter?: boolean | { multiple?: boolean; label?: string };
1330
1336
 
1337
+ /**
1338
+ * Show a small chip in the grid chrome that reads how many rows an anomaly
1339
+ * shadow column has flagged, and filters the grid to exactly those when it is
1340
+ * clicked (BACKLOG-0000799).
1341
+ *
1342
+ * Off by default, and it draws nothing unless a column declares a
1343
+ * `shadow: { kind: 'anomalyFlag' }`. The count and the filter both read that
1344
+ * one shadow column, so the number on the chip is the number of rows the
1345
+ * click reveals. `column` names the base column to summarise when more than
1346
+ * one anomaly-flag shadow is present; `label` overrides the chip's wording.
1347
+ */
1348
+ anomalySummary?: boolean | { column?: string; label?: string };
1349
+
1331
1350
  /**
1332
1351
  * Open a row on a form when it is double-clicked.
1333
1352
  *
@@ -1926,6 +1945,18 @@ export interface GridConfig {
1926
1945
  /** Placeholder shown while nothing is grouped. */
1927
1946
  hint?: string;
1928
1947
  };
1948
+ /**
1949
+ * A built-in KPI/stat strip: a labelled band of {@link createStat} tiles the
1950
+ * grid places for you, above the column header. Each entry is a stat spec —
1951
+ * the same fields {@link StatConfig} takes, minus `grid` and `container`,
1952
+ * which the grid supplies — so a strip tile and a hand-placed one are the same
1953
+ * object. The tiles follow the grid's filters, recomputing on every change
1954
+ * exactly as a stand-alone stat does.
1955
+ *
1956
+ * Off by default and non-breaking, matching `groupPanel`: no `kpis` means no
1957
+ * band and no cost. It reuses `createStat` and reimplements no compute.
1958
+ */
1959
+ kpis?: Array<Omit<StatConfig, 'grid' | 'container'>>;
1929
1960
  /** The quick filter's initial text. */
1930
1961
  quickFilterText?: string;
1931
1962
  /**
@@ -2371,6 +2402,17 @@ export interface StatisticsApi {
2371
2402
  reduce(colId: string, fn: string): unknown;
2372
2403
  /** Everything worth knowing about one column, in one pass each. */
2373
2404
  profile(colId: string): ColumnProfile | null;
2405
+ /**
2406
+ * The rows that do not belong (BACKLOG-0000749): anomaly detection over the
2407
+ * filtered rows by the robust modified z-score (`modifiedZScore`, the
2408
+ * default), Tukey's IQR fences (`iqr`), or multivariate Mahalanobis distance
2409
+ * over the chosen columns (`mahalanobis`). Every flagged row carries the score
2410
+ * behind it and the reason for it, so a flag is explainable rather than a
2411
+ * verdict from nowhere. Non-numeric columns are returned under `skipped`.
2412
+ */
2413
+ anomalies(opts?: { columns?: string[];
2414
+ method?: 'modifiedZScore' | 'iqr' | 'mahalanobis';
2415
+ threshold?: number; k?: number; p?: number }): AnomalyReport;
2374
2416
  /**
2375
2417
  * Which columns differ most between the filtered subset and the whole
2376
2418
  * population it was drawn from, ranked by effect size — never by a p-value.
@@ -2390,6 +2432,20 @@ export interface StatisticsApi {
2390
2432
  * on one side alone is returned under `unmatched`.
2391
2433
  */
2392
2434
  datasetVsDataset(other: Grid, opts?: { columns?: string[] }): DatasetComparison;
2435
+ /**
2436
+ * Is the difference between two groups real? A two-sample test returned as
2437
+ * data to interpret — never a verdict (BACKLOG-0000750). The significance
2438
+ * boundary the comparison story (653, 735) stopped short of: those rank by how
2439
+ * *much* columns differ and return no p-value; this answers *how sure* for one
2440
+ * chosen pair of groups and hands the p-value back as data. There is no
2441
+ * `significant` flag, no badge, and no multiple-comparison correction. The
2442
+ * rows are split by `opts.by`, the test is chosen by the column's family and
2443
+ * named in the result (overridable with `opts.test`): Welch's t or
2444
+ * Mann-Whitney U for a numeric column, chi-square for a categorical one. Every
2445
+ * result pairs a confidence interval on the difference with the effect size,
2446
+ * so it is always "how big and how sure".
2447
+ */
2448
+ compareGroups(colId: string, opts: TwoSampleSpec): GroupComparison | null;
2393
2449
  /** Pearson's correlation between two columns. */
2394
2450
  correlation(a: string, b: string): number | null;
2395
2451
  /** Covariance, a correlation before the scales are divided out. */
@@ -2558,12 +2614,64 @@ export function openWindow(
2558
2614
  now?: () => number,
2559
2615
  ): Window;
2560
2616
 
2617
+ /**
2618
+ * The anomaly-detection methods (BACKLOG-0000749): the robust univariate
2619
+ * modified z-score, Tukey's IQR fences, and multivariate Mahalanobis distance.
2620
+ * Interpretable statistics with written-down cuts, never a black box.
2621
+ */
2622
+ export const ANOMALY_METHODS: readonly ('modifiedZScore' | 'iqr' | 'mahalanobis')[];
2623
+
2624
+ /**
2625
+ * Per-row modified z-scores and flags for one column of readings — the robust
2626
+ * outlier score on the median and MAD (`0.6745·(x − median)/MAD`), flagged past
2627
+ * `threshold` (default 3.5). Robust to the outliers themselves: one wild reading
2628
+ * cannot inflate the spread and hide. A non-finite reading and a zero-MAD column
2629
+ * yield a null score and no flag rather than an invented one.
2630
+ */
2631
+ export function modifiedZScores(
2632
+ values: ArrayLike<number>,
2633
+ opts?: { threshold?: number },
2634
+ ): { median: number | null; mad: number | null; threshold: number;
2635
+ scores: (number | null)[]; flags: boolean[]; flagged: number };
2636
+
2637
+ /**
2638
+ * Tukey's fences for one column: `[Q1 − k·IQR, Q3 + k·IQR]` (default `k = 1.5`),
2639
+ * the same fence the box plot draws, with R type 7 quartiles. Null when there
2640
+ * are no readings.
2641
+ */
2642
+ export function iqrFences(
2643
+ values: ArrayLike<number>,
2644
+ opts?: { k?: number },
2645
+ ): { q1: number; q3: number; iqr: number; lower: number; upper: number; k: number } | null;
2646
+
2647
+ /**
2648
+ * Mahalanobis distance of every row from the joint centre, in the metric of the
2649
+ * data's own sample covariance, cut at a χ² quantile (default the 0.975 point).
2650
+ * Catches a row impossible only in combination, which a per-column scan misses.
2651
+ * A row with any missing coordinate gets a null distance; a singular covariance
2652
+ * is ridge-regularised and reported as `singular` rather than throwing.
2653
+ */
2654
+ export function mahalanobis(
2655
+ matrix: number[][],
2656
+ opts?: { p?: number; ridge?: number },
2657
+ ): { center: number[]; df: number; cutoff: number; singular: boolean; used: number;
2658
+ distances: (number | null)[]; squared: (number | null)[]; flags: boolean[];
2659
+ flagged: number } | null;
2660
+
2561
2661
  export type ShadowKind =
2562
2662
  | 'updates' | 'updatedAt' | 'sinceUpdate' | 'delta' | 'deltaPercent'
2563
2663
  | 'rate' | 'history' | 'firstValue' | 'streak'
2564
2664
  /** Where the row sits among the others, over every tracked row. */
2565
2665
  | 'rank' | 'rankAsc' | 'rankChange' | 'percentile' | 'quartile'
2566
2666
  | 'zScore' | 'shareOfTotal'
2667
+ /**
2668
+ * A robust outlier score and flag per row (BACKLOG-0000749): the modified
2669
+ * z-score on the median and MAD, and the boolean of whether it clears
2670
+ * `threshold` (default 3.5, read off the shadow declaration). Sortable,
2671
+ * filterable, groupable and exportable like any cell. Null where there is no
2672
+ * robust spread to score against.
2673
+ */
2674
+ | 'anomalyScore' | 'anomalyFlag'
2567
2675
  /**
2568
2676
  * The row's pass/fail verdict against a hard-limit spec, as a value:
2569
2677
  * `'PASS'`, `'WARN'` or `'FAIL'`. Sortable, filterable, groupable and
@@ -2712,6 +2820,69 @@ export interface SubsetComparison {
2712
2820
  measures: { numeric: string; categorical: string; common: string };
2713
2821
  }
2714
2822
 
2823
+ export interface AnomalyReason {
2824
+ /** The column that put this row over the line. */
2825
+ column: string;
2826
+ /** The column's display name, or its id. */
2827
+ name: string;
2828
+ /** The row's value in that column. */
2829
+ value: number;
2830
+ /** The modified z-score, for the `modifiedZScore` method. */
2831
+ score?: number;
2832
+ /** The lower fence, for the `iqr` method. */
2833
+ lower?: number;
2834
+ /** The upper fence, for the `iqr` method. */
2835
+ upper?: number;
2836
+ /** Which rule flagged it. */
2837
+ method?: 'modifiedZScore' | 'iqr';
2838
+ }
2839
+
2840
+ export interface AnomalyRow {
2841
+ /** The row key — stable across a sort or a feed, where the index is not. */
2842
+ rowKey: string | null;
2843
+ /** The physical row index at the time of the call. */
2844
+ index: number;
2845
+ /**
2846
+ * The row's headline score: its most extreme modified z-score across the
2847
+ * flagging columns (univariate), the Mahalanobis distance (multivariate), or
2848
+ * null for the IQR method, which has no single score.
2849
+ */
2850
+ score: number | null;
2851
+ /** The squared Mahalanobis distance, for the `mahalanobis` method. */
2852
+ squared?: number | null;
2853
+ /** Why this row was flagged: the columns and how far, so it is explainable. */
2854
+ why: AnomalyReason[];
2855
+ }
2856
+
2857
+ export interface AnomalyReport {
2858
+ /** Which rule produced the report. */
2859
+ method: 'modifiedZScore' | 'iqr' | 'mahalanobis';
2860
+ /** The IQR fence multiplier, for the `iqr` method. */
2861
+ k?: number;
2862
+ /** How many rows the scan ran over. */
2863
+ n: number;
2864
+ /** The flagged rows, worst first. */
2865
+ rows: AnomalyRow[];
2866
+ /** How many rows were flagged. */
2867
+ flagged: number;
2868
+ /** The column ids that were not numeric and so could not be scored. */
2869
+ skipped: string[];
2870
+ /** How many numeric columns were scored (univariate). */
2871
+ scored?: number;
2872
+ /** Per-column summaries (univariate): the centre, spread and fence per column. */
2873
+ columns?: unknown;
2874
+ /** The degrees of freedom of the χ² cut (multivariate). */
2875
+ df?: number;
2876
+ /** The χ² cut the squared distance is compared against (multivariate). */
2877
+ cutoff?: number | null;
2878
+ /** The joint centre the distances are measured from (multivariate). */
2879
+ center?: number[];
2880
+ /** How many complete rows defined the metric (multivariate). */
2881
+ used?: number;
2882
+ /** Whether the covariance was singular and had to be regularised (multivariate). */
2883
+ singular?: boolean;
2884
+ }
2885
+
2715
2886
  export interface DatasetColumnDifference {
2716
2887
  /** The column id, present on both grids. */
2717
2888
  column: string;
@@ -2753,6 +2924,92 @@ export interface DatasetComparison {
2753
2924
  measures: { numeric: string; categorical: string; common: string };
2754
2925
  }
2755
2926
 
2927
+ /** How {@link StatisticsApi.compareGroups} splits the rows and picks a test. */
2928
+ export interface TwoSampleSpec {
2929
+ /** The column whose values split the rows into groups. Required. */
2930
+ by: string;
2931
+ /** The two group values to compare. The two most frequent when omitted. */
2932
+ groups?: [unknown, unknown];
2933
+ /**
2934
+ * Force a test rather than choosing by column family. `auto` (the default)
2935
+ * picks Welch or Mann-Whitney for a numeric column and chi-square for a
2936
+ * categorical one; the choice is always named in the result.
2937
+ */
2938
+ test?: 'auto' | 'welch' | 'mannWhitney' | 'chiSquare';
2939
+ /** The confidence level for the interval, 0 to 1. 0.95 by default. */
2940
+ confidence?: number;
2941
+ /**
2942
+ * The focal category for a chi-square difference interval, when the column has
2943
+ * more than two categories. Without it, a multi-category comparison reports no
2944
+ * scalar interval, only the effect size.
2945
+ */
2946
+ category?: unknown;
2947
+ }
2948
+
2949
+ /** The effect size paired with a two-sample test — the "how big" half. */
2950
+ export interface GroupEffectSize {
2951
+ /**
2952
+ * The named measure: `pooledStandardMeanDifference` (Cohen's d) for the
2953
+ * numeric tests, `categoricalTotalVariation` for chi-square.
2954
+ */
2955
+ name: string;
2956
+ /** The effect size in its own terms, or null when it has no scale here. */
2957
+ value: number | null;
2958
+ }
2959
+
2960
+ /** A confidence interval on the difference a two-sample test measured. */
2961
+ export interface GroupDifferenceInterval {
2962
+ /** The point estimate of the difference the interval is around. */
2963
+ estimate: number;
2964
+ lower: number;
2965
+ upper: number;
2966
+ /** The level the bounds were computed at, 0 to 1. */
2967
+ confidence: number;
2968
+ /** The method, named for honesty: `welch-t`, `hodges-lehmann`, `newcombe`. */
2969
+ method: string;
2970
+ /** For a chi-square interval, which category's share the difference is of. */
2971
+ category?: unknown;
2972
+ }
2973
+
2974
+ /**
2975
+ * The result of {@link StatisticsApi.compareGroups}: how big *and* how sure, as
2976
+ * data to interpret. Carries no significance verdict — the p-value is a number,
2977
+ * never a flag or a badge.
2978
+ */
2979
+ export interface GroupComparison {
2980
+ /** The test used, named so it is never hidden. */
2981
+ test: 'welch' | 'mannWhitney' | 'chiSquare';
2982
+ /** Whether the test was chosen automatically or forced by the caller. */
2983
+ chosenBy: 'auto' | 'override';
2984
+ /** Why this test — the column family, a normality screen, or the override. */
2985
+ reason: string;
2986
+ /** The test statistic. */
2987
+ statistic: number;
2988
+ /** What the statistic is: `t`, `U`, or `chiSquare`. */
2989
+ statisticName: string;
2990
+ /** The degrees of freedom, where the test has them; null for Mann-Whitney. */
2991
+ df: number | null;
2992
+ /**
2993
+ * The two-sided p-value, returned as data for the caller to interpret. Never
2994
+ * thresholded into a verdict here.
2995
+ */
2996
+ pValue: number;
2997
+ /** The confidence interval on the difference, or null when there is none. */
2998
+ interval: GroupDifferenceInterval | null;
2999
+ /** The paired effect size, so the p-value is never read on its own. */
3000
+ effectSize: GroupEffectSize;
3001
+ /** How many rows the first group stood on. */
3002
+ nA: number;
3003
+ /** How many rows the second group stood on. */
3004
+ nB: number;
3005
+ /** The two group values compared, as keys. */
3006
+ groups: [unknown, unknown];
3007
+ /** False when either group is under the reliability floor. */
3008
+ reliable: boolean;
3009
+ /** The test's method, named per the reference-suite honesty rule. */
3010
+ method: string;
3011
+ }
3012
+
2756
3013
  export interface FormattingApi {
2757
3014
  list(scope?: FormattingScope): FormattingRule[];
2758
3015
  all(): Record<FormattingScope, FormattingRule[]>;
@@ -3148,6 +3405,20 @@ export interface EditApi {
3148
3405
  undo(): void;
3149
3406
  redo(): void;
3150
3407
  setCells(writes: { key: string; colId: string; value: unknown }[], type?: 'cell' | 'fill' | 'paste'): number;
3408
+ /**
3409
+ * Set one value across a block of cells as a single undoable step (§12, card
3410
+ * 740). Defaults to the selected range; read-only and non-editable cells are
3411
+ * skipped and every write runs the normal parse/validate path.
3412
+ */
3413
+ bulkSet(value: unknown, opts?: { cells?: { key: string; colId: string }[] }): number;
3414
+ /**
3415
+ * Fill a selected range from its leading edge as one undoable step (§12, card
3416
+ * 740). The default copies the anchor across the range (Excel's Ctrl+D and its
3417
+ * natural siblings); `series: true` extrapolates a numeric or date series from
3418
+ * the first one or two cells of each line, falling back to a copy for types
3419
+ * with no series. `direction` defaults to `'down'`.
3420
+ */
3421
+ fill(opts?: { direction?: 'down' | 'up' | 'left' | 'right'; series?: boolean; range?: CellRange }): number;
3151
3422
  pasteInto(anchor: { key: string; colId: string }, text: string, extent?: { rows?: number; columns?: number }): number;
3152
3423
  /** Whether a bulk paste is previewed before it commits (`edit.pastePreview`, §12). */
3153
3424
  readonly pastePreview: boolean;
@@ -4423,15 +4694,18 @@ export function odataAdapter(options: {
4423
4694
  url: string; fetch?: typeof fetch; headers?: Record<string, string>;
4424
4695
  count?: boolean; search?: boolean;
4425
4696
  /**
4426
- * The key property a cell update targets in its entity-key URL segment
4427
- * (`/Orders(<key>)`). Write-back only (§7 OData, wave 1).
4697
+ * The key property every write addresses a row by in its entity-key URL
4698
+ * segment (`/Orders(<key>)`), and that an add-row is rekeyed to from the
4699
+ * created entity. Write-back only (§7 OData).
4428
4700
  */
4429
4701
  key?: string;
4430
4702
  /**
4431
- * Opt the adapter into cell write-back. `false` (the default) declares the
4432
- * source read-only; `true` advertises `mutate: { update: true, returning: 'row' }`
4433
- * so a committed cell edit is persisted with `PATCH`. Wave 1 wires `update`
4434
- * only; append and delete are deferred.
4703
+ * Opt the adapter into write-back. `false` (the default) declares the source
4704
+ * read-only; `true` advertises `mutate: { update: true, delete: true, append:
4705
+ * true, returning: 'row' }` so a committed cell edit is persisted with
4706
+ * `PATCH`, a row delete with `DELETE /EntitySet(key)`, and an add-row with
4707
+ * `POST /EntitySet` reading the created entity back (§7 OData,
4708
+ * BACKLOG-0000766, BACKLOG-0000795).
4435
4709
  */
4436
4710
  edit?: boolean;
4437
4711
  }): PushdownAdapter & { urlFor(query: RemoteRequest): string };
@@ -4447,18 +4721,27 @@ export function restAdapter(options: {
4447
4721
  encodeFilter?: (filters: object) => string;
4448
4722
  rows?: (body: unknown) => unknown[]; total?: (body: unknown, rows: unknown[]) => number;
4449
4723
  /**
4450
- * Opt the adapter into cell write-back. `false` (the default) declares the
4451
- * source read-only; `true` advertises `mutate: { update: true, delete: true, returning }`
4452
- * so a committed cell edit is persisted with `PATCH` and a row delete with
4453
- * `DELETE`. Append needs the row-keyed pending engine and is refused loudly.
4724
+ * Opt the adapter into write-back. `false` (the default) declares the source
4725
+ * read-only; `true` advertises `mutate: { update: true, delete: true, append:
4726
+ * true, returning }` so a committed cell edit is persisted with `PATCH`, a row
4727
+ * delete with `DELETE`, and an add-row with `POST` to the collection URL
4728
+ * (§7 REST, BACKLOG-0000769, BACKLOG-0000795).
4454
4729
  */
4455
4730
  edit?: boolean;
4456
4731
  /**
4457
4732
  * The reconcile contract for a successful write (§5.1). `'none'` (the default)
4458
4733
  * is last-write-wins — the optimistic value stands; `'row'` reads the server's
4459
- * authoritative row (via {@link writeRow}) back before confirm.
4734
+ * authoritative row (via {@link writeRow}) back before confirm; `'key'` reads
4735
+ * only the server-assigned key. An add-row needs `'row'` or `'key'` so the
4736
+ * temp row can be rekeyed to its server key.
4460
4737
  */
4461
- returning?: 'row' | 'none';
4738
+ returning?: 'row' | 'key' | 'none';
4739
+ /**
4740
+ * The property an add-row response carries the server-assigned key in, read
4741
+ * back (through {@link writeRow}) to rekey the optimistic row. Defaults to
4742
+ * `id`. Write-back only.
4743
+ */
4744
+ keyField?: string;
4462
4745
  /**
4463
4746
  * Full control of a mutation's HTTP shape, overriding the default verb map and
4464
4747
  * URL. Given the {@link MutationOp}, return the method, url and optional
@@ -4468,11 +4751,13 @@ export function restAdapter(options: {
4468
4751
  /**
4469
4752
  * The endpoint a single mutation targets, when the default `${url}/${key}` is
4470
4753
  * not what the service uses. Ignored when {@link encodeMutation} is supplied.
4754
+ * Addresses an existing row; an add-row POSTs to the collection `url` instead.
4471
4755
  */
4472
4756
  writeUrlFor?: (op: MutationOp) => string;
4473
4757
  /**
4474
- * Pull the authoritative row out of a write response when `returning: 'row'`.
4475
- * Tolerates the plain entity, a `{ row }` or a `{ data }` envelope by default.
4758
+ * Pull the authoritative row out of a write response when `returning: 'row'`,
4759
+ * and the created row an add-row reads its key from. Tolerates the plain
4760
+ * entity, a `{ row }` or a `{ data }` envelope by default.
4476
4761
  */
4477
4762
  writeRow?: (body: unknown) => unknown;
4478
4763
  }): PushdownAdapter & { urlFor(query: RemoteRequest): string };
@@ -4498,21 +4783,25 @@ export function duckdbAdapter(options: {
4498
4783
  /** Columns to select. Everything by default. */
4499
4784
  fields?: string[];
4500
4785
  /**
4501
- * The key column a cell update targets in its `WHERE`. Write-back is refused
4502
- * unless this names a real column, because an `UPDATE` without a unique key
4503
- * could touch more than one row (§7 DuckDB, wave 1).
4786
+ * The key column an update and a delete target in their `WHERE`, and that an
4787
+ * add-row is rekeyed by. Write-back is refused unless this names a real column,
4788
+ * because an `UPDATE`/`DELETE` without a unique key could touch more than one
4789
+ * row (§7 DuckDB). Defaults to `id`.
4504
4790
  */
4505
4791
  keyField?: string;
4506
4792
  /**
4507
- * Allow cell updates against a plain writable table. `false` (the default)
4508
- * keeps the source read-only, so a `from` that is a view or an expression can
4509
- * never be mutated by accident. Wave 1 wires `update` only.
4793
+ * Allow write-back against a plain writable table. `false` (the default) keeps
4794
+ * the source read-only, so a `from` that is a view or an expression can never
4795
+ * be mutated by accident. Enables `update`, `delete` and `append`
4796
+ * (BACKLOG-0000765, BACKLOG-0000795).
4510
4797
  */
4511
4798
  writable?: boolean;
4512
4799
  /**
4513
- * The reconcile contract for a successful update (§5.1). `'row'` (the default)
4800
+ * The reconcile contract for a successful write (§5.1). `'row'` (the default)
4514
4801
  * appends `RETURNING *` and reconciles server truth (computed columns,
4515
- * triggers); `'none'` keeps the optimistic value (last-write-wins).
4802
+ * triggers); `'none'` keeps the optimistic value (last-write-wins). An add-row
4803
+ * always `RETURNING`s at least the key column regardless, since it needs that
4804
+ * key to rekey the temp row.
4516
4805
  */
4517
4806
  returning?: 'row' | 'none';
4518
4807
  }): PushdownAdapter & { sqlFor(query: RemoteRequest): { sql: string; params: unknown[] } };
@@ -4557,6 +4846,58 @@ export function dfqlAdapter(options: {
4557
4846
  encodeCreate?: (row: unknown) => Record<string, unknown>;
4558
4847
  }): PushdownAdapter & { linesFor(query: RemoteRequest): object[] };
4559
4848
 
4849
+ /**
4850
+ * An adapter for a GraphQL endpoint (BACKLOG-0000741).
4851
+ *
4852
+ * GraphQL has no fixed query semantics — a filter, a sort and pagination are
4853
+ * whatever the schema defines — so this adapter is configured, not zero-config.
4854
+ * The caller supplies `buildQuery`, which turns the pushed plan into the
4855
+ * `{ query, variables }` body a GraphQL endpoint is POSTed, and `parseResponse`,
4856
+ * which reads the operation's `data` back into `{ rows, total }`. Sensible
4857
+ * defaults cover an offset/limit list with a `totalCount` and a Relay cursor
4858
+ * connection (`first`/`after` with `pageInfo`); either is replaced by passing
4859
+ * the hook.
4860
+ *
4861
+ * The default `buildQuery` pushes only the window and asks for the total, so the
4862
+ * default capabilities are `range` and `total` and nothing else: filter, sort
4863
+ * and quick are left absent and the grid finishes them over the window. Declare
4864
+ * `operators`/`capabilities` only alongside a `buildQuery` that genuinely emits
4865
+ * them, or the grid returns the wrong rows silently.
4866
+ *
4867
+ * A Relay cursor connection is forward-only: a deep window is reached by paging
4868
+ * forward to it, which costs round trips proportional to its offset. Offset
4869
+ * pagination jumps straight to the window. `buildMutation` opts the write path
4870
+ * in and is a declared follow-up (the write-back wave); `capabilities.mutate` is
4871
+ * `false` by declaration until it is wired.
4872
+ */
4873
+ export function graphqlAdapter(options: {
4874
+ /** The GraphQL endpoint, POSTed a `{ query, variables }` body. Required. */
4875
+ url: string;
4876
+ fetch?: typeof fetch; headers?: Record<string, string>;
4877
+ /** The root query field the default query selects from. `items` by default. */
4878
+ field?: string;
4879
+ /** Field names for the default query's selection set. */
4880
+ fields?: string[];
4881
+ /** A raw selection set (for nested fields), overriding `fields`. */
4882
+ selection?: string;
4883
+ /** `offset` (offset/limit list) or `cursor` (Relay connection). `offset` by default. */
4884
+ pagination?: 'offset' | 'cursor';
4885
+ /** The page size for the whole-result and forward-cursor walks. */
4886
+ pageSize?: number;
4887
+ /** Rename the pagination variables the adapter drives per page. */
4888
+ vars?: Partial<Record<'offset' | 'limit' | 'first' | 'after', string>>;
4889
+ capabilities?: PushdownCapabilities; operators?: string[];
4890
+ /** Turn the pushed plan into a GraphQL operation `{ query, variables }`, replacing the default. */
4891
+ buildQuery?: (request: RemoteRequest) => object;
4892
+ /** Read the operation's `data` into `{ rows, total, pageInfo? }`, replacing the default. */
4893
+ parseResponse?: (data: object) => object;
4894
+ /** Turn a mutation into a GraphQL operation (write-back follow-up). */
4895
+ buildMutation?: (op: object) => object;
4896
+ }): PushdownAdapter & {
4897
+ buildQuery(query: RemoteRequest): { query: string; variables: object };
4898
+ parseResponse(data: object): { rows: unknown[]; total: number };
4899
+ };
4900
+
4560
4901
  export function createGrid(element: HTMLElement, config?: GridConfig): Grid;
4561
4902
  export function createHeadlessGrid(config?: GridConfig): Grid;
4562
4903
 
@@ -5063,6 +5404,9 @@ declare module 'lattice-grid/modules/react' {
5063
5404
  * React nor the grid: you pass both in. That is what keeps the package's
5064
5405
  * promise of no runtime dependencies, and what stops an adapter disagreeing
5065
5406
  * with the grid version already loaded.
5407
+ *
5408
+ * The live grid is reached through a forwarded ref: `ref.current.grid` is the
5409
+ * same `Grid` the vanilla `createGrid` returns, or null before mount.
5066
5410
  */
5067
5411
  export function createLatticeGrid(deps: { React: unknown; createGrid: unknown }): unknown;
5068
5412
  /** Every grid event, as the prop name a React caller writes. */
@@ -5072,14 +5416,37 @@ declare module 'lattice-grid/modules/react' {
5072
5416
  }
5073
5417
 
5074
5418
  declare module 'lattice-grid/modules/vue' {
5075
- export function createLatticeGrid(deps: { Vue?: unknown; createGrid: unknown }): unknown;
5419
+ /**
5420
+ * Build the Vue 3 component.
5421
+ *
5422
+ * The Vue runtime and `createGrid` are passed in, for the same reason as the
5423
+ * React adapter: the package ships no dependencies and cannot import either.
5424
+ * The dependency key is lowercase `vue` — `createLatticeGrid({ vue, createGrid })`.
5425
+ *
5426
+ * The live grid is reached through the component's exposed `grid()` method:
5427
+ * with `ref="grid"` on the element, `this.$refs.grid.grid()` returns the same
5428
+ * `Grid` the vanilla `createGrid` returns, or null before mount.
5429
+ */
5430
+ export function createLatticeGrid(deps: { vue: unknown; createGrid: unknown }): unknown;
5076
5431
  export const EVENT_NAMES: readonly string[];
5077
5432
  export function dashedName(event: string): string;
5078
5433
  export default createLatticeGrid;
5079
5434
  }
5080
5435
 
5081
5436
  declare module 'lattice-grid/modules/svelte' {
5082
- /** A Svelte action: `use:lattice={config}`. */
5437
+ /**
5438
+ * A Svelte action: `use:lattice={config}`.
5439
+ *
5440
+ * The action owns nothing but the node the caller already has, so the grid is
5441
+ * reached one of two ways. Pass an `onGrid` callback in the action params
5442
+ * (BACKLOG-0000785): `use:lattice={{ ...config, onGrid: (g) => (grid = g) }}`
5443
+ * calls it once with the live `Grid` the moment it is built — synchronously,
5444
+ * before `ready` fires — and again if you hand the action a different
5445
+ * `onGrid`. Or read it off an event: every grid event carries the grid on its
5446
+ * `detail`, so `on:ready={(e) => e.detail.grid}` hands you the same `Grid` a
5447
+ * turn after construction. Use `onGrid` when you need the instance during the
5448
+ * first render.
5449
+ */
5083
5450
  export function createLatticeAction(deps: { createGrid: unknown }): unknown;
5084
5451
  export const EVENT_NAMES: readonly string[];
5085
5452
  export function dashedName(event: string): string;
@@ -5093,6 +5460,10 @@ declare module 'lattice-grid/modules/webcomponent' {
5093
5460
  * This module carries the grid inside it. Use it *or* `createGrid` in one
5094
5461
  * page, never both: two copies keep separate registries, and a renderer
5095
5462
  * registered through one will not appear in the other.
5463
+ *
5464
+ * The live grid is reached through the element's `grid` getter: `el.grid` is
5465
+ * the same `Grid` the vanilla `createGrid` returns, or null while the element
5466
+ * is disconnected.
5096
5467
  */
5097
5468
  export function defineLatticeGrid(tag?: string): void;
5098
5469
  export function createLatticeGridElement(deps?: object): unknown;
@@ -5102,6 +5473,11 @@ declare module 'lattice-grid/modules/webcomponent' {
5102
5473
  export function observedAttributeNames(): string[];
5103
5474
  export function domEventName(event: string): string;
5104
5475
  export class GridElementController {}
5476
+ // Core factories re-exported from this module so they bind to the one engine
5477
+ // the element already carries: a type built with these here shares the
5478
+ // element's registry rather than a second copy's (BACKLOG-0000787). Typed by
5479
+ // reference to the base package.
5480
+ export { createCurrencyType, createUnitType, registerUnitSystem, createStat } from 'lattice-grid';
5105
5481
  export default defineLatticeGrid;
5106
5482
  }
5107
5483
 
@@ -5133,6 +5509,27 @@ declare module 'lattice-grid/modules/htmx' {
5133
5509
  export const QUERY_CHANGED_EVENT: string;
5134
5510
  export const SCROLL_NEAR_END_EVENT: string;
5135
5511
  export const HTML_ROW_WARNING_THRESHOLD: number;
5512
+ // The core factory surface this module re-exports, so an htmx page builds its
5513
+ // configured columns (a currency type, a unit type, a stat) from the one
5514
+ // engine it already carries rather than a second copy (BACKLOG-0000786).
5515
+ // Typed by reference to the base package; names the base package leaves
5516
+ // untyped stay untyped here too.
5517
+ export {
5518
+ createHeadlessGrid, version, getVersion, Grid, Registry, registerModules,
5519
+ createRadixType, createUnitType, registerUnitSystem, defineUnit, UNIT_SYSTEMS, parseUnit, formatUnit,
5520
+ createCurrencyType, parseMoney, formatMoney, convertMoney, rateFunction, MISSING_RATE,
5521
+ Messages, createMessages, auditCatalogue,
5522
+ EN_GB, MESSAGE_KEYS, DEFAULT_LOCALE, formatList, resolveLocale, LOCALES, resolveCatalogue,
5523
+ EN_US, FR_FR, FR_CA, IT_IT, ES_ES, PT_BR, DE_DE, NL_NL, SV_SE, DA_DK, NB_NO, FI_FI,
5524
+ PL_PL, CS_CZ, HU_HU, RO_RO, UK_UA, EL_GR, JA_JP, AR, AR_SA,
5525
+ Window, openWindow, WINDOW_KINDS,
5526
+ evaluateFormula, referencesOf, looksLikeFormula, compileRules, ingest, ingestSync,
5527
+ createPushdownSource, planQuery, splitFilters, applyResidual, capabilitiesOf, resolveMutate, NO_CAPABILITIES,
5528
+ odataAdapter, restAdapter, dfqlAdapter, duckdbAdapter,
5529
+ createStat, deltaOf, toneOf,
5530
+ } from 'lattice-grid';
5531
+ // American licence aliases mirror the base package (dom/index.js).
5532
+ export { setLicence as setLicense, licenceInfo as licenseInfo, licenceState as licenseState } from 'lattice-grid';
5136
5533
  }
5137
5534
 
5138
5535
  declare module 'lattice-grid/modules/dhtmlx-compat' {