@svgrid/grid 2.2.15 → 2.2.17
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/README.md +1 -1
- package/dist/GridFooter.svelte +12 -11
- package/dist/SvAnchor.svelte +65 -0
- package/dist/SvAnchor.svelte.d.ts +24 -0
- package/dist/SvAspectRatio.svelte +38 -0
- package/dist/SvAspectRatio.svelte.d.ts +16 -0
- package/dist/SvAutoComplete.svelte +52 -7
- package/dist/SvAutoComplete.svelte.d.ts +4 -1
- package/dist/SvBlockquote.svelte +43 -0
- package/dist/SvBlockquote.svelte.d.ts +16 -0
- package/dist/SvCalendar.svelte +33 -2
- package/dist/SvCalendar.svelte.d.ts +8 -1
- package/dist/SvCheckBox.svelte +6 -2
- package/dist/SvCode.svelte +52 -0
- package/dist/SvCode.svelte.d.ts +19 -0
- package/dist/SvCollapsible.svelte +75 -0
- package/dist/SvCollapsible.svelte.d.ts +27 -0
- package/dist/SvColorInput.svelte +11 -17
- package/dist/SvColorInput.svelte.d.ts +2 -0
- package/dist/SvComboBox.svelte +85 -8
- package/dist/SvComboBox.svelte.d.ts +14 -0
- package/dist/SvCountryInput.svelte +2 -2
- package/dist/SvCountryInput.svelte.d.ts +1 -1
- package/dist/SvDropDownList.svelte +154 -51
- package/dist/SvDropDownList.svelte.d.ts +17 -3
- package/dist/SvDurationInput.svelte +59 -41
- package/dist/SvDurationInput.svelte.d.ts +18 -0
- package/dist/SvField.svelte +203 -12
- package/dist/SvField.svelte.d.ts +45 -8
- package/dist/SvForm.svelte +195 -21
- package/dist/SvForm.svelte.d.ts +23 -0
- package/dist/SvGrid.controller.svelte.d.ts +12 -1
- package/dist/SvGrid.controller.svelte.js +87 -7
- package/dist/SvGrid.svelte +383 -181
- package/dist/SvGrid.types.d.ts +123 -2
- package/dist/SvGridChartView.svelte +70 -0
- package/dist/SvGridChartView.svelte.d.ts +11 -0
- package/dist/SvGridDropdown.svelte +9 -2
- package/dist/SvGridSelect.svelte +5 -2
- package/dist/SvGridSelect.svelte.d.ts +1 -1
- package/dist/SvGroup.svelte +41 -0
- package/dist/SvGroup.svelte.d.ts +27 -0
- package/dist/SvHoverCard.svelte +70 -0
- package/dist/SvHoverCard.svelte.d.ts +41 -0
- package/dist/SvKbd.svelte +51 -0
- package/dist/SvKbd.svelte.d.ts +18 -0
- package/dist/SvList.svelte +55 -0
- package/dist/SvList.svelte.d.ts +23 -0
- package/dist/SvListBox.svelte +166 -77
- package/dist/SvListBox.svelte.d.ts +17 -4
- package/dist/SvLoadingOverlay.svelte +53 -0
- package/dist/SvLoadingOverlay.svelte.d.ts +28 -0
- package/dist/SvMark.svelte +36 -0
- package/dist/SvMark.svelte.d.ts +14 -0
- package/dist/SvMaskedInput.svelte +50 -35
- package/dist/SvMaskedInput.svelte.d.ts +17 -2
- package/dist/SvMenuList.svelte +32 -3
- package/dist/SvMenubar.svelte +200 -0
- package/dist/SvMenubar.svelte.d.ts +18 -0
- package/dist/SvMultiSelect.svelte +7 -4
- package/dist/SvMultiSelect.svelte.d.ts +1 -1
- package/dist/SvNumberInput.svelte +79 -42
- package/dist/SvNumberInput.svelte.d.ts +25 -0
- package/dist/SvOtpInput.svelte +2 -2
- package/dist/SvPasswordInput.svelte +51 -31
- package/dist/SvPasswordInput.svelte.d.ts +17 -0
- package/dist/SvPhoneInput.svelte +39 -28
- package/dist/SvPhoneInput.svelte.d.ts +4 -0
- package/dist/SvPopconfirm.svelte +79 -0
- package/dist/SvPopconfirm.svelte.d.ts +42 -0
- package/dist/SvPopover.svelte +87 -29
- package/dist/SvPopover.svelte.d.ts +18 -4
- package/dist/SvRadioGroup.svelte +5 -1
- package/dist/SvResult.svelte +73 -0
- package/dist/SvResult.svelte.d.ts +28 -0
- package/dist/SvSegmented.svelte +114 -0
- package/dist/SvSegmented.svelte.d.ts +29 -0
- package/dist/SvSimpleGrid.svelte +41 -0
- package/dist/SvSimpleGrid.svelte.d.ts +25 -0
- package/dist/SvSlider.svelte +23 -10
- package/dist/SvSpinner.svelte +43 -0
- package/dist/SvSpinner.svelte.d.ts +20 -0
- package/dist/SvStack.svelte +37 -0
- package/dist/SvStack.svelte.d.ts +24 -0
- package/dist/SvSwitchButton.svelte +6 -1
- package/dist/SvTagsInput.svelte +9 -5
- package/dist/SvText.svelte +76 -0
- package/dist/SvText.svelte.d.ts +31 -0
- package/dist/SvTextInput.svelte +75 -43
- package/dist/SvTextInput.svelte.d.ts +28 -1
- package/dist/SvTimePicker.svelte +32 -2
- package/dist/SvTimePicker.svelte.d.ts +8 -9
- package/dist/SvTitle.svelte +57 -0
- package/dist/SvTitle.svelte.d.ts +24 -0
- package/dist/SvToaster.svelte +41 -6
- package/dist/SvToggleButton.svelte +4 -1
- package/dist/SvTooltip.svelte +68 -34
- package/dist/SvTooltip.svelte.d.ts +14 -2
- package/dist/SvTree.svelte +81 -21
- package/dist/SvTree.svelte.d.ts +3 -2
- package/dist/SvTreeSelect.svelte +5 -2
- package/dist/SvTreeSelect.svelte.d.ts +1 -1
- package/dist/SvVisuallyHidden.svelte +49 -0
- package/dist/SvVisuallyHidden.svelte.d.ts +19 -0
- package/dist/ai.d.ts +289 -0
- package/dist/ai.js +1013 -0
- package/dist/board-view.svelte.d.ts +22 -0
- package/dist/board-view.svelte.js +13 -0
- package/dist/build-api.js +36 -6
- package/dist/cdn/GridMenus-0AK9O7qG.js +420 -0
- package/dist/cdn/GridMenus-BjUoCXoD.js +416 -0
- package/dist/cdn/SvDateTimePicker-CYC7gRER.js +2176 -0
- package/dist/cdn/SvDateTimePicker-DtQKd4Ns.js +2198 -0
- package/dist/cdn/SvGridChart-BcLCYvw9.js +1195 -0
- package/dist/cdn/SvGridChart-BhnFdLd0.js +1203 -0
- package/dist/cdn/SvGridChartPanel-Cmx9DHAS.js +561 -0
- package/dist/cdn/SvGridChartPanel-DvjwxLvK.js +577 -0
- package/dist/cdn/SvGridChartView-B40DTJSX.js +54 -0
- package/dist/cdn/SvGridChartView-PwqI4s02.js +53 -0
- package/dist/cdn/SvGridDropdown-DjALc_4f.js +255 -0
- package/dist/cdn/SvGridDropdown-hpnHvOGt.js +254 -0
- package/dist/cdn/chart-T1usDN0o.js +1212 -0
- package/dist/cdn/disclose-version-DoD9AFD_.js +2958 -0
- package/dist/cdn/export-format-JT5pWVT8.js +561 -0
- package/dist/cdn/popover-P-9P2YYn.js +69 -0
- package/dist/cdn/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/cdn/src-BLhdLmoN.js +25707 -0
- package/dist/cdn/src-BwnUVj3T.js +25623 -0
- package/dist/cdn/svgrid.js +9 -32897
- package/dist/cdn/svgrid.svelte-external.js +9 -30052
- package/dist/cell-formatting.d.ts +2 -2
- package/dist/cell-render.js +4 -4
- package/dist/chart-view.svelte.d.ts +25 -0
- package/dist/chart-view.svelte.js +14 -0
- package/dist/createCombobox.svelte.d.ts +5 -0
- package/dist/createCombobox.svelte.js +21 -5
- package/dist/createDropdownList.svelte.d.ts +3 -0
- package/dist/createDropdownList.svelte.js +8 -2
- package/dist/createForm.svelte.d.ts +18 -0
- package/dist/createForm.svelte.js +51 -6
- package/dist/createMenu.svelte.js +27 -0
- package/dist/createPopoverSelect.svelte.d.ts +3 -0
- package/dist/createPopoverSelect.svelte.js +9 -1
- package/dist/createSlider.svelte.d.ts +8 -21
- package/dist/createSlider.svelte.js +34 -0
- package/dist/createTooltip.svelte.d.ts +12 -0
- package/dist/createTooltip.svelte.js +72 -9
- package/dist/editor-contract.d.ts +15 -0
- package/dist/export-provider.d.ts +27 -0
- package/dist/export-provider.js +9 -0
- package/dist/filter-operators.d.ts +6 -0
- package/dist/filter-operators.js +33 -0
- package/dist/form-field.d.ts +45 -2
- package/dist/grid-messages.d.ts +61 -0
- package/dist/grid-messages.js +72 -0
- package/dist/group-display.d.ts +62 -0
- package/dist/group-display.js +78 -0
- package/dist/index.d.ts +36 -4
- package/dist/index.js +43 -2
- package/dist/js-scroller.svelte.d.ts +35 -0
- package/dist/js-scroller.svelte.js +154 -0
- package/dist/list-option.d.ts +46 -0
- package/dist/list-option.js +53 -0
- package/dist/menus.js +25 -11
- package/dist/pivot-view.svelte.d.ts +72 -0
- package/dist/pivot-view.svelte.js +13 -0
- package/dist/positioning.d.ts +111 -0
- package/dist/positioning.js +191 -0
- package/dist/scheduler-model.d.ts +3 -0
- package/dist/scheduler-model.js +22 -5
- package/dist/svgrid-wrapper.types.d.ts +18 -0
- package/dist/toast-store.svelte.d.ts +54 -0
- package/dist/toast-store.svelte.js +65 -15
- package/package.json +9 -1
- package/src/GridFooter.svelte +12 -11
- package/src/SvAnchor.svelte +65 -0
- package/src/SvAspectRatio.svelte +38 -0
- package/src/SvAutoComplete.svelte +52 -7
- package/src/SvBlockquote.svelte +43 -0
- package/src/SvCalendar.svelte +33 -2
- package/src/SvCalendar.test.ts +15 -0
- package/src/SvCheckBox.svelte +6 -2
- package/src/SvCode.svelte +52 -0
- package/src/SvCollapsible.svelte +75 -0
- package/src/SvColorInput.svelte +11 -17
- package/src/SvComboBox.svelte +85 -8
- package/src/SvCountryInput.svelte +2 -2
- package/src/SvDropDownList.svelte +154 -51
- package/src/SvDurationInput.svelte +59 -41
- package/src/SvField.svelte +203 -12
- package/src/SvForm.svelte +195 -21
- package/src/SvForm.test.ts +112 -0
- package/src/SvGrid.controller.svelte.ts +88 -7
- package/src/SvGrid.svelte +383 -181
- package/src/SvGrid.types.ts +125 -1
- package/src/SvGridChartView.svelte +70 -0
- package/src/SvGridDropdown.svelte +9 -2
- package/src/SvGridSelect.svelte +5 -2
- package/src/SvGroup.svelte +41 -0
- package/src/SvHoverCard.svelte +70 -0
- package/src/SvKbd.svelte +51 -0
- package/src/SvList.svelte +55 -0
- package/src/SvListBox.svelte +166 -77
- package/src/SvLoadingOverlay.svelte +53 -0
- package/src/SvMark.svelte +36 -0
- package/src/SvMaskedInput.svelte +50 -35
- package/src/SvMenuList.svelte +32 -3
- package/src/SvMenubar.svelte +200 -0
- package/src/SvMultiSelect.svelte +7 -4
- package/src/SvNumberInput.svelte +79 -42
- package/src/SvOtpInput.svelte +2 -2
- package/src/SvPasswordInput.svelte +51 -31
- package/src/SvPhoneInput.svelte +39 -28
- package/src/SvPopconfirm.svelte +79 -0
- package/src/SvPopover.svelte +87 -29
- package/src/SvRadioGroup.svelte +5 -1
- package/src/SvResult.svelte +73 -0
- package/src/SvSegmented.svelte +114 -0
- package/src/SvSimpleGrid.svelte +41 -0
- package/src/SvSlider.svelte +23 -10
- package/src/SvSpinner.svelte +43 -0
- package/src/SvStack.svelte +37 -0
- package/src/SvSwitchButton.svelte +6 -1
- package/src/SvTagsInput.svelte +9 -5
- package/src/SvText.svelte +76 -0
- package/src/SvTextInput.svelte +75 -43
- package/src/SvTimePicker.svelte +32 -2
- package/src/SvTitle.svelte +57 -0
- package/src/SvToaster.svelte +41 -6
- package/src/SvToaster.test.ts +32 -0
- package/src/SvToggleButton.svelte +4 -1
- package/src/SvTooltip.svelte +68 -34
- package/src/SvTree.svelte +81 -21
- package/src/SvTreeSelect.svelte +5 -2
- package/src/SvVisuallyHidden.svelte +49 -0
- package/src/ai.test.ts +502 -0
- package/src/ai.ts +1391 -0
- package/src/board-view.svelte.ts +33 -0
- package/src/build-api.coverage.test.ts +101 -0
- package/src/build-api.ts +43 -18
- package/src/builtin-editors.grid.test.ts +1 -1
- package/src/cell-formatting.ts +5 -5
- package/src/cell-render.ts +4 -4
- package/src/chart-view.svelte.ts +36 -0
- package/src/createCombobox.svelte.ts +17 -5
- package/src/createDropdownList.svelte.ts +8 -2
- package/src/createForm.svelte.ts +59 -6
- package/src/createMenu.svelte.ts +23 -0
- package/src/createPopoverSelect.svelte.ts +8 -1
- package/src/createSlider.svelte.ts +20 -0
- package/src/createTooltip.svelte.ts +67 -9
- package/src/editor-contract.ts +16 -0
- package/src/export-provider.ts +40 -0
- package/src/filter-operators.ts +37 -0
- package/src/form-field.ts +42 -2
- package/src/grid-messages.test.ts +24 -0
- package/src/grid-messages.ts +137 -0
- package/src/group-display.test.ts +77 -0
- package/src/group-display.ts +117 -0
- package/src/i18n.grid.test.ts +73 -0
- package/src/index.ts +91 -2
- package/src/js-scroller.svelte.ts +173 -0
- package/src/list-option.test.ts +56 -0
- package/src/list-option.ts +81 -0
- package/src/menus.test.ts +32 -0
- package/src/menus.ts +25 -12
- package/src/pivot-view.svelte.ts +90 -0
- package/src/pivot-view.test.ts +38 -0
- package/src/pivot.grid.test.ts +102 -0
- package/src/positioning.test.ts +141 -0
- package/src/positioning.ts +266 -0
- package/src/scheduler-model.test.ts +16 -0
- package/src/scheduler-model.ts +24 -5
- package/src/svgrid-wrapper.types.ts +23 -0
- package/src/svgrid.charting.test.ts +8 -1
- package/src/svgrid.comments-autocomplete.test.ts +7 -2
- package/src/svgrid.context-menu.test.ts +8 -3
- package/src/toast-store.svelte.ts +98 -0
- package/src/toast-store.test.ts +62 -1
- package/src/ui-breadth.test.ts +138 -0
- package/src/ui-buttons.test.ts +39 -0
- package/src/ui-inputs.test.ts +2 -2
- package/src/ui-range.test.ts +9 -0
- package/src/ui-selection.test.ts +36 -0
- package/src/ui-tier1.test.ts +1 -1
- package/src/virtual.test.ts +20 -6
- package/dist/SvGridBoard.svelte +0 -2339
- package/dist/SvGridBoard.svelte.d.ts +0 -31
- package/src/SvGridBoard.svelte +0 -2339
- package/src/board.test.ts +0 -927
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pro AI feature pack
|
|
3
|
+
* -------------------
|
|
4
|
+
*
|
|
5
|
+
* Three jobs every analyst wishes a data grid could do:
|
|
6
|
+
*
|
|
7
|
+
* 1. Natural-language filter / sort (`aiFilter`)
|
|
8
|
+
* "show me deals closing this quarter over $50k owned by Sasha"
|
|
9
|
+
* -> { filters: [...], sort: [...] }
|
|
10
|
+
*
|
|
11
|
+
* 2. Smart fill (`aiSmartFill`)
|
|
12
|
+
* User edits two cells in a column with example values; the
|
|
13
|
+
* Grid proposes the rest. Excel "Flash Fill" pattern.
|
|
14
|
+
*
|
|
15
|
+
* 3. Summarise rows (`aiSummarize`)
|
|
16
|
+
* Single row, the current selection, a group key, or the whole
|
|
17
|
+
* filtered view -> a one-paragraph summary.
|
|
18
|
+
*
|
|
19
|
+
* The grid stays headless / model-agnostic. The consumer supplies an
|
|
20
|
+
* `AIProvider` that knows how to call OpenAI / Anthropic / a local
|
|
21
|
+
* model / a server-side proxy. We never bundle a model client.
|
|
22
|
+
*
|
|
23
|
+
* Built-in + free: the AI helpers live in `@svgrid/grid`. They ship no model
|
|
24
|
+
* client and do nothing until you register a provider with `setAIProvider(...)`,
|
|
25
|
+
* so they add nothing to the base bundle unless you actually use them.
|
|
26
|
+
*/
|
|
27
|
+
import type { RowData, SvGridApi, TableFeatures } from './index';
|
|
28
|
+
type ExportFormat = 'xlsx' | 'xls' | 'pdf' | 'csv' | 'tsv' | 'html' | 'json' | 'xml' | 'md';
|
|
29
|
+
/**
|
|
30
|
+
* Shape every consumer-provided model adapter must implement. Keeping this
|
|
31
|
+
* tiny (one async call, two response formats) lets the same adapter drive
|
|
32
|
+
* OpenAI's `chat.completions`, Anthropic's `messages`, a self-hosted
|
|
33
|
+
* llama.cpp endpoint, or a server-side proxy. The grid only cares that the
|
|
34
|
+
* provider eventually returns a string we can parse.
|
|
35
|
+
*/
|
|
36
|
+
export type AIProvider = (request: AIRequest) => Promise<string>;
|
|
37
|
+
export type AIRequest = {
|
|
38
|
+
/** Full prompt the grid built for the model. Already includes column
|
|
39
|
+
* schema and any sampled rows where applicable. */
|
|
40
|
+
prompt: string;
|
|
41
|
+
/** When 'json', the provider should ask the model to return strict
|
|
42
|
+
* JSON only - no prose. We parse the response with JSON.parse and
|
|
43
|
+
* throw a typed error on failure. */
|
|
44
|
+
responseFormat?: 'text' | 'json';
|
|
45
|
+
/** Honored if the underlying transport supports cancellation. */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
/** Free-form tag for telemetry / logging. One of: 'filter',
|
|
48
|
+
* 'smart-fill', 'summarize', 'classify'. */
|
|
49
|
+
task: AITask;
|
|
50
|
+
/** Soft hint to the provider about how many tokens we expect back.
|
|
51
|
+
* Useful for routing small jobs to a cheaper model. */
|
|
52
|
+
maxOutputTokens?: number;
|
|
53
|
+
};
|
|
54
|
+
export type AITask = 'filter' | 'smart-fill' | 'summarize' | 'classify' | 'export' | 'anomaly' | 'chart';
|
|
55
|
+
/**
|
|
56
|
+
* Register the model adapter every AI call will route through. Call once
|
|
57
|
+
* at app boot. Passing `null` clears the provider and AI calls revert to
|
|
58
|
+
* throwing "no provider" errors.
|
|
59
|
+
*/
|
|
60
|
+
export declare function setAIProvider(p: AIProvider | null): void;
|
|
61
|
+
export declare function getAIProvider(): AIProvider | null;
|
|
62
|
+
export declare function hasAIProvider(): boolean;
|
|
63
|
+
export type AIFilterClause = {
|
|
64
|
+
field: string;
|
|
65
|
+
operator: 'contains' | 'equals' | 'startsWith' | 'greaterThan' | 'lessThan' | 'isBlank';
|
|
66
|
+
value?: string;
|
|
67
|
+
};
|
|
68
|
+
export type AISortClause = {
|
|
69
|
+
field: string;
|
|
70
|
+
desc: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type AIFilterResult = {
|
|
73
|
+
filters: AIFilterClause[];
|
|
74
|
+
sort: AISortClause[];
|
|
75
|
+
/** Plain-English explanation of how the model interpreted the query.
|
|
76
|
+
* Surface this in the UI so the user can confirm or undo. */
|
|
77
|
+
rationale: string;
|
|
78
|
+
};
|
|
79
|
+
export type AIFilterOptions = {
|
|
80
|
+
/**
|
|
81
|
+
* When true, the helper not only RETURNS the plan but also applies it
|
|
82
|
+
* to the grid via `api.setFilter` / `api.setSort`. Defaults to false
|
|
83
|
+
* so callers can show a preview before committing.
|
|
84
|
+
*/
|
|
85
|
+
apply?: boolean;
|
|
86
|
+
signal?: AbortSignal;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Translate a natural-language query into a filter+sort plan against
|
|
90
|
+
* the current grid's columns. The grid passes the column schema (names,
|
|
91
|
+
* types, sample values) to the model so it can pick the right field
|
|
92
|
+
* names without hallucinating.
|
|
93
|
+
*/
|
|
94
|
+
export declare function aiFilter<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, query: string, opts?: AIFilterOptions): Promise<AIFilterResult>;
|
|
95
|
+
export type AISmartFillExample = {
|
|
96
|
+
input: Record<string, unknown>;
|
|
97
|
+
output: unknown;
|
|
98
|
+
};
|
|
99
|
+
export type AISmartFillResult<TValue = unknown> = {
|
|
100
|
+
field: string;
|
|
101
|
+
predictions: Array<{
|
|
102
|
+
rowIndex: number;
|
|
103
|
+
value: TValue;
|
|
104
|
+
confidence: number;
|
|
105
|
+
}>;
|
|
106
|
+
rationale: string;
|
|
107
|
+
};
|
|
108
|
+
export type AISmartFillOptions = {
|
|
109
|
+
/** Target column - the one whose values we want filled. */
|
|
110
|
+
field: string;
|
|
111
|
+
/** Index of rows the model should propose values for. If omitted, every
|
|
112
|
+
* row whose current `field` value is `null`, `undefined` or `''` is
|
|
113
|
+
* selected automatically. */
|
|
114
|
+
targetRowIndices?: number[];
|
|
115
|
+
/**
|
|
116
|
+
* Worked examples the user has already filled in. Required - the
|
|
117
|
+
* model needs at least one to know the pattern, two or more to lock
|
|
118
|
+
* the schema. We don't pull these from the grid automatically because
|
|
119
|
+
* "edited" vs "untouched" isn't a state SvGrid exposes today.
|
|
120
|
+
*/
|
|
121
|
+
examples: AISmartFillExample[];
|
|
122
|
+
signal?: AbortSignal;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Given a column and a few user-provided examples, propose values for the
|
|
126
|
+
* untouched rows. Returns predictions only - the caller chooses whether to
|
|
127
|
+
* commit them via `api.setCellValue`. This is the right shape for an
|
|
128
|
+
* accept-per-cell UX with confidence-coloured highlights.
|
|
129
|
+
*/
|
|
130
|
+
export declare function aiSmartFill<TFeatures extends TableFeatures, TData extends RowData, TValue = unknown>(api: SvGridApi<TFeatures, TData>, opts: AISmartFillOptions): Promise<AISmartFillResult<TValue>>;
|
|
131
|
+
export type AISummarizeTarget = {
|
|
132
|
+
kind: 'row';
|
|
133
|
+
rowIndex: number;
|
|
134
|
+
} | {
|
|
135
|
+
kind: 'all';
|
|
136
|
+
} | {
|
|
137
|
+
kind: 'selection';
|
|
138
|
+
rowIndices: number[];
|
|
139
|
+
} | {
|
|
140
|
+
kind: 'group';
|
|
141
|
+
field: string;
|
|
142
|
+
value: unknown;
|
|
143
|
+
};
|
|
144
|
+
export type AISummary = {
|
|
145
|
+
text: string;
|
|
146
|
+
bullets: string[];
|
|
147
|
+
/** Field names the model thinks are the most load-bearing for the
|
|
148
|
+
* story it just told. UI can highlight those columns. */
|
|
149
|
+
highlightedFields: string[];
|
|
150
|
+
};
|
|
151
|
+
export type AISummarizeOptions = {
|
|
152
|
+
target: AISummarizeTarget;
|
|
153
|
+
/** Optional question the user is trying to answer. Helps the model
|
|
154
|
+
* bias the summary toward the relevant columns. */
|
|
155
|
+
question?: string;
|
|
156
|
+
signal?: AbortSignal;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Ask the model to summarise a slice of the grid. Caps the row sample at
|
|
160
|
+
* a model-friendly size; for huge selections it samples uniformly so the
|
|
161
|
+
* summary stays representative without blowing the context window.
|
|
162
|
+
*/
|
|
163
|
+
export declare function aiSummarize<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, opts: AISummarizeOptions): Promise<AISummary>;
|
|
164
|
+
export type AIClassifyOptions = {
|
|
165
|
+
/** Column whose free-text we're classifying. */
|
|
166
|
+
inputField: string;
|
|
167
|
+
/** Target column the model should write to. */
|
|
168
|
+
outputField: string;
|
|
169
|
+
/** Allowed values. The model is constrained to pick one. */
|
|
170
|
+
classes: string[];
|
|
171
|
+
/** Optional one-line description of each class (acts as a labeling rubric). */
|
|
172
|
+
classDescriptions?: Record<string, string>;
|
|
173
|
+
/** Rows to classify. Defaults to all. */
|
|
174
|
+
targetRowIndices?: number[];
|
|
175
|
+
signal?: AbortSignal;
|
|
176
|
+
};
|
|
177
|
+
export type AIClassifyResult = {
|
|
178
|
+
inputField: string;
|
|
179
|
+
outputField: string;
|
|
180
|
+
predictions: Array<{
|
|
181
|
+
rowIndex: number;
|
|
182
|
+
value: string;
|
|
183
|
+
confidence: number;
|
|
184
|
+
}>;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Bucket free-text cells into one of a known set of classes. The model
|
|
188
|
+
* is constrained to pick from `opts.classes`; predictions outside the set
|
|
189
|
+
* are dropped so the caller can rely on the output being clean enum
|
|
190
|
+
* values it can write straight back into the grid.
|
|
191
|
+
*/
|
|
192
|
+
export declare function aiClassify<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, opts: AIClassifyOptions): Promise<AIClassifyResult>;
|
|
193
|
+
export type AIExportPlan = {
|
|
194
|
+
format: ExportFormat;
|
|
195
|
+
filters: AIFilterClause[];
|
|
196
|
+
sort: AISortClause[];
|
|
197
|
+
groupBy: string[];
|
|
198
|
+
/** Plain-English explanation of how the model read the request. */
|
|
199
|
+
rationale: string;
|
|
200
|
+
};
|
|
201
|
+
export type AIExportOptions = {
|
|
202
|
+
/**
|
|
203
|
+
* Also apply the filter / sort / grouping to the grid (mutating the view) so
|
|
204
|
+
* it mirrors the export. Default FALSE - the export is self-contained (it
|
|
205
|
+
* computes its own rows), so the grid is left untouched unless you opt in.
|
|
206
|
+
*/
|
|
207
|
+
apply?: boolean;
|
|
208
|
+
/** Actually download the file. Default true; set false to preview the plan. */
|
|
209
|
+
run?: boolean;
|
|
210
|
+
/** Base filename (no extension). Default 'export'. */
|
|
211
|
+
filename?: string;
|
|
212
|
+
signal?: AbortSignal;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Turn a natural-language request ("export EU orders from Q2 as a grouped PDF")
|
|
216
|
+
* into an export: the model returns a `{ format, filters, sort, groupBy }` plan
|
|
217
|
+
* against the grid's columns; we apply the filter/sort to the grid and hand the
|
|
218
|
+
* result to the registered export engine (@svgrid/enterprise). Returns the plan
|
|
219
|
+
* so the UI can show what it did (or preview it first with `run: false`).
|
|
220
|
+
*/
|
|
221
|
+
export declare function aiExport<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, query: string, opts?: AIExportOptions): Promise<AIExportPlan>;
|
|
222
|
+
export type AIAnomaly = {
|
|
223
|
+
/** Index into the SCANNED rows (target order), when the model pins one row. */
|
|
224
|
+
rowIndex?: number;
|
|
225
|
+
field?: string;
|
|
226
|
+
value?: unknown;
|
|
227
|
+
reason: string;
|
|
228
|
+
severity: 'low' | 'medium' | 'high';
|
|
229
|
+
};
|
|
230
|
+
export type AIAnomalyResult = {
|
|
231
|
+
anomalies: AIAnomaly[];
|
|
232
|
+
summary: string;
|
|
233
|
+
};
|
|
234
|
+
export type AIAnomalyOptions = {
|
|
235
|
+
/** Which rows to scan. Defaults to the whole dataset. */
|
|
236
|
+
target?: AISummarizeTarget;
|
|
237
|
+
/** Optional focus, e.g. "look at pricing and margins". */
|
|
238
|
+
question?: string;
|
|
239
|
+
signal?: AbortSignal;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Scan a slice of the grid (all / selection / group) for anomalies - outliers,
|
|
243
|
+
* suspicious values, inconsistencies - and return a structured list plus a
|
|
244
|
+
* one-line summary. Pairs naturally with an export: "find the odd ones, then
|
|
245
|
+
* export just those".
|
|
246
|
+
*/
|
|
247
|
+
export declare function aiFindAnomalies<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, opts?: AIAnomalyOptions): Promise<AIAnomalyResult>;
|
|
248
|
+
export type AIChartType = 'bar' | 'line' | 'area' | 'pie';
|
|
249
|
+
export type AIChartPlan = {
|
|
250
|
+
type: AIChartType;
|
|
251
|
+
/** Group-by (category-axis) column field, or null. */
|
|
252
|
+
dimension: string | null;
|
|
253
|
+
/** Split-by column field: one series per distinct value, or null. */
|
|
254
|
+
series: string | null;
|
|
255
|
+
/** Measure (value-axis) column field, or null. */
|
|
256
|
+
measure: string | null;
|
|
257
|
+
reduce: 'sum' | 'avg' | 'count';
|
|
258
|
+
stacked: boolean;
|
|
259
|
+
logScale: boolean;
|
|
260
|
+
timeAxis: boolean;
|
|
261
|
+
valueFormat: 'number' | 'currency' | 'percent';
|
|
262
|
+
rationale: string;
|
|
263
|
+
};
|
|
264
|
+
export type AIChartOptions = {
|
|
265
|
+
/** Apply the plan to the grid's chart panel (open + configure). Default false. */
|
|
266
|
+
apply?: boolean;
|
|
267
|
+
signal?: AbortSignal;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Translate a natural-language request into a chart plan for the grid's built-in
|
|
271
|
+
* `charting` panel. Validates every field against the real schema, then (with
|
|
272
|
+
* `apply: true`) pushes it into the panel through `api.configureChart`.
|
|
273
|
+
*/
|
|
274
|
+
export declare function aiChart<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>, query: string, opts?: AIChartOptions): Promise<AIChartPlan>;
|
|
275
|
+
/**
|
|
276
|
+
* Wire the grid's chart-panel AI button to the model: registers a handler (via
|
|
277
|
+
* `api.setChartAiHandler`) that runs `aiChart` and returns the plan for the
|
|
278
|
+
* panel to apply + explain. Call once after `onApiReady`. `installEnterprise`
|
|
279
|
+
* calls this for you.
|
|
280
|
+
*/
|
|
281
|
+
export declare function enableAiCharting<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>): void;
|
|
282
|
+
export declare function disableAiCharting<TFeatures extends TableFeatures, TData extends RowData>(api: SvGridApi<TFeatures, TData>): void;
|
|
283
|
+
/**
|
|
284
|
+
* A deterministic provider that returns canned, schema-shaped responses
|
|
285
|
+
* for each task. Wire it in via `setAIProvider(mockAIProvider)` to make
|
|
286
|
+
* the AI demo work end-to-end without a real model key. Not for production.
|
|
287
|
+
*/
|
|
288
|
+
export declare const mockAIProvider: AIProvider;
|
|
289
|
+
export {};
|