@1771technologies/lytenyte-pro 1.0.16 → 1.0.17-dev.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/+types.d.ts CHANGED
@@ -2177,9 +2177,54 @@ export interface RowDataSourceServer<T> {
2177
2177
  */
2178
2178
  readonly loadError: GridAtomReadonly<unknown>;
2179
2179
  /**
2180
- * Retries the failed data load requests.
2180
+ * A set that tracks which requests the server data source has already made. It prevents duplicate
2181
+ * requests to the server. This mutable set can be used to customize how the
2182
+ * grid tracks requests or to inform the data source about optimistically loaded requests.
2183
+ *
2184
+ * Modifying `seenRequests` is intended for advanced use cases. Ensure you fully understand how
2185
+ * data loading works in LyteNyte Grid's server data source before making
2186
+ * changes. If you're unsure, reach out to the LyteNyte Grid team on GitHub.
2187
+ */
2188
+ readonly seenRequests: Set<string>;
2189
+ /**
2190
+ * `retry` re-requests any failed data loads in the grid.
2191
+ * Calling `retry` clears the error state for all failed requests, and
2192
+ * the grid resends data requests for those currently in view. Failed
2193
+ * requests outside the view are not retried until they come back into view.
2181
2194
  */
2182
2195
  readonly retry: () => void;
2196
+ /**
2197
+ * A grid atom that returns the data requests that would be
2198
+ * sent to the server based on the current state of the view.
2199
+ *
2200
+ * This can be used to implement polling for cell updates, allowing the client
2201
+ * to periodically fetch new or changed data without reloading the entire view.
2202
+ *
2203
+ * To execute the generated requests, use the `pushRequests` method.
2204
+ */
2205
+ readonly requestsForView: GridAtomReadonly<DataRequest[]>;
2206
+ /**
2207
+ * Returns the data request that would be sent to the server to load the row group
2208
+ * of the given row. This may be used to get a request that can be used to optimistically
2209
+ * load the group.
2210
+ *
2211
+ * This method will return null if the group is invalid or if the row is not found.
2212
+ */
2213
+ readonly requestForGroup: (row: RowGroup | number) => DataRequest | null;
2214
+ /**
2215
+ * Returns the data request for the next slice of data based on the provided request.
2216
+ * This is useful for preloading the next view of data. Returns `null` if no
2217
+ * next slice exists or if the provided request is invalid for the current view configuration.
2218
+ */
2219
+ readonly requestForNextSlice: (currentRequest: DataRequest) => DataRequest | null;
2220
+ /**
2221
+ * Refreshes the current view by re-sending the data requests that make up the view to the server.
2222
+ * This ensures that any underlying data changes are reflected in the rendered view.
2223
+ *
2224
+ * This is a convenience method that combines the functionality of `requestsForView` and `pushRequests`,
2225
+ * allowing you to easily re-fetch and re-render data for the current view in a single call.
2226
+ */
2227
+ readonly refresh: (onSuccess?: () => void, onError?: (e: unknown) => void) => void;
2183
2228
  /**
2184
2229
  * Pushes data responses directly into the data source. Useful for
2185
2230
  * preloading, live updates, or streaming responses.
@@ -2452,6 +2497,16 @@ export interface RowGroup {
2452
2497
  * Depth level from the root; used to determine visual indenting and structure.
2453
2498
  */
2454
2499
  readonly depth: number;
2500
+ /**
2501
+ * An error that applies to the group row. This is usually set when the group fails to load
2502
+ * its children rows.
2503
+ */
2504
+ readonly errorGroup?: unknown;
2505
+ /**
2506
+ * A boolean indicating if the group expansion is loading. This is normally used for server
2507
+ * data loading, which expansions occur only after the group's children data has been fetched.
2508
+ */
2509
+ readonly loadingGroup?: boolean;
2455
2510
  }
2456
2511
  /**
2457
2512
  * A height configuration for rows. May be:
@@ -5510,17 +5565,29 @@ export interface PopoverFrameRendererParams<T> {
5510
5565
  */
5511
5566
  export type CellSelectionMode = "range" | "multi-range" | "none";
5512
5567
  /**
5513
- * Fetches pivoted columns for the grid's current pivot configuration.
5568
+ * Fetches the set of pivoted columns defined by the grid's current pivot
5569
+ * configuration. The fetcher retrieves metadata for each pivoted column
5570
+ * independently from the row data, ensuring that column definitions reflect
5571
+ * the active pivot state at the time of the request. This process allows the
5572
+ * grid to update column pivots dynamically when the configuration changes or
5573
+ * when multiple pivot definitions are requested concurrently.
5514
5574
  *
5515
5575
  * @group Row Data Source
5516
5576
  */
5517
5577
  export type DataColumnPivotFetcherFn<T> = (
5518
5578
  /**
5519
- * The parameters provided to the column pivot fetcher.
5579
+ * The parameters passed to the column pivot fetcher. These parameters include
5580
+ * the unix timestamp of the request, which ensures consistency when resolving
5581
+ * conflicts across concurrent pivot requests, as well as any configuration
5582
+ * details required to retrieve the correct set of pivoted column definitions
5583
+ * from the server.
5520
5584
  */
5521
5585
  params: DataColumnPivotFetcherParams<T>) => Promise<Column<T>[]>;
