Skip to content

Commit a2244af

Browse files
committed
fix: move api to internal
1 parent 75bbee7 commit a2244af

File tree

11 files changed

+30
-328
lines changed

11 files changed

+30
-328
lines changed

src/components/ComponentsProvider/chatPlaceholderTypes.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type React from 'react';
22

3-
import type {ChatConfig, ChatContext} from '../../types/chat';
4-
53
// Placeholder types for chat components
64
// These will be properly typed when implemented in external packages
75

@@ -10,9 +8,9 @@ export interface AIAssistantButtonProps {
108
}
119

1210
export interface ChatPanelProps {
13-
config?: ChatConfig;
14-
context?: ChatContext;
15-
formatContext?: (context: ChatContext) => string;
11+
config?: any; // Will be properly typed in the implementation
12+
context?: any; // Will be properly typed in the implementation
13+
formatContext?: (context: any) => string;
1614
}
1715

1816
// Placeholder components that do nothing

src/containers/Heatmap/Heatmap.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export const Heatmap = ({path, database}: HeatmapProps) => {
8888
const {min, max} = getCurrentMetricLimits(currentMetric, tablets);
8989

9090
const preparedTablets = tablets.map((tablet) => {
91-
const value = currentMetric && Number(tablet.metrics?.[currentMetric]);
91+
const value =
92+
currentMetric &&
93+
Number(tablet.metrics?.[currentMetric as keyof typeof tablet.metrics]);
9294
const colorIndex = getColorIndex(value, min, max);
9395
const color = COLORS_RANGE[colorIndex];
9496

src/lib.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,5 @@ export type {GetMonitoringLink, GetMonitoringClusterLink} from './utils/monitori
3737

3838
export {configureUIFactory} from './uiFactory/uiFactory';
3939

40-
// Export chat types
41-
export type {
42-
ChatMessage,
43-
ChatState,
44-
ChatDelta,
45-
ChatRequest,
46-
ChatConfig,
47-
ChatContext,
48-
ChatCustomAction,
49-
QuotaInfo,
50-
ToolCall,
51-
UsageBreakdown,
52-
} from './types/chat';
53-
5440
// Re-export chat component types from ComponentsProvider
5541
export type {AIAssistantButtonProps, ChatPanelProps} from './components/ComponentsProvider';
56-
57-
// Export placeholder chat reducer and actions
58-
// These can be overridden by external implementations
59-
export {chatReducer, chatActions} from './store/reducers/chat/chatPlaceholder';

src/services/api/aiAssist.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/services/api/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type {AxiosRequestConfig} from 'axios';
22

33
import {codeAssistBackend} from '../../store';
4-
import {aiAssistBackend} from '../../store/configureStore';
54

6-
import {AIAssistAPI} from './aiAssist';
75
import {AuthAPI} from './auth';
86
import {CodeAssistAPI} from './codeAssist';
97
import {MetaAPI} from './meta';
@@ -28,7 +26,6 @@ export class YdbEmbeddedAPI {
2826
viewer: ViewerAPI;
2927
meta?: MetaAPI;
3028
codeAssist?: CodeAssistAPI;
31-
aiAssist?: AIAssistAPI;
3229

3330
constructor({webVersion = false, withCredentials = false} = {}) {
3431
const config: AxiosRequestConfig = {withCredentials};
@@ -42,10 +39,6 @@ export class YdbEmbeddedAPI {
4239
this.codeAssist = new CodeAssistAPI({config});
4340
}
4441

45-
if (aiAssistBackend) {
46-
this.aiAssist = new AIAssistAPI({config});
47-
}
48-
4942
this.operation = new OperationAPI({config});
5043
this.pdisk = new PDiskAPI({config});
5144
this.scheme = new SchemeAPI({config});

src/store/configureStore.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {configureStore as configureReduxStore} from '@reduxjs/toolkit';
1+
import {combineReducers, configureStore as configureReduxStore} from '@reduxjs/toolkit';
22
import type {Action, Dispatch, Middleware, Reducer, UnknownAction} from '@reduxjs/toolkit';
33
import type {History} from 'history';
44
import {createBrowserHistory} from 'history';
@@ -7,7 +7,7 @@ import {listenForHistoryChange} from 'redux-location-state';
77
import {YdbEmbeddedAPI} from '../services/api';
88

99
import {getUrlData} from './getUrlData';
10-
import rootReducer from './reducers';
10+
import combinedRootReducer, {rootReducer} from './reducers';
1111
import {api as storeApi} from './reducers/api';
1212
import {syncUserSettingsFromLS} from './reducers/settings/settings';
1313
import {UPDATE_REF} from './reducers/tooltip';
@@ -51,19 +51,18 @@ export const webVersion = window.web_version;
5151
export const customBackend = window.custom_backend;
5252
export const metaBackend = window.meta_backend;
5353
export const codeAssistBackend = window.code_assist_backend;
54-
export const aiAssistBackend = window.ai_assist_backend;
5554

5655
const isSingleClusterMode = `${metaBackend}` === 'undefined';
5756

5857
export interface ConfigureStoreOptions {
59-
aRootReducer?: typeof rootReducer;
58+
aRootReducer?: Reducer;
6059
singleClusterMode?: boolean;
6160
api?: YdbEmbeddedAPI;
6261
additionalReducers?: Record<string, Reducer>;
6362
}
6463

6564
export function configureStore({
66-
aRootReducer = rootReducer,
65+
aRootReducer,
6766
singleClusterMode = isSingleClusterMode,
6867
api = new YdbEmbeddedAPI({webVersion, withCredentials: !customBackend}),
6968
additionalReducers = {},
@@ -74,21 +73,26 @@ export function configureStore({
7473
}));
7574
const history = createBrowserHistory({basename});
7675

77-
// Merge root reducer with additional reducers
78-
const mergedReducer =
79-
Object.keys(additionalReducers).length > 0
80-
? {
81-
...aRootReducer,
82-
...additionalReducers,
83-
}
84-
: aRootReducer;
85-
86-
const store = _configureStore(
87-
mergedReducer as typeof rootReducer,
88-
history,
89-
{singleClusterMode},
90-
[storeApi.middleware],
91-
);
76+
// Create the final reducer
77+
let finalReducer: Reducer;
78+
79+
if (aRootReducer) {
80+
// If custom root reducer is provided, use it
81+
finalReducer = aRootReducer;
82+
} else if (Object.keys(additionalReducers).length > 0) {
83+
// If additional reducers are provided, combine them with the default ones
84+
finalReducer = combineReducers({
85+
...rootReducer,
86+
...additionalReducers,
87+
});
88+
} else {
89+
// Otherwise use the default combined reducer
90+
finalReducer = combinedRootReducer;
91+
}
92+
93+
const store = _configureStore(finalReducer, history, {singleClusterMode}, [
94+
storeApi.middleware,
95+
]);
9296
listenForHistoryChange(store, history);
9397

9498
window.api = api;

src/store/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export {
55
configureStore,
66
customBackend,
77
metaBackend,
8-
aiAssistBackend,
98
codeAssistBackend,
109
webVersion,
1110
} from './configureStore';

src/store/reducers/chat/chatPlaceholder.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/store/reducers/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {combineReducers} from '@reduxjs/toolkit';
22

33
import {api} from './api';
44
import authentication from './authentication/authentication';
5-
import {chatReducer} from './chat/chatPlaceholder';
65
import cluster from './cluster/cluster';
76
import clusters from './clusters/clusters';
87
import executeTopQueries from './executeTopQueries/executeTopQueries';
@@ -39,7 +38,6 @@ export const rootReducer = {
3938
queryActions,
4039
fullscreen,
4140
clusters,
42-
chat: chatReducer,
4341
};
4442

4543
const combinedReducer = combineReducers({

0 commit comments

Comments
 (0)