@@ -8,56 +8,52 @@ import type {EPathType} from '../../types/api/schema';
88import { isQueryErrorResponse } from '../../utils/query' ;
99
1010import { api } from './api' ;
11- import { createViewSchemaQuery } from './viewSchema/viewSchema' ;
11+ import { overviewApi } from './overview/overview' ;
12+ import { viewSchemaApi } from './viewSchema/viewSchema' ;
1213
1314export interface GetTableSchemaDataParams {
1415 path : string ;
1516 tenantName : string ;
1617 type : EPathType ;
1718}
1819
19- const tableSchemaDataConcurrentId = 'getTableSchemaData' ;
20-
2120const TABLE_SCHEMA_TIMEOUT = 1000 ;
2221
22+ const getTableSchemaDataConcurrentId = 'getTableSchemaData' ;
23+
2324export const tableSchemeDataApi = api . injectEndpoints ( {
2425 endpoints : ( build ) => ( {
2526 getTableSchemaData : build . mutation < SchemaData [ ] , GetTableSchemaDataParams > ( {
26- queryFn : async ( { path, tenantName, type} , { signal } ) => {
27+ queryFn : async ( { path, tenantName, type} , { dispatch } ) => {
2728 try {
28- const schemaData = await window . api . getDescribe (
29- {
30- path,
29+ const schemaData = await dispatch (
30+ overviewApi . endpoints . getOverview . initiate ( {
31+ paths : [ path ] ,
3132 database : tenantName ,
3233 timeout : TABLE_SCHEMA_TIMEOUT ,
33- } ,
34- { signal , concurrentId : tableSchemaDataConcurrentId + 'describe' } ,
34+ concurrentId : getTableSchemaDataConcurrentId + 'getOverview' ,
35+ } ) ,
3536 ) ;
3637
3738 if ( isViewType ( type ) ) {
38- const response = await window . api . sendQuery (
39- {
40- query : createViewSchemaQuery ( path ) ,
39+ const response = await dispatch (
40+ viewSchemaApi . endpoints . getViewSchema . initiate ( {
4141 database : tenantName ,
42- action : 'execute-scan' ,
42+ path ,
4343 timeout : TABLE_SCHEMA_TIMEOUT ,
44- } ,
45- {
46- withRetries : true ,
47- concurrentId : tableSchemaDataConcurrentId + 'query' ,
48- } ,
44+ concurrentId : getTableSchemaDataConcurrentId + 'getViewSchema' ,
45+ } ) ,
4946 ) ;
5047
5148 if ( isQueryErrorResponse ( response ) ) {
5249 return { error : response } ;
5350 }
5451
55- const viewColumnsData = { data : response ?. result ?. [ 0 ] ?. columns || [ ] } ;
56- const result = prepareViewSchema ( viewColumnsData . data ) ;
52+ const result = prepareViewSchema ( response . data ) ;
5753 return { data : result } ;
5854 }
5955
60- const result = prepareSchemaData ( type , schemaData ) ;
56+ const result = prepareSchemaData ( type , schemaData . data ?. data ) ;
6157
6258 return { data : result } ;
6359 } catch ( error ) {
0 commit comments