5522
5586
  /**
5523
- * Parameters passed to the column pivot fetcher function.
5587
+ * When column pivots are applied in LyteNyte Grid, the grid fetches pivot column
5588
+ * definitions separately from the pivot row data. The `DataColumnPivotFetcherParams`
5589
+ * type defines the parameters passed to the fetcher that retrieves these column
5590
+ * pivot definitions from the server.
5524
5591
  *
5525
5592
  * @group Row Data Source
5526
5593
  */
@@ -5530,26 +5597,70 @@ export interface DataColumnPivotFetcherParams<T> {
5530
5597
  */
5531
5598
  readonly grid: Grid<T>;
5532
5599
  /**
5533
- * Timestamp representing the time of the request.
5600
+ * The unix timestamp at the time of the request. The system uses this value to
5601
+ * resolve conflicts when multiple column pivot definitions are requested. Such
5602
+ * conflicts can occur if the pivot configuration changes while a column pivot
5603
+ * request is in flight.
5534
5604
  */
5535
5605
  readonly reqTime: number;
5536
5606
  /**
5537
- * The full model describing the pivot request state.
5607
+ * The `model` property contains the full `DataRequestModel`, which captures the grid's state at the moment the
5608
+ * request is created. This snapshot includes all relevant settings: sorting,
5609
+ * filtering, grouping, pivot configuration, and aggregation rules.
5610
+ *
5611
+ * The server uses the `model` to interpret how data should be prepared before returning
5612
+ * it to the client. For example, the model tells the server which filters to
5613
+ * apply, how rows should be grouped, and what aggregations to compute.
5614
+ *
5615
+ * Because it is a snapshot, the `model` does not remain in sync with the grid after
5616
+ * the request is sent. It represents the state as it existed when the request was
5617
+ * created, ensuring that the server response aligns with the user's view at that time.
5538
5618
  */
5539
5619
  readonly model: DataRequestModel<T>;
5540
5620
  }
5541
5621
  /**
5542
- * Fetches grid row data asynchronously for the LyteNyte Server Data Source.
5622
+ * A function used by LyteNyte Grid's server row data source to fetch blocks of row
5623
+ * data slices from the server. This function must be implemented by the developer,
5624
+ * and LyteNyte Grid will call it whenever the view in the grid changes.
5625
+ *
5626
+ * The function receives a `DataFetcherParams` object that contains all the
5627
+ * information required to construct a server request. This includes the set of
5628
+ * `DataRequest` objects for the current view, a snapshot of the grid state
5629
+ * (`DataRequestModel`), and a `reqTime` value marking when the request was
5630
+ * initiated.
5631
+ *
5632
+ * By providing both the request details and the current grid model, LyteNyte Grid
5633
+ * ensures that the server can return data consistent with the user's view. This
5634
+ * allows developers to handle sorting, filtering, grouping, pivoting, and
5635
+ * aggregation on the server side while keeping the grid synchronized.
5636
+ *
5637
+ * The function must return a promise that resolves to an array of `DataResponse`
5638
+ * or `DataResponsePinned` objects, which describe the rows and metadata needed
5639
+ * to render the grid.
5543
5640
  *
5544
5641
  * @group Row Data Source
5545
5642
  */
5546
5643
  export type DataFetcherFn<T> = (
5547
5644
  /**
5548
- * The parameters provided to the data fetch function.
5645
+ * The parameters passed to the data fetch function.
5646
+ *
5647
+ * This object contains everything needed for the server to fulfill a grid data
5648
+ * request. It includes one or more `DataRequest` objects (`params.requests`)
5649
+ * that describe the slices to fetch, the full `DataRequestModel` (`params.model`)
5650
+ * capturing the grid's sort, filter, group, pivot, and aggregation state, and a
5651
+ * `reqTime` value marking when the request was initiated.
5652
+ *
5653
+ * Together, these parameters let the server return data that matches the user's
5654
+ * current view while handling asynchronous requests consistently.
5549
5655
  */
5550
5656
  params: DataFetcherParams<T>) => Promise<(DataResponse | DataResponsePinned)[]>;
5551
5657
  /**
5552
- * Input parameters provided to a grid data fetcher function.
5658
+ * The LyteNyte Grid server data source requires a `dataFetcher` function. The `DataFetcherParams` type describes the
5659
+ * parameters that LyteNyte Grid passes to this function when performing data loading.
5660
+ *
5661
+ * These parameters include a set of `DataRequest` objects based on the current grid view
5662
+ * and the `DataRequestModel` at the time of the call. A `reqTime` value is also provided,
5663
+ * which is a Unix timestamp indicating when the request was made.
5553
5664
  *
5554
5665
  * @group Row Data Source
5555
5666
  */
@@ -5559,30 +5670,71 @@ export interface DataFetcherParams<T> {
5559
5670
  */
5560
5671
  readonly grid: Grid<T>;
5561
5672
  /**
5562
- * Array of individual data fetch requests.
5673
+ * The `requests` property is an array of `DataRequest` objects. Each object defines a slice of
5674
+ * grid data to load, including its `path`, `start`, and `end` values, along with related metadata.
5675
+ * These requests describe exactly which part of the row tree the server should return data for.
5676
+ *
5677
+ * LyteNyte Grid may issue multiple `DataRequest` objects at once, depending on the user's
5678
+ * current view. For example, if different branches of a grouped view are visible,
5679
+ * separate requests are created for each branch.
5680
+ *
5681
+ * This property ensures that the server receives all necessary instructions to
5682
+ * provide data slices consistently, even when the grid state is complex or rapidly changing.
5563
5683
  */
5564
5684
  readonly requests: DataRequest[];
5565
5685
  /**
5566
- * Unix timestamp representing when the request was initiated.
5686
+ * The `reqTime` property is a Unix timestamp indicating when the request was initiated.
5687
+ * This value is included with every data fetch so LyteNyte Grid can resolve
5688
+ * conflicts that occur when asynchronous requests complete out of order.
5689
+ *
5690
+ * If two requests target the same slice of data, the one with the later `reqTime` value takes
5691
+ * precedence. This guarantees that the grid reflects the most up-to-date
5692
+ * information, even when network latency or rapid user interactions
5693
+ * cause responses to arrive unpredictably.
5694
+ *
5695
+ * By tracking freshness through `reqTime`, the grid avoids overwriting newer data
5696
+ * with stale results, providing a consistent user experience. The `asOfTime` property on the
5697
+ * responses takes priority over the `reqTime` value.
5567
5698
  */
5568
5699
  readonly reqTime: number;
5569
5700
  /**
5570
- * The full data request model describing grid state.
5701
+ * The `model` property contains the full `DataRequestModel`, which captures the grid's state at the moment the
5702
+ * request is created. This snapshot includes all relevant settings: sorting,
5703
+ * filtering, grouping, pivot configuration, and aggregation rules.
5704
+ *
5705
+ * The server uses the `model` to interpret how data should be prepared before returning
5706
+ * it to the client. For example, the model tells the server which filters to
5707
+ * apply, how rows should be grouped, and what aggregations to compute.
5708
+ *
5709
+ * Because it is a snapshot, the `model` does not remain in sync with the grid after
5710
+ * the request is sent. It represents the state as it existed when the request was
5711
+ * created, ensuring that the server response aligns with the user's view at that time.
5571
5712
  */
5572
5713
  readonly model: DataRequestModel<T>;
5573
5714
  }
5574
5715
  /**
5575
- * Fetches items used in "in" filters from a server-side source.
5716
+ * Retrieves the unique items used in "in" filters from the server-side data
5717
+ * source. This fetch ensures that filter options reflect the actual distinct
5718
+ * values stored on the server for the specified column.
5576
5719
  *
5577
5720
  * @group Row Data Source
5578
5721
  */
5579
5722
  export type DataInFilterItemFetcherFn<T> = (
5580
5723
  /**
5581
- * The parameters for the in-filter fetcher function.
5724
+ * The parameters passed to the in-filter fetcher function. These include details
5725
+ * such as the target column and the request timestamp, which ensure the fetcher
5726
+ * returns the correct set of unique filter items from the server.
5582
5727
  */
5583
5728
  params: DataInFilterItemFetcherParams<T>) => Promise<FilterInFilterItem[]> | FilterInFilterItem[];
5584
5729
  /**
5585
- * Parameters passed to the in-filter fetcher function.
5730
+ * The in filter (set filter) in LyteNyte Grid requests possible values from the
5731
+ * row data source attached to the grid state. For a server data source, the
5732
+ * unique values for a given column are stored on the server.
5733
+ *
5734
+ * Developers can supply a `DataInFilterItemFetcherFn` to the server data
5735
+ * source to retrieve these unique filter items. The
5736
+ * `DataInFilterItemFetcherParams` type defines the parameters passed to the
5737
+ * fetcher function.
5586
5738
  *
5587
5739
  * @group Row Data Source
5588
5740
  */
@@ -5596,220 +5748,445 @@ export interface DataInFilterItemFetcherParams<T> {
5596
5748
  */
5597
5749
  readonly column: Column<T>;
5598
5750
  /**
5599
- * Timestamp for the in-filter fetch request.
5751
+ * The unix timestamp recorded when the in-filter fetch request is made. It
5752
+ * ensures consistency and helps resolve conflicts if multiple filter requests
5753
+ * for the same column occur at the same time.
5600
5754
  */
5601
5755
  readonly reqTime: number;
5602
5756
  }
5603
5757
  /**
5604
- * Represents a specific request for data to an external data source.
5758
+ * The `DataRequest` type represents a request for a slice of data from the server.
5759
+ * A slice can target either the root of the view or a specific grouping,
5760
+ * identified by the `path` property.
5761
+ *
5762
+ * Each request includes a unique ID, which can be used to deduplicate
5763
+ * requests or enable caching. It also defines `start` and `end` values that specify
5764
+ * the offsets of the requested slice.
5765
+ *
5766
+ * LyteNyte Grid may issue multiple `DataRequest` objects at once, depending on
5767
+ * the user's current view. Each request is a snapshot of the
5768
+ * grid state at the time it was made.
5605
5769
  *
5606
5770
  * @group Row Data Source
5607
5771
  */
5608
5772
  export interface DataRequest {
5609
5773
  /**
5610
- * Unique id for the request, useful for caching and deduplication.
5774
+ * The `id` property uniquely identifies a data request. LyteNyte Grid
5775
+ * generates this value from the request path and the slice's `start` and `end` values.
5776
+ * The ID can be used to deduplicate requests or cache results.
5611
5777
  */
5612
5778
  readonly id: string;
5613
5779
  /**
5614
- * Hierarchy path for the request. An empty array represents the root level.
5780
+ * The `path` property identifies the position in the data tree for a request.
5781
+ * LyteNyte Grid stores requested slices in a tree structure: the tree is flat
5782
+ * when no row grouping is applied, and nested when groups are present.
5783
+ * The `path` specifies which branch of the tree the request targets.
5784
+ *
5785
+ * Developers typically only need to fetch data for the given `path` value. In practice,
5786
+ * the path usually translates into a filter. For example, if rows are grouped
5787
+ * by the `Category` column and the path is `["critical"]`, the server may apply
5788
+ * a filter such as `WHERE Category = 'critical'`.
5615
5789
  */
5616
5790
  readonly path: (string | null)[];
5617
5791
  /**
5618
- * Start offset of the requested rows, relative to the current path.
5792
+ * The `start` value specifies the offset from the first row
5793
+ * of the current data slice, relative to the node identified by
5794
+ * the `path`. LyteNyte Grid stores slices in a tree structure: flat when
5795
+ * no row grouping is applied, and nested when groups are present.
5796
+ * Unlike a global row index, `start` is always relative to its parent node.
5797
+ *
5798
+ * In SQL, `start` typically maps to an `OFFSET` value. For example,
5799
+ * if the block size is `100`, the request might translate to `LIMIT 100 OFFSET <start>`.
5619
5800
  */
5620
5801
  readonly start: number;
5621
5802
  /**
5622
- * End offset of the requested rows, relative to the current path.
5803
+ * The `end` value specifies the offset of the last row in the current data slice.
5804
+ * It is calculated as `start + blockSize`, but constrained by the node size (row count)
5805
+ * to avoid exceeding available rows. In practice, `end` is often not required for SQL-based
5806
+ * implementations of server data loading, but it is included for completeness and for non-SQL backends.
5807
+ *
5808
+ * Like other slice values, `end` is relative to the node identified by the `path` in LyteNyte Grid's tree
5809
+ * structure. The tree is flat when no row grouping is applied and nested when groups are present.
5623
5810
  */
5624
5811
  readonly end: number;
5625
5812
  /**
5626
- * Grid row index where the request starts.
5813
+ * The `rowStartIndex` is the projected index of the first row in the requested data.
5814
+ * It is an estimate of where LyteNyte expects the row to appear once the request resolves,
5815
+ * not the actual row index. For example, if row groups are applied and the
5816
+ * parent node is rendered at row index `20`, then `rowStartIndex` will be `20 + start`.
5817
+ *
5818
+ * Use `rowStartIndex` only in advanced server view implementations.
5819
+ * Because projected indices can change before a request resolves, relying on
5820
+ * this value increases complexity and should be avoided in most cases.
5627
5821
  */
5628
5822
  readonly rowStartIndex: number;
5629
5823
  /**
5630
- * Grid row index where the request ends.
5824
+ * The `rowEndIndex` is the projected index of the last row in the requested data slice.
5825
+ * Like `rowStartIndex`, it is an estimate based on where LyteNyte expects the rows to appear once
5826
+ * the request resolves, not an actual row index. For example, if a slice requests 100 rows and
5827
+ * the projected `rowStartIndex` is `20`, then the projected `rowEndIndex` will be `120`.
5828
+ *
5829
+ * Use `rowEndIndex` only in advanced server view implementations. Because projected indices
5830
+ * can change before a request resolves, relying on this value increases complexity and
5831
+ * should be avoided in most cases.
5631
5832
  */
5632
5833
  readonly rowEndIndex: number;
5633
5834
  }
5634
5835
  /**
5635
- * Describes the current grid state used to construct a request for external data.
5836
+ * The data request model represents the current LyteNyte Grid state at the time of creation.
5837
+ * It concatenates the grid's internal models into a single structure used to request external data.
5838
+ * Depending on your server's capabilities, you can choose to omit certain parts of the model.
5839
+ *
5840
+ * The model is a snapshot only; it is not reactive and does not stay in sync with the grid's ongoing state.
5636
5841
  *
5637
5842
  * @group Row Data Source
5638
5843
  */
5639
5844
  export interface DataRequestModel<T> {
5640
5845
  /**
5641
- * Array of column sort configurations.
5846
+ * The `sorts` property is an array of column sort configurations.
5847
+ * The grid can apply multiple sorts at once, which the server should respect when ordering rows.
5848
+ * Use the sort model on the server to ensure rows appear in the order the user expects. In SQL,
5849
+ * sorts typically translate to an `ORDER BY <column> ASC|DESC` clause. In NoSQL systems,
5850
+ * apply the equivalent ordering logic.
5642
5851
  */
5643
5852
  readonly sorts: SortModelItem<T>[];
5644
5853
  /**
5645
- * The simple filters currently applied to columns. The key of the record is the column
5646
- * id. It is not guaranteed that the column id in the filters is present in the columns in the grid.
5854
+ * The `filters` property records the column filters applied to the grid. It stores key/value pairs
5855
+ * where the key is a column ID and the value is the filter definition. LyteNyte Grid
5856
+ * allows keys that do not match a column in the current state, enabling dynamic
5857
+ * filters defined on the server but not present on the client.
5858
+ *
5859
+ * Filter values can represent any type, including text, number, or date filters.
5860
+ * The server is responsible for applying these filters and returning the results.
5861
+ * In SQL, filters typically translate into `WHERE` clauses.
5647
5862
  */
5648
5863
  readonly filters: Record<string, FilterModelItem<T>>;
5649
5864
  /**
5650
- * The in (set) filters currently applied to the columns. The key of the record is the column
5651
- * id. It is not guaranteed that the column id in the in filters is present in the columns in the grid.
5865
+ * The `filtersIn` property stores set filters applied to the grid. It uses key/value pairs where
5866
+ * the key is a column ID and the value is a set filter that includes or excludes specific values.
5867
+ * LyteNyte Grid allows keys that do not match a column in the current state,
5868
+ * enabling dynamic filters defined on the server but not present on the client.
5869
+ *
5870
+ * Values in a set filter are unique by definition and cannot repeat. The server
5871
+ * applies these filters and returns the results. In SQL, set filters typically
5872
+ * translate into `WHERE <column> IN (<set>)` clauses.
5652
5873
  */
5653
5874
  readonly filtersIn: Record<string, FilterIn>;
5654
5875
  /**
5655
- * Quick search text value, or null if not in use.
5876
+ * The `quickSearch` property stores a text filter matched against cell values in
5877
+ * each column. The server decides which columns to search and how to
5878
+ * apply the text match. In SQL, quick search filters typically
5879
+ * translate into multiple `WHERE <column> LIKE '%<value>%'` clauses.
5656
5880
  */
5657
5881
  readonly quickSearch: string | null;
5658
5882
  /**
5659
- * Group model defining how rows are grouped.
5883
+ * The `groups` property stores the row grouping model currently applied to the grid.
5884
+ * Each item in the model represents a grouping level, which can be defined by a
5885
+ * column or by a dynamic expression. Row groups typically translate into `GROUP BY` clauses in SQL.
5886
+ *
5887
+ * When a data request is made, the full group model is included, but the request targets
5888
+ * only a specific slice of grouped data, identified by the `path` value. Including the entire
5889
+ * model supports optimistic data loading and provides full context for the grouped view.
5660
5890
  */
5661
5891
  readonly groups: RowGroupModelItem<T>[];
5662
5892
  /**
5663
- * Expansion state of row groups by group key.
5893
+ * The `groupExpansions` property stores the expansion state of group rows as key/value pairs.
5894
+ * The key is a row ID, and the value is either a boolean or `undefined`.
5895
+ * A value of `undefined` means the row has not been explicitly expanded or collapsed,
5896
+ * so the default expansion state determines whether it is open or closed.
5897
+ *
5898
+ * `groupExpansions` is used only for optimistic data loading,
5899
+ * since LyteNyte Grid requests data for individual group slices.
5664
5900
  */
5665
5901
  readonly groupExpansions: Record<string, boolean | undefined>;
5666
5902
  /**
5667
- * Map of aggregation functions per column.
5903
+ * The `aggregations` property defines how column values are aggregated when row groups are present.
5904
+ * Aggregations are applied per column, but the output does not need to match the grid's columns exactly.
5905
+ * Some columns may omit aggregation if none applies, while others
5906
+ * may include additional aggregations to attach extra data to a row.
5907
+ *
5908
+ * Each aggregation typically produces a column in the server response and
5909
+ * translates to an SQL clause such as `SUM(<column>) AS <alias>`.
5668
5910
  */
5669
5911
  readonly aggregations: Record<string, {
5670
5912
  fn: AggModelFn<T>;
5671
5913
  }>;
5672
5914
  /**
5673
- * Expansion state of pivot row groups.
5915
+ * The `pivotGroupExpansions` property stores the expansion state of pivot group rows as key/value pairs.
5916
+ * The key is a row ID, and the value is either a boolean or `undefined`. A value of `undefined` means the row has
5917
+ * not been explicitly expanded or collapsed, so the default expansion state decides whether it is open or closed.
5674
5918
  */
5675
5919
  readonly pivotGroupExpansions: Record<string, boolean | undefined>;
5676
5920
  /**
5677
- * Indicates whether pivot mode is enabled.
5921
+ * The `pivotMode` property is a boolean that indicates whether the pivot view in
5922
+ * LyteNyte Grid is active. Check this value before returning pivot data, since
5923
+ * pivot columns are not displayed unless the mode is enabled.
5678
5924
  */
5679
5925
  readonly pivotMode: boolean;
5680
5926
  /**
5681
- * Model describing current pivot column state.
5927
+ * The `pivotModel` defines the current pivot configuration of the grid.
5928
+ * It specifies which columns act as pivots, the measures applied to those
5929
+ * pivots, the row groups to include, the sort state of pivot columns, and any filters in effect.
5930
+ *
5931
+ * The server uses this model to determine which pivoted data to return.
5682
5932
  */
5683
5933
  readonly pivotModel: ColumnPivotModel<T>;
5684
5934
  }
5685
5935
  /**
5686
- * Response object for row data from a center section request.
5936
+ * LyteNyte Grid's server data source sends request objects describing the
5937
+ * data needed to render the grid. The server responds with
5938
+ * one or more `DataResponse` objects.
5939
+ *
5940
+ * A `DataResponse` contains the rows and metadata required to render a slice of
5941
+ * the grid's view. Each response includes a `path` value, which identifies where in the row
5942
+ * tree the data belongs. Parent paths must be provided
5943
+ * before their child paths can be created.
5944
+ *
5945
+ * The server data source can handle multiple responses at once.
5946
+ * Sending multiple responses for different slices is common, especially
5947
+ * when data updates frequently.
5687
5948
  *
5688
5949
  * @group Row Data Source
5689
5950
  */
5690
5951
  export interface DataResponse {
5691
5952
  /**
5692
- * Must be "center" the section this response applies to.
5953
+ * A type discriminant used by LyteNyte Grid to identify responses for scrollable
5954
+ * rows. Pinned rows use a different structure, so for scrollable
5955
+ * rows this value must always be `"center"`.
5693
5956
  */
5694
5957
  readonly kind: "center";
5695
5958
  /**
5696
- * Array of leaf or branch rows returned for the given path.
5959
+ * An array of row items returned for the
5960
+ * specified `path`. Each item is either a `DataResponseLeafItem` (a leaf row with no children)
5961
+ * or a `DataResponseBranchItem` (a group row with nested children).
5962
+ *
5963
+ * If a response includes leaf items for a grouping that is not the final level,
5964
+ * the result is an unbalanced tree. In this case, those leaf rows cannot
5965
+ * be expanded further, regardless of the group model.
5697
5966
  */
5698
5967
  readonly data: (DataResponseLeafItem | DataResponseBranchItem)[];
5699
5968
  /**
5700
- * Updated row count for the associated path.
5969
+ * The row count for the `path` associated with the response. If the path is empty
5970
+ * (the root view), the size corresponds to the total root row count. LyteNyte Grid uses this
5971
+ * value to determine how much space to reserve for scrollable rows in the viewport.
5701
5972
  */
5702
5973
  readonly size: number;
5703
5974
  /**
5704
- * Unix timestamp indicating when the data is valid from. Used to resolve response conflicts.
5975
+ * The `asOfTime` property is a Unix timestamp that indicates data freshness.
5976
+ * LyteNyte Grid uses it to resolve request conflicts.
5977
+ *
5978
+ * When data is loaded asynchronously, requests may arrive out of order.
5979
+ * If two requests target the same row, the one with the later `asOfTime` value takes precedence.
5705
5980
  */
5706
5981
  readonly asOfTime: number;
5707
5982
  /**
5708
- * Hierarchy path the data belongs to. Empty array means root.
5983
+ * The `path` property identifies the part of the row tree that this
5984
+ * response belongs to. It must match the path provided in the data request.
5985
+ * Because LyteNyte Grid represents the view as a flattened row tree,
5986
+ * the path links data to its correct position in the hierarchy.
5987
+ *
5988
+ * For a path to be valid, its parent must already exist or be created as
5989
+ * part of the current response set. Attempting to load a deeply nested
5990
+ * path before its parents is an error.
5991
+ *
5992
+ * A path array may include `null` values to represent missing values in
5993
+ * a grouping. This acts as a catch-all for row groups
5994
+ * without values in every level.
5709
5995
  */
5710
5996
  readonly path: (string | null)[];
5711
5997
  /**
5712
- * Start offset within the hierarchy segment.
5998
+ * The first relative index where data should begin loading. This value must match
5999
+ * the `start` value in the data request and is relative to the slice's
6000
+ * group, not the row index in the view.
6001
+ *
6002
+ * Avoid using a different `start` value than the request. The only valid case is
6003
+ * when the response lowers the `start` value, typically for optimistic data loading
6004
+ * or refreshing nearby rows in the view.
5713
6005
  */
5714
6006
  readonly start: number;
5715
6007
  /**
5716
- * End offset within the hierarchy segment.
6008
+ * The last relative index where data should stop loading. This value must
6009
+ * match the `end` value in the data request. For optimistic data loading,
6010
+ * it may differ, but it must still be greater than the corresponding `start` value
6011
+ * and less than the slice `size`.
5717
6012
  */
5718
6013
  readonly end: number;
5719
6014
  }
5720
6015
  /**
5721
- * Represents a group (branch) row returned from a data request.
6016
+ * The `DataResponseBranchItem` represents a group node.
6017
+ * These items are converted into group row nodes and
6018
+ * indicate that additional child rows are nested beneath them.
5722
6019
  *
5723
6020
  * @group Row Data Source
5724
6021
  */
5725
6022
  export interface DataResponseBranchItem {
5726
6023
  /**
5727
- * Discriminates the item as a branch response.
6024
+ * A type discriminant used by LyteNyte Grid to distinguish between leaf and
6025
+ * group items in a server response. When a response item has this kind,
6026
+ * the grid creates an expandable group row.
5728
6027
  */
5729
6028
  readonly kind: "branch";
5730
6029
  /**
5731
- * Unique identifier used to create the branch row.
6030
+ * A unique ID for the row. LyteNyte Grid uses this ID to track group
6031
+ * expansion, retrieve rows, and manage selection. The ID must be
6032
+ * unique across all rows, including leaf nodes.
5732
6033
  */
5733
6034
  readonly id: string;
5734
6035
  /**
5735
- * The row data associated with this branch.
6036
+ * The row data for the group node. This value can be any type,
6037
+ * but LyteNyte Grid typically expects a set of key/value pairs.
6038
+ * Server responses usually contain aggregated data for the group
6039
+ * node, though not every column requires a value. The aggregation
6040
+ * model defines the expected shape of this object.
5736
6041
  */
5737
6042
  readonly data: any;
5738
6043
  /**
5739
- * The key of the group the row represents.
6044
+ * A group or branch node represents a branch in the row data tree used for grouped views.
6045
+ * Each node's position in the tree is determined by its `key`, which represents the
6046
+ * path from the root. LyteNyte Grid uses this key to place the row node in
6047
+ * the correct location within the tree.
6048
+ *
6049
+ * The `key` may be `null` if the grouping has no value.
6050
+ * In this case, `null` represents the absence of a value for that grouping.
5740
6051
  */
5741
6052
  readonly key: string | null;
5742
6053
  /**
5743
- * Number of immediate children under this group.
6054
+ * A group node has child rows, though they do not need to be loaded immediately.
6055
+ * The server should indicate how many child rows a group node contains.
6056
+ * This value can be updated in later requests and serves as a hint to
6057
+ * LyteNyte Grid rather than a strict contract.
6058
+ *
6059
+ * In SQL, retrieving child counts typically translates
6060
+ * to a `COUNT(*)` query combined with a `GROUP BY` statement.
5744
6061
  */
5745
6062
  readonly childCount: number;
5746
6063
  }
5747
6064
  /**
5748
- * Represents a row of data (a leaf node) returned in a server response.
6065
+ * The `DataResponseLeafItem` represents the data for a leaf row node. A leaf node is the last
6066
+ * level in the data tree and cannot be expanded further. Leaf nodes appear when the view
6067
+ * is flat (no row groups) or when the expanded row is at the final grouping level.
6068
+ *
6069
+ * Each `DataResponseLeafItem` corresponds to a single row node, and responses can mix
6070
+ * different node types in the same request. When row groups are present, a leaf
6071
+ * item may appear before the final grouping level, which can result in unbalanced groups.
5749
6072
  *
5750
6073
  * @group Row Data Source
5751
6074
  */
5752
6075
  export interface DataResponseLeafItem {
5753
6076
  /**
5754
- * Type identifier for a leaf response item.
6077
+ * A type discriminant used by LyteNyte Grid to distinguish between leaf and
6078
+ * group data items returned by the server. When a response item has this
6079
+ * kind, the grid creates a leaf row that cannot be expanded further.
6080
+ * If no row groups are defined, all data responses should be leaf items.
5755
6081
  */
5756
6082
  readonly kind: "leaf";
5757
6083
  /**
5758
- * Unique row identifier for the grid.
6084
+ * The unique ID that LyteNyte assigns to each row. This ID is used
6085
+ * for row selection, retrieval, updates, and as the rendering key.
6086
+ * It must be unique across all rows in all data responses.
5759
6087
  */
5760
6088
  readonly id: string;
5761
6089
  /**
5762
- * Arbitrary data associated with this row.
6090
+ * The data associated with the row node created from the response.
6091
+ * This value can be any type and should match your application's use case.
6092
+ * LyteNyte Grid does not validate this data; the server is treated as trusted,
6093
+ * and developers are responsible for ensuring the data is appropriate for the view.
5763
6094
  */
5764
6095
  readonly data: any;
5765
6096
  }
5766
6097
  /**
5767
- * Response object for setting pinned row data (top or bottom).
6098
+ * Pinned rows in LyteNyte Grid remain visible regardless of user interaction
6099
+ * such as scrolling. By definition, pinned rows do not move within the view.
6100
+ *
6101
+ * The `DataResponsePinned` type provides data for pinned rows and allows the
6102
+ * server to set or update rows pinned to the top or bottom of the view.
5768
6103
  *
5769
6104
  * @group Row Data Source
5770
6105
  */
5771
6106
  export interface DataResponsePinned {
5772
6107
  /**
5773
- * Specifies the pinned section this data applies to: "top" or "bottom".
6108
+ * A type discriminant used by LyteNyte Grid to indicate whether pinned rows
6109
+ * belong at the top or bottom of the view. To support both top and
6110
+ * bottom pinned rows, the server must send two separate data responses.
5774
6111
  */
5775
6112
  readonly kind: "top" | "bottom";
5776
6113
  /**
5777
- * Array of leaf rows for the pinned section.
6114
+ * The data items used by LyteNyte Grid to create pinned rows.
6115
+ * Pinned rows are always leaf rows. The response can include any number of pinned
6116
+ * rows, but it is usually best to provide only one or two.
5778
6117
  */
5779
6118
  readonly data: DataResponseLeafItem[];
5780
6119
  /**
5781
- * Unix timestamp indicating when the data is valid from. Used to resolve response conflicts.
6120
+ * The `asOfTime` property is a Unix timestamp that indicates data freshness.
6121
+ * LyteNyte Grid uses it to resolve request conflicts.
6122
+ *
6123
+ * When data is loaded asynchronously, requests may arrive out of order.
6124
+ * If two requests target the same row, the one with the later `asOfTime` value takes precedence.
5782
6125
  */
5783
6126
  readonly asOfTime: number;
5784
6127
  }
5785
6128
  /**
5786
- * Parameters for configuring the server row data source.
6129
+ * The LyteNyte Grid server row data source provides an implementation optimized
6130
+ * for fetching data in slices from the server.
6131
+ *
6132
+ * The `RowDataSourceServerParams` type defines the configuration parameters
6133
+ * that can be passed to this row data source.
5787
6134
  *
5788
6135
  * @group Row Data Source
5789
6136
  */
5790
6137
  export interface RowDataSourceServerParams<T> {
5791
6138
  /**
5792
- * Function that fetches grid data when rows are requested.
6139
+ * The `dataFetcher` function is required by the LyteNyte Grid server data source
6140
+ * and serves as its main entry point for retrieving rows. It fetches row slices
6141
+ * from the server based on the current grid view. LyteNyte Grid calls this function
6142
+ * whenever the view changes, which means it may be invoked frequently if the view
6143
+ * updates often.
5793
6144
  */
5794
6145
  readonly dataFetcher: DataFetcherFn<T>;
5795
6146
  /**
5796
- * Optional function to fetch columns when pivot mode is enabled.
6147
+ * A list of external dependencies the data source should depend on. If any of these properties
6148
+ * change, then the grid will reset and fetch the data from the server again. This is the equivalent
6149
+ * of adding watch keys/dependency tracking to the grid.
6150
+ *
6151
+ * Use this property when you want the grid to reset based on some external piece of data, such as an
6152
+ * external search query.
6153
+ */
6154
+ readonly dataFetchExternals?: unknown[];
6155
+ /**
6156
+ * Column pivots produce column definitions derived from the row data. Because the
6157
+ * server data source does not have full access to row data, it relies on a
6158
+ * `dataColumnPivotFetcher` function. The server data source calls this function
6159
+ * to fetch pivot column definitions whenever the pivot configuration changes.
5797
6160
  */
5798
6161
  readonly dataColumnPivotFetcher?: DataColumnPivotFetcherFn<T>;
5799
6162
  /**
5800
- * Optional function for fetching items for in-type filters.
6163
+ * The `inFilter` in LyteNyte Grid filters rows by the unique values of a column.
6164
+ * LyteNyte Grid retrieves these values from the row data source. For server data
6165
+ * sources, the `dataInFilterItemFetcher` function retrieves the filter items on
6166
+ * demand. These items are then included with data requests to apply the filter.
5801
6167
  */
5802
6168
  readonly dataInFilterItemFetcher?: DataInFilterItemFetcherFn<T>;
5803
6169
  /**
5804
- * Function called to handle cell updates in the grid.
6170
+ * LyteNyte Grid supports cell editing, but the row data source must perform the
6171
+ * actual update once an edit completes. For a server data source, the data is not
6172
+ * stored on the client, so LyteNyte Grid calls the `cellUpdateHandler` function
6173
+ * to trigger the server update.
6174
+ *
6175
+ * Developers are responsible for executing the update and handling errors. The
6176
+ * `cellUpdateHandler` provides the hook for managing these updates.
5805
6177
  */
5806
6178
  readonly cellUpdateHandler?: (updates: Map<string, any>) => void;
5807
6179
  /**
5808
- * Whether cell updates should be applied optimistically.
6180
+ * If true, applies cell edits to the UI before the server confirms the update.
6181
+ * This is an optimistic update, assuming the server operation will succeed.
6182
+ * Developers are responsible for reconciling server-side changes and handling
6183
+ * any failures that occur.
5809
6184
  */
5810
6185
  readonly cellUpdateOptimistically?: boolean;
5811
6186
  /**
5812
- * Number of rows to fetch in a single data block request.
6187
+ * LyteNyte Grid's server data source fetches row data in slices. The `blockSize`
6188
+ * property controls the size of each slice. A larger `blockSize` reduces the
6189
+ * number of requests but increases the amount of data transferred per request.
5813
6190
  */
5814
6191
  readonly blockSize?: number;
5815
6192
  }