Skip to content

Commit 57ff4a5

Browse files
committed
GridCore: add public types for AIAssistant
1 parent ea5abe2 commit 57ff4a5

7 files changed

Lines changed: 143 additions & 66 deletions

File tree

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/__tests__/ai_assistant_view_controller.integration.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,14 @@ import {
66
it,
77
jest,
88
} from '@jest/globals';
9-
import type { Properties as DataGridProperties } from '@js/ui/data_grid';
109

1110
import {
1211
afterTest,
1312
beforeTest,
14-
createDataGrid as commonCreateDataGrid,
13+
createDataGrid,
1514
type DataGridInstance,
1615
} from '../../__tests__/__mock__/helpers/utils';
1716

18-
// TODO remove when types added to public dts
19-
interface AIAssistantDataGridProperties extends DataGridProperties {
20-
aiAssistant?: {
21-
enabled?: boolean;
22-
title?: string;
23-
};
24-
}
25-
26-
// TODO remove when types added to public dts
27-
const createDataGrid = (
28-
options: AIAssistantDataGridProperties = {},
29-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
30-
): ReturnType<typeof commonCreateDataGrid> => commonCreateDataGrid(options as any);
31-
3217
const AI_ASSISTANT_BUTTON_SELECTOR = '.dx-datagrid-ai-assistant-button';
3318
const HIDDEN_CLASS = 'dx-hidden';
3419

packages/devextreme/js/__internal/grids/grid_core/m_types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import type { GridBase, GridBaseOptions, SelectionBase } from '@js/common/grids'
44
import type { Component } from '@js/core/component';
55
import type { PropertyType } from '@js/core/index';
66
import type { dxElementWrapper } from '@js/core/renderer';
7-
import type { Properties as ChatOptions } from '@js/ui/chat';
87
import type { Properties as DataGridOptions } from '@js/ui/data_grid';
9-
import type { Properties as PopupOptions } from '@js/ui/popup';
108
import type { Properties as TreeListdOptions } from '@js/ui/tree_list';
119
import type Widget from '@js/ui/widget/ui.widget';
1210

@@ -129,14 +127,6 @@ export interface InternalGridOptions extends GridBaseOptions<InternalGrid, unkno
129127
loadItemsOnExportingSelectedItems?: boolean | undefined;
130128

131129
selection?: InternalSelection;
132-
133-
// TODO move to public d.ts
134-
aiAssistant?: {
135-
enabled?: boolean;
136-
title?: string;
137-
popup?: PopupOptions;
138-
chat?: ChatOptions;
139-
};
140130
}
141131

142132
// todo: move to upper .d.ts files

packages/devextreme/js/common/grids.d.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ import {
6161

6262
import { LoadPanelIndicatorProperties } from '../ui/load_panel';
6363

64+
import {
65+
Properties as ChatProperties,
66+
} from '../ui/chat';
6467
import {
6568
Properties as PopupProperties,
6669
} from '../ui/popup';
@@ -79,6 +82,59 @@ import { PositionConfig } from './core/animation';
7982
import { PagerBase } from '../ui/pagination';
8083
import { AIIntegration } from './ai-integration';
8184

85+
/**
86+
* @docid
87+
* @public
88+
* @namespace DevExpress.common.grids
89+
*/
90+
export type AIAssistant = {
91+
/**
92+
* @docid
93+
* @public
94+
*/
95+
aiIntegration?: AIIntegration;
96+
/**
97+
* @docid
98+
* @public
99+
* @type dxChatOptions
100+
*/
101+
chat?: ChatProperties;
102+
/**
103+
* @docid
104+
* @default false
105+
*/
106+
enabled?: boolean;
107+
/**
108+
* @docid
109+
* @public
110+
* @type dxPopupOptions
111+
*/
112+
popup?: PopupProperties;
113+
/**
114+
* @docid
115+
* @default 'AI Assistant'
116+
*/
117+
title?: string;
118+
};
119+
120+
/**
121+
* @docid
122+
* @hidden
123+
* @namespace DevExpress.common.grids
124+
*/
125+
export type AIAssistantRequestCreatingInfo = {
126+
/**
127+
* @docid
128+
* @type object
129+
*/
130+
context: Record<string, any>;
131+
/**
132+
* @docid
133+
* @type object
134+
*/
135+
responseSchema: Record<string, any>;
136+
};
137+
82138
/**
83139
* @docid
84140
* @hidden
@@ -1940,6 +1996,11 @@ interface GridBaseOptionsBlank<TComponent extends GridBase<TRowData, TKey>, TRow
19401996
* @type object
19411997
*/
19421998
export type GridBaseOptions<TComponent extends GridBase<TRowData, TKey>, TRowData = any, TKey = any> = Omit<GridBaseOptionsBlank<TComponent, TRowData, TKey>, 'focusStateEnabled'> & {
1999+
/**
2000+
* @docid
2001+
* @public
2002+
*/
2003+
aiAssistant?: AIAssistant;
19432004
/**
19442005
* @docid
19452006
* @default undefined
@@ -2145,6 +2206,15 @@ export type GridBaseOptions<TComponent extends GridBase<TRowData, TKey>, TRowDat
21452206
* @public
21462207
*/
21472208
noDataText?: string;
2209+
/**
2210+
* @docid
2211+
* @default null
2212+
* @type_function_param1 e:object
2213+
* @type_function_param1_field component:this
2214+
* @action
2215+
* @public
2216+
*/
2217+
onAIAssistantRequestCreating?: ((e: EventInfo<TComponent> & Cancelable & AIAssistantRequestCreatingInfo) => void);
21482218
/**
21492219
* @docid
21502220
* @default null

packages/devextreme/js/ui/data_grid.d.ts

Lines changed: 55 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,47 @@ import {
4141
} from '../localization';
4242

4343
import {
44-
AdaptiveDetailRowPreparingInfo,
45-
ColumnBase as ComponentColumnBase,
46-
ColumnButtonBase as ComponentColumnButtonBase,
47-
GridsContextMenuTarget,
48-
EditingBase as ComponentEditingBase,
49-
EditingTextsBase as ComponentEditingTextsBase,
50-
DataChangeInfo,
51-
DataErrorOccurredInfo,
52-
DragDropInfo,
53-
DragReorderInfo,
54-
DragStartEventInfo,
55-
FilterPanel as ComponentFilterPanel,
56-
FilterPanelCustomizeTextArg as ComponentFilterPanelCustomizeTextArg,
57-
GridBase,
58-
GridBaseOptions,
59-
GroupExpandMode,
60-
KeyDownInfo,
61-
NewRowInfo,
62-
NewRowPosition,
63-
PagingBase as ComponentPaging,
64-
ReducedNativeEventInfo,
65-
RowDragging as ComponentRowDragging,
66-
RowDraggingEventInfo,
67-
RowDraggingTemplateData,
68-
RowInsertedInfo,
69-
RowInsertingInfo,
70-
RowKeyInfo,
71-
RowRemovedInfo,
72-
RowRemovingInfo,
73-
RowUpdatedInfo,
74-
RowUpdatingInfo,
75-
RowValidatingInfo,
76-
SavingInfo,
77-
ScrollingBase as ComponentScrollingBase,
78-
SelectionBase as ComponentSelectionBase,
79-
SelectionChangedInfo,
80-
SelectionColumnDisplayMode,
81-
SummaryType,
82-
ToolbarPreparingInfo,
83-
AIColumnRequestCreatingInfo,
44+
AdaptiveDetailRowPreparingInfo,
45+
ColumnBase as ComponentColumnBase,
46+
ColumnButtonBase as ComponentColumnButtonBase,
47+
GridsContextMenuTarget,
48+
EditingBase as ComponentEditingBase,
49+
EditingTextsBase as ComponentEditingTextsBase,
50+
DataChangeInfo,
51+
DataErrorOccurredInfo,
52+
DragDropInfo,
53+
DragReorderInfo,
54+
DragStartEventInfo,
55+
FilterPanel as ComponentFilterPanel,
56+
FilterPanelCustomizeTextArg as ComponentFilterPanelCustomizeTextArg,
57+
GridBase,
58+
GridBaseOptions,
59+
GroupExpandMode,
60+
KeyDownInfo,
61+
NewRowInfo,
62+
NewRowPosition,
63+
PagingBase as ComponentPaging,
64+
ReducedNativeEventInfo,
65+
RowDragging as ComponentRowDragging,
66+
RowDraggingEventInfo,
67+
RowDraggingTemplateData,
68+
RowInsertedInfo,
69+
RowInsertingInfo,
70+
RowKeyInfo,
71+
RowRemovedInfo,
72+
RowRemovingInfo,
73+
RowUpdatedInfo,
74+
RowUpdatingInfo,
75+
RowValidatingInfo,
76+
SavingInfo,
77+
ScrollingBase as ComponentScrollingBase,
78+
SelectionBase as ComponentSelectionBase,
79+
SelectionChangedInfo,
80+
SelectionColumnDisplayMode,
81+
SummaryType,
82+
ToolbarPreparingInfo,
83+
AIColumnRequestCreatingInfo,
84+
AIAssistantRequestCreatingInfo,
8485
} from '../common/grids';
8586

8687
export {
@@ -258,6 +259,14 @@ export type GridBaseColumn<TRowData = any> = ColumnBase<TRowData>;
258259
*/
259260
export type GridBaseColumnButton = ColumnButtonBase;
260261

262+
/**
263+
* @docid _ui_data_grid_AIAssistantRequestCreatingEvent
264+
* @public
265+
* @type object
266+
* @inherits EventInfo,Cancelable,AIAssistantRequestCreatingInfo
267+
*/
268+
export type AIAssistantRequestCreatingEvent<TRowData = any, TKey = any> = EventInfo<dxDataGrid<TRowData, TKey>> & Cancelable & AIAssistantRequestCreatingInfo;
269+
261270
/**
262271
* @docid _ui_data_grid_AdaptiveDetailRowPreparingEvent
263272
* @public
@@ -2446,6 +2455,7 @@ export type Row<TRowData = any, TKey = any> = {
24462455

24472456
/** @public */
24482457
export type ExplicitTypes<TRowData, TKey> = {
2458+
AIAssistantRequestCreatingEvent: AIAssistantRequestCreatingEvent<TRowData, TKey>;
24492459
AdaptiveDetailRowPreparingEvent: AdaptiveDetailRowPreparingEvent<TRowData, TKey>;
24502460
CellClickEvent: CellClickEvent<TRowData, TKey>;
24512461
CellDblClickEvent: CellDblClickEvent<TRowData, TKey>;
@@ -2546,6 +2556,11 @@ type EventsIntegrityCheckingHelper = CheckedEvents<FilterOutHidden<Properties>,
25462556
* @hidden
25472557
*/
25482558
type Events = {
2559+
/**
2560+
* @docid dxDataGridOptions.onAIAssistantRequestCreating
2561+
* @type_function_param1 e:{ui/data_grid:AIAssistantRequestCreatingEvent}
2562+
*/
2563+
onAIAssistantRequestCreating?: ((e: AIAssistantRequestCreatingEvent) => void);
25492564
/**
25502565
* @docid dxDataGridOptions.onAdaptiveDetailRowPreparing
25512566
* @type_function_param1 e:{ui/data_grid:AdaptiveDetailRowPreparingEvent}

packages/devextreme/js/ui/data_grid_types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export {
112112
RowDraggingReorderEvent,
113113
ColumnButtonClickEvent,
114114
AIColumnRequestCreatingEvent,
115+
AIAssistantRequestCreatingEvent,
115116
ColumnButtonTemplateData,
116117
ColumnCellTemplateData,
117118
ColumnEditCellTemplateData,

packages/devextreme/js/ui/tree_list.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import {
6262
SelectionChangedInfo,
6363
ToolbarPreparingInfo,
6464
AIColumnRequestCreatingInfo,
65+
AIAssistantRequestCreatingInfo,
6566
} from '../common/grids';
6667

6768
import { dxToolbarItem } from './toolbar';
@@ -181,6 +182,14 @@ export type TreeListFilterMode = 'fullBranch' | 'withAncestors' | 'matchOnly';
181182
/** @public */
182183
export type Scrollable = Omit<dxScrollable, '_templateManager' | '_cancelOptionChange' | '_getTemplate' | '_invalidate' | '_refresh' | '_notifyOptionChanged' | '_createElement'>;
183184

185+
/**
186+
* @docid _ui_tree_list_AIAssistantRequestCreatingEvent
187+
* @public
188+
* @type object
189+
* @inherits EventInfo,Cancelable,AIAssistantRequestCreatingInfo
190+
*/
191+
export type AIAssistantRequestCreatingEvent<TRowData = any, TKey = any> = EventInfo<dxTreeList<TRowData, TKey>> & Cancelable & AIAssistantRequestCreatingInfo;
192+
184193
/**
185194
* @docid _ui_tree_list_AdaptiveDetailRowPreparingEvent
186195
* @public
@@ -1799,6 +1808,7 @@ export type Row<TRowData = any, TKey = any> = {
17991808

18001809
/** @public */
18011810
export type ExplicitTypes<TRowData, TKey> = {
1811+
AIAssistantRequestCreatingEvent: AIAssistantRequestCreatingEvent<TRowData, TKey>;
18021812
AdaptiveDetailRowPreparingEvent: AdaptiveDetailRowPreparingEvent<TRowData, TKey>;
18031813
CellClickEvent: CellClickEvent<TRowData, TKey>;
18041814
CellDblClickEvent: CellDblClickEvent<TRowData, TKey>;
@@ -1876,6 +1886,11 @@ type EventsIntegrityCheckingHelper = CheckedEvents<FilterOutHidden<Properties>,
18761886
*/
18771887
type Events = {
18781888
/**
1889+
* @docid dxTreeListOptions.onAIAssistantRequestCreating
1890+
* @type_function_param1 e:{ui/tree_list:AIAssistantRequestCreatingEvent}
1891+
*/
1892+
onAIAssistantRequestCreating?: ((e: AIAssistantRequestCreatingEvent) => void);
1893+
/**
18791894
* @docid dxTreeListOptions.onAdaptiveDetailRowPreparing
18801895
* @type_function_param1 e:{ui/tree_list:AdaptiveDetailRowPreparingEvent}
18811896
*/

packages/devextreme/js/ui/tree_list_types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export {
106106
RowDraggingReorderEvent,
107107
ColumnButtonClickEvent,
108108
AIColumnRequestCreatingEvent,
109+
AIAssistantRequestCreatingEvent,
109110
ColumnButtonTemplateData,
110111
ColumnCellTemplateData,
111112
ColumnEditCellTemplateData,

0 commit comments

Comments
 (0)