ydb-embedded-ui 3.5.0 → 4.1.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/components/ClusterInfo/ClusterInfo.tsx +3 -3
  3. package/dist/{containers/Nodes/NodesTable.scss → components/NodeHostWrapper/NodeHostWrapper.scss} +4 -6
  4. package/dist/components/NodeHostWrapper/NodeHostWrapper.tsx +60 -0
  5. package/dist/containers/AsideNavigation/AsideNavigation.tsx +1 -11
  6. package/dist/containers/Header/Header.tsx +1 -1
  7. package/dist/containers/Nodes/getNodesColumns.tsx +7 -46
  8. package/dist/containers/Storage/StorageNodes/StorageNodes.scss +0 -24
  9. package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +2 -39
  10. package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.tsx +3 -3
  11. package/dist/containers/Tenant/QueryEditor/QueryDuration/QueryDuration.scss +8 -0
  12. package/dist/containers/Tenant/QueryEditor/QueryDuration/QueryDuration.tsx +21 -0
  13. package/dist/containers/Tenant/QueryEditor/QueryEditor.js +58 -83
  14. package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +0 -33
  15. package/dist/containers/Tenant/QueryEditor/QueryEditorControls/OldQueryEditorControls.tsx +83 -0
  16. package/dist/containers/Tenant/QueryEditor/QueryEditorControls/QueryEditorControls.scss +57 -0
  17. package/dist/containers/Tenant/QueryEditor/QueryEditorControls/QueryEditorControls.tsx +84 -0
  18. package/dist/containers/Tenant/QueryEditor/QueryEditorControls/shared.ts +23 -0
  19. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +12 -23
  20. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +4 -6
  21. package/dist/containers/Tenant/QueryEditor/i18n/en.json +3 -0
  22. package/dist/containers/Tenant/QueryEditor/i18n/index.ts +11 -0
  23. package/dist/containers/Tenant/QueryEditor/i18n/ru.json +3 -0
  24. package/dist/containers/Tenants/Tenants.js +1 -1
  25. package/dist/containers/UserSettings/UserSettings.tsx +30 -1
  26. package/dist/services/api.ts +383 -0
  27. package/dist/store/reducers/{cluster.js → cluster/cluster.ts} +9 -14
  28. package/dist/store/reducers/cluster/types.ts +13 -0
  29. package/dist/store/reducers/executeQuery.ts +12 -37
  30. package/dist/store/reducers/executeTopQueries.ts +2 -2
  31. package/dist/store/reducers/{explainQuery.js → explainQuery.ts} +44 -59
  32. package/dist/store/reducers/index.ts +5 -4
  33. package/dist/store/reducers/settings.js +19 -17
  34. package/dist/store/reducers/{tenants.js → tenants/tenants.ts} +14 -9
  35. package/dist/store/reducers/tenants/types.ts +17 -0
  36. package/dist/store/utils.ts +3 -2
  37. package/dist/types/api/acl.ts +25 -0
  38. package/dist/types/api/cluster.ts +3 -0
  39. package/dist/types/api/compute.ts +5 -3
  40. package/dist/types/api/error.ts +14 -0
  41. package/dist/types/api/netInfo.ts +48 -0
  42. package/dist/types/api/nodes.ts +5 -3
  43. package/dist/types/api/pdisk.ts +11 -2
  44. package/dist/types/api/query.ts +226 -117
  45. package/dist/types/api/storage.ts +5 -3
  46. package/dist/types/api/tenant.ts +18 -3
  47. package/dist/types/api/vdisk.ts +10 -2
  48. package/dist/types/api/whoami.ts +19 -0
  49. package/dist/types/store/executeQuery.ts +4 -8
  50. package/dist/types/store/explainQuery.ts +38 -0
  51. package/dist/types/store/query.ts +23 -3
  52. package/dist/types/window.d.ts +5 -0
  53. package/dist/utils/constants.ts +2 -1
  54. package/dist/utils/error.ts +25 -0
  55. package/dist/utils/hooks/useTypedSelector.ts +2 -2
  56. package/dist/utils/index.js +0 -49
  57. package/dist/utils/nodes.ts +3 -1
  58. package/dist/utils/prepareQueryExplain.ts +7 -24
  59. package/dist/utils/query.test.ts +153 -231
  60. package/dist/utils/query.ts +44 -78
  61. package/dist/utils/timeParsers/i18n/en.json +9 -9
  62. package/dist/utils/timeParsers/i18n/ru.json +9 -9
  63. package/dist/utils/timeParsers/parsers.ts +9 -0
  64. package/dist/utils/utils.js +1 -2
  65. package/package.json +1 -1
  66. package/dist/services/api.d.ts +0 -86
  67. package/dist/services/api.js +0 -278
@@ -1,34 +1,165 @@
1
- // common
1
+ // ==== types from backend protos ====
2
+ interface Position {
3
+ row?: number;
4
+ column?: number;
5
+ file?: string;
6
+ }
2
7
 
3
- type Plan = Record<string, any>;
4
- type AST = string;
5
- type Stats = Record<string, any>;
8
+ /** source: https://github.com/ydb-platform/ydb/blob/main/ydb/public/api/protos/ydb_issue_message.proto */
9
+ export interface IssueMessage {
10
+ position?: Position;
11
+ end_position?: Position;
12
+ message?: string;
13
+ issue_code?: number;
14
+ severity?: number;
15
+ issues?: IssueMessage[];
16
+ }
6
17
 
7
- export interface CommonFields {
8
- ast?: AST;
9
- plan?: Plan;
10
- stats?: Stats;
18
+ /** incomplete */
19
+ interface TDqStageStats {}
20
+
21
+ /** incomplete */
22
+ interface TKqpStatsCompile {}
23
+
24
+ interface TDqTableStats {
25
+ TablePath?: string;
26
+ /** uint64 */
27
+ ReadRows?: string;
28
+ /** uint64 */
29
+ ReadBytes?: string;
30
+ /** uint64 */
31
+ WriteRows?: string;
32
+ /** uint64 */
33
+ WriteBytes?: string;
34
+ /** uint64 */
35
+ EraseRows?: string;
36
+ /** uint64 */
37
+ EraseBytes?: string;
38
+ AffectedPartitions?: number;
39
+ Extra?: unknown;
11
40
  }
12
41
 
13
- interface DeprecatedCommonFields {
14
- stats?: Stats;
42
+ /** source: https://github.com/ydb-platform/ydb/blob/main/ydb/library/yql/dq/actors/protos/dq_stats.proto */
43
+ interface TDqExecutionStats {
44
+ /** uint64 */
45
+ CpuTimeUs?: string;
46
+ /** uint64 */
47
+ DurationUs?: string;
48
+ /** uint64 */
49
+ ResultRows?: string;
50
+ /** uint64 */
51
+ ResultBytes?: string;
52
+
53
+ Tables?: TDqTableStats[];
54
+
55
+ /** uint64 */
56
+ ExecuterCpuTimeUs?: string;
57
+ /** uint64 */
58
+ StartTimeMs?: string;
59
+ /** uint64 */
60
+ FinishTimeMs?: string;
61
+ /** uint64 */
62
+ FirstRowTimeMs?: string;
63
+
64
+ Stages?: TDqStageStats[];
65
+ TxPlansWithStats?: string[];
66
+
67
+ Extra: unknown;
15
68
  }
16
69
 
17
- export interface ErrorResponse {
18
- error?: any;
19
- issues?: any;
70
+ /** source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/protos/kqp_stats.proto */
71
+ export interface TKqpStatsQuery {
72
+ /** uint64 */
73
+ DurationUs?: string;
74
+ Compilation?: TKqpStatsCompile;
75
+
76
+ /** uint64 */
77
+ WorkerCpuTimeUs?: string;
78
+ /** uint64 */
79
+ ReadSetsCount?: string;
80
+ /** uint64 */
81
+ MaxShardProgramSize?: string;
82
+ /** uint64 */
83
+ MaxShardReplySize?: string;
84
+
85
+ Executions?: TDqExecutionStats[];
20
86
  }
21
87
 
22
- export type ExecuteActions = 'execute-script' | 'execute' | 'execute-scan' | undefined;
23
- export type ExplainActions = 'explain' | 'explain-ast';
24
- export type Actions = ExecuteActions | ExplainActions;
88
+ // ==== Self-written types ====
89
+ // ==== Meta version 0.2 ====
90
+ // Backend code: https://github.com/ydb-platform/ydb/blob/main/ydb/core/kqp/opt/kqp_query_plan.cpp
25
91
 
26
- // undefined == 'classic'
27
- export type Schemas = 'classic' | 'modern' | 'ydb' | undefined;
92
+ // ==== Plan ====
93
+ export interface PlanMeta {
94
+ version: string;
95
+ type: 'script' | 'query';
96
+ }
28
97
 
29
- // ==== EXECUTE ====
98
+ export interface PlanTable {
99
+ name: string;
100
+ reads?: {
101
+ type: string;
102
+ lookup_by?: string[];
103
+ scan_by?: string[];
104
+ limit?: string;
105
+ reverse?: boolean;
106
+ columns?: string[];
107
+ }[];
108
+ writes?: {
109
+ type: string;
110
+ key?: string[];
111
+ columns?: string[];
112
+ }[];
113
+ }
30
114
 
31
- // common types
115
+ interface PlanNodeStats {
116
+ TotalCpuTimeUs?: number;
117
+ TotalTasks?: number;
118
+ TotalInputBytes?: number;
119
+ TotalInputRows?: number;
120
+ TotalOutputBytes?: number;
121
+ TotalDurationMs?: number;
122
+ TotalOutputRows?: number;
123
+ }
124
+
125
+ interface PlanNodeOperator {
126
+ Name: string;
127
+ Limit?: string;
128
+ ReadLimit?: string;
129
+ ReadColumns?: string[];
130
+ ReadRanges?: string[];
131
+ Table?: string;
132
+ Iterator?: string;
133
+ }
134
+
135
+ export interface PlanNode {
136
+ PlanNodeId?: number;
137
+ 'Node Type'?: string;
138
+ Plans?: PlanNode[];
139
+ Operators?: PlanNodeOperator[];
140
+ Tables?: string[];
141
+ PlanNodeType?: string;
142
+ Stats?: PlanNodeStats;
143
+ 'CTE Name'?: string;
144
+ 'Subplan Name'?: string;
145
+ 'Parent Relationship'?: string;
146
+ }
147
+
148
+ export interface ScriptPlan {
149
+ queries?: {
150
+ Plan?: PlanNode;
151
+ tables?: PlanTable[];
152
+ }[];
153
+ meta: PlanMeta;
154
+ }
155
+
156
+ export interface ScanPlan {
157
+ Plan?: PlanNode;
158
+ tables?: PlanTable[];
159
+ meta: PlanMeta;
160
+ }
161
+
162
+ // ==== Common types ====
32
163
 
33
164
  export type CellValue = string | number | null | undefined;
34
165
 
@@ -43,113 +174,91 @@ export interface ColumnType {
43
174
  type: string;
44
175
  }
45
176
 
46
- // modern response
47
-
48
- export type ExecuteModernResponse = {
49
- result: ArrayRow[];
50
- columns: ColumnType[];
51
- } & CommonFields;
52
-
53
- export type ExecuteClassicResponseDeep = {
54
- result: KeyValueRow[];
55
- } & CommonFields;
56
-
57
- // can be undefined for queries like `insert into`
58
- export type ExecuteClassicResponsePlain = KeyValueRow[] | undefined;
59
-
60
- export type ExecuteClassicResponse = ExecuteClassicResponseDeep | ExecuteClassicResponsePlain;
61
-
62
- export type ExecuteYdbResponse = {
63
- result: KeyValueRow[];
64
- } & CommonFields;
65
-
66
- // prettier-ignore
67
- type ExecuteResponse<Schema extends Schemas> =
68
- | CommonFields // result can be undefined for queries like `insert into`
69
- | (Schema extends 'modern'
70
- ? ExecuteModernResponse
71
- : Schema extends 'ydb'
72
- ? ExecuteYdbResponse
73
- : Schema extends 'classic' | undefined
74
- ? ExecuteClassicResponse
75
- : unknown);
76
-
77
- // deprecated response from older versions, backward compatibility
78
-
79
- type DeprecatedExecuteResponseValue =
80
- | KeyValueRow[]
81
- | string
82
- // can be here because of a bug in the previous backend version
83
- // should be ignored in parsing
84
- | Plan;
85
-
86
- export type DeprecatedExecuteResponseDeep = {
87
- // can be undefined for queries like `insert into`
88
- result?: DeprecatedExecuteResponseValue;
89
- } & DeprecatedCommonFields;
90
-
91
- // can be undefined for queries like `insert into`
92
- export type DeprecatedExecuteResponsePlain = DeprecatedExecuteResponseValue | undefined;
93
-
94
- export type DeprecatedExecuteResponse =
95
- | DeprecatedExecuteResponseDeep
96
- | DeprecatedExecuteResponsePlain;
177
+ /** undefined = 'classic' */
178
+ export type Schemas = 'classic' | 'modern' | 'ydb' | undefined;
97
179
 
98
- // ==== EXPLAIN ====
180
+ /**
181
+ * undefined = 'execute'
182
+ *
183
+ * execute and execute-script have similar responses
184
+ */
185
+ export type ExecuteActions = 'execute' | 'execute-scan' | 'execute-script' | undefined;
99
186
 
100
- // modern response
187
+ /** explain, explain-scan and explain-ast have similar responses */
188
+ export type ExplainActions = 'explain' | 'explain-scan' | 'explain-script' | 'explain-ast';
101
189
 
102
- type ExplainResponse = CommonFields;
190
+ export type Actions = ExecuteActions | ExplainActions;
103
191
 
104
- // deprecated response from older versions, backward compatibility
192
+ // ==== Error response ====
105
193
 
106
- // prettier-ignore
107
- type DeprecatedExplainResponse<Action extends ExplainActions> =
108
- Action extends 'explain-ast'
109
- ? ({result: {ast: AST}} & Required<DeprecatedCommonFields>) | {ast: AST}
110
- : Action extends 'explain'
111
- ? ({result: Plan} & Required<DeprecatedCommonFields>) | Plan
112
- : unknown;
194
+ export interface ErrorResponse {
195
+ error?: IssueMessage;
196
+ issues?: IssueMessage[];
197
+ }
113
198
 
114
- // ==== COMBINED API RESPONSE ====
199
+ // ==== Explain Responses ====
115
200
 
116
- export type QueryAPIExecuteResponse<Schema extends Schemas = undefined> =
117
- | ExecuteResponse<Schema>
118
- | DeprecatedExecuteResponse
119
- | null;
201
+ export interface ExplainScriptResponse {
202
+ plan?: ScriptPlan;
203
+ }
120
204
 
121
- export type QueryAPIExplainResponse<Action extends ExplainActions> =
122
- | ExplainResponse
123
- | DeprecatedExplainResponse<Action>
124
- | null;
205
+ export interface ExplainScanResponse {
206
+ ast?: string;
207
+ plan?: ScanPlan;
208
+ }
125
209
 
126
- // prettier-ignore
127
- export type QueryAPIResponse<Action extends Actions, Schema extends Schemas = undefined> =
128
- Action extends ExecuteActions
129
- ? QueryAPIExecuteResponse<Schema>
130
- : Action extends ExplainActions
131
- ? QueryAPIExplainResponse<Action>
132
- : unknown;
210
+ export type ExplainResponse<Action extends ExplainActions> = Action extends 'explain-script'
211
+ ? ExplainScriptResponse
212
+ : ExplainScanResponse;
213
+
214
+ // ==== Execute Responses ====
215
+
216
+ type ResultFields<Schema extends Schemas> = Schema extends 'modern'
217
+ ? {
218
+ result?: ArrayRow[];
219
+ columns?: ColumnType[];
220
+ }
221
+ : {
222
+ result?: KeyValueRow[];
223
+ };
224
+
225
+ export type ExecuteScanResponse<Schema extends Schemas> = {
226
+ plan?: ScanPlan;
227
+ ast?: string;
228
+ stats?: TKqpStatsQuery;
229
+ } & ResultFields<Schema>;
230
+
231
+ export type ExecuteScriptResponse<Schema extends Schemas> = {
232
+ plan?: ScriptPlan;
233
+ ast?: string;
234
+ stats?: TKqpStatsQuery;
235
+ } & ResultFields<Schema>;
236
+
237
+ export type ExecuteResponse<
238
+ Action extends ExecuteActions,
239
+ Schema extends Schemas,
240
+ > = Action extends 'execute-scan' ? ExecuteScanResponse<Schema> : ExecuteScriptResponse<Schema>;
241
+
242
+ // ==== Combined API response ====
243
+ export type QueryAPIResponse<
244
+ Action extends Actions,
245
+ Schema extends Schemas,
246
+ > = Action extends ExplainActions
247
+ ? ExplainResponse<Action>
248
+ : Action extends ExecuteActions
249
+ ? ExecuteResponse<Action, Schema>
250
+ : unknown;
251
+
252
+ // ==== types to use in query result preparation ====
253
+ export type AnyExplainResponse = ExplainScanResponse | ExplainScriptResponse;
254
+
255
+ export type ExecuteModernResponse = ExecuteScanResponse<'modern'> | ExecuteScriptResponse<'modern'>;
256
+ export type ExecuteClassicResponse =
257
+ | ExecuteScanResponse<'classic'>
258
+ | ExecuteScriptResponse<'classic'>;
259
+ export type ExecuteYdbResponse = ExecuteScanResponse<'ydb'> | ExecuteScriptResponse<'ydb'>;
133
260
 
134
261
  export type AnyExecuteResponse =
135
262
  | ExecuteModernResponse
136
263
  | ExecuteClassicResponse
137
- | ExecuteYdbResponse
138
- | CommonFields
139
- | DeprecatedExecuteResponse
140
- | null;
141
-
142
- export type DeepExecuteResponse =
143
- | ExecuteModernResponse
144
- | ExecuteClassicResponseDeep
145
- | ExecuteYdbResponse
146
- | DeprecatedExecuteResponseDeep;
147
-
148
- export type AnyExplainResponse =
149
- | ExplainResponse
150
- | CommonFields
151
- | DeprecatedExplainResponse<'explain'>
152
- | DeprecatedExplainResponse<'explain-ast'>
153
- | null;
154
-
155
- export type AnyResponse = AnyExecuteResponse | AnyExplainResponse;
264
+ | ExecuteYdbResponse;
@@ -1,9 +1,11 @@
1
1
  import {EFlag} from './enums';
2
2
  import {TVDiskStateInfo} from './vdisk';
3
3
 
4
- // endpoint: /viewer/json/storage
5
- // source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto
6
-
4
+ /**
5
+ * endpoint: /viewer/json/storage
6
+ *
7
+ * source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto
8
+ */
7
9
  export interface TStorageInfo {
8
10
  Overall?: EFlag;
9
11
  StoragePools?: TStoragePoolInfo[];
@@ -2,13 +2,20 @@ import {EFlag} from './enums';
2
2
  import {TPoolStats, TSystemStateInfo} from './nodes';
3
3
  import {TTabletStateInfo} from './tablet';
4
4
 
5
- // endpoint: /viewer/json/tenantinfo
6
- // source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto
7
-
5
+ /**
6
+ * endpoint: /viewer/json/tenants
7
+ *
8
+ * source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto
9
+ */
8
10
  export interface TTenants {
9
11
  Tenants?: TTenant[];
10
12
  }
11
13
 
14
+ /**
15
+ * endpoint: /viewer/json/tenantinfo
16
+ *
17
+ * source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto
18
+ */
12
19
  export interface TTenantInfo {
13
20
  TenantInfo?: TTenant[];
14
21
  Errors?: string[];
@@ -47,6 +54,9 @@ export interface TTenant {
47
54
  CoresUsed: number;
48
55
  /** uint64 */
49
56
  StorageGroups: string;
57
+
58
+ MonitoringEndpoint?: string; // additional
59
+ ControlPlane?: ControlPlane; // additional
50
60
  }
51
61
 
52
62
  interface THiveDomainStatsStateCount {
@@ -107,6 +117,11 @@ interface TTenantResource {
107
117
  Count: number;
108
118
  }
109
119
 
120
+ /** incomplete */
121
+ interface ControlPlane {
122
+ name?: string;
123
+ }
124
+
110
125
  export enum ETenantType {
111
126
  'UnknownTenantType' = 'UnknownTenantType',
112
127
  'Domain' = 'Domain',
@@ -1,8 +1,16 @@
1
1
  import {EFlag} from './enums';
2
2
  import {TPDiskStateInfo} from './pdisk';
3
3
 
4
- // endpoint: /viewer/json/vdiskinfo
5
- // source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/protos/node_whiteboard.proto
4
+ /**
5
+ * endpoint: /viewer/json/vdiskinfo
6
+ *
7
+ * source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/protos/node_whiteboard.proto
8
+ */
9
+ export interface TEvVDiskStateResponse {
10
+ VDiskStateInfo?: TVDiskStateInfo[];
11
+ ResponseTime?: string;
12
+ ResponseDuration?: number;
13
+ }
6
14
 
7
15
  export interface TVDiskStateInfo {
8
16
  VDiskId?: TVDiskID;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * endpoint: /viewer/json/whoami
3
+ *
4
+ * source: https://github.com/ydb-platform/ydb/blob/main/ydb/library/aclib/protos/aclib.proto
5
+ */
6
+ export interface TUserToken {
7
+ UserSID?: string;
8
+ GroupSIDs?: TProtoHashTable;
9
+ OriginalUserToken?: string;
10
+ AuthType?: string;
11
+ }
12
+
13
+ interface TProtoHashTable {
14
+ Buckets?: TProtoHashBucket[];
15
+ }
16
+
17
+ interface TProtoHashBucket {
18
+ Values?: string[];
19
+ }
@@ -2,19 +2,17 @@ import {
2
2
  SEND_QUERY,
3
3
  changeUserInput,
4
4
  saveQueryToHistory,
5
- selectRunAction,
6
5
  goToPreviousQuery,
7
6
  setMonacoHotKey,
8
7
  goToNextQuery,
9
8
  MONACO_HOT_KEY_ACTIONS,
10
- RUN_ACTIONS_VALUES,
11
9
  } from '../../store/reducers/executeQuery';
12
10
  import type {ApiRequestAction} from '../../store/utils';
11
+ import type {ErrorResponse} from '../api/query';
13
12
  import type {ValueOf} from '../common';
14
- import type {IQueryResult} from './query';
13
+ import type {IQueryResult, QueryError} from './query';
15
14
 
16
15
  export type MonacoHotKeyAction = ValueOf<typeof MONACO_HOT_KEY_ACTIONS>;
17
- export type RunAction = ValueOf<typeof RUN_ACTIONS_VALUES>;
18
16
 
19
17
  export interface ExecuteQueryState {
20
18
  loading: boolean;
@@ -23,14 +21,13 @@ export interface ExecuteQueryState {
23
21
  queries: string[];
24
22
  currentIndex: number;
25
23
  };
26
- runAction: RunAction;
27
24
  monacoHotKey: null | MonacoHotKeyAction;
28
25
  data?: IQueryResult;
29
26
  stats?: IQueryResult['stats'];
30
- error?: unknown;
27
+ error?: string | ErrorResponse;
31
28
  }
32
29
 
33
- type SendQueryAction = ApiRequestAction<typeof SEND_QUERY, IQueryResult, unknown>;
30
+ type SendQueryAction = ApiRequestAction<typeof SEND_QUERY, IQueryResult, QueryError>;
34
31
 
35
32
  export type ExecuteQueryAction =
36
33
  | SendQueryAction
@@ -38,5 +35,4 @@ export type ExecuteQueryAction =
38
35
  | ReturnType<typeof goToPreviousQuery>
39
36
  | ReturnType<typeof changeUserInput>
40
37
  | ReturnType<typeof saveQueryToHistory>
41
- | ReturnType<typeof selectRunAction>
42
38
  | ReturnType<typeof setMonacoHotKey>;
@@ -0,0 +1,38 @@
1
+ import type {ExplainPlanNodeData, GraphNode, Link} from '@gravity-ui/paranoid';
2
+
3
+ import {GET_EXPLAIN_QUERY, GET_EXPLAIN_QUERY_AST} from '../../store/reducers/explainQuery';
4
+ import type {ApiRequestAction} from '../../store/utils';
5
+ import type {PlanTable, ErrorResponse, ScanPlan, ScriptPlan} from '../api/query';
6
+ import type {IQueryResult, QueryError} from './query';
7
+
8
+ export interface PreparedExplainResponse {
9
+ plan?: {
10
+ links?: Link[];
11
+ nodes?: GraphNode<ExplainPlanNodeData>[];
12
+ tables?: PlanTable[];
13
+ version?: string;
14
+ pristine?: ScanPlan | ScriptPlan;
15
+ };
16
+ ast?: string;
17
+ }
18
+
19
+ export interface ExplainQueryState {
20
+ loading: boolean;
21
+ data?: PreparedExplainResponse['plan'];
22
+ dataAst?: PreparedExplainResponse['ast'];
23
+ error?: string | ErrorResponse;
24
+ errorAst?: string | ErrorResponse;
25
+ }
26
+
27
+ type GetExplainQueryAstAction = ApiRequestAction<
28
+ typeof GET_EXPLAIN_QUERY_AST,
29
+ IQueryResult,
30
+ QueryError
31
+ >;
32
+ type GetExplainQueryAction = ApiRequestAction<
33
+ typeof GET_EXPLAIN_QUERY,
34
+ PreparedExplainResponse,
35
+ QueryError
36
+ >;
37
+
38
+ export type ExplainQueryAction = GetExplainQueryAstAction | GetExplainQueryAction;
@@ -1,9 +1,29 @@
1
- import type {KeyValueRow, ColumnType} from '../api/query';
1
+ import type {NetworkError} from '../api/error';
2
+ import type {
3
+ KeyValueRow,
4
+ ColumnType,
5
+ ErrorResponse,
6
+ ScriptPlan,
7
+ ScanPlan,
8
+ TKqpStatsQuery,
9
+ } from '../api/query';
2
10
 
3
11
  export interface IQueryResult {
4
12
  result?: KeyValueRow[];
5
13
  columns?: ColumnType[];
6
- stats?: any;
7
- plan?: any;
14
+ stats?: TKqpStatsQuery;
15
+ plan?: ScriptPlan | ScanPlan;
8
16
  ast?: string;
9
17
  }
18
+
19
+ export interface QueryRequestParams {
20
+ database: string;
21
+ query: string;
22
+ }
23
+
24
+ export type QueryError = NetworkError | ErrorResponse;
25
+
26
+ export enum QueryModes {
27
+ scan = 'scan',
28
+ script = 'script',
29
+ }
@@ -37,4 +37,9 @@ interface Window {
37
37
  custom_backend?: string;
38
38
 
39
39
  __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof import('redux').compose;
40
+
41
+ userSettings?: Record<string, string | undefined>;
42
+ systemSettings?: Record<string, string | undefined>;
43
+
44
+ api: import('../services/api').YdbEmbeddedAPI;
40
45
  }
@@ -94,6 +94,7 @@ export type IProblemFilterValues = typeof ALL | typeof PROBLEMS;
94
94
  export const THEME_KEY = 'theme';
95
95
  export const INVERTED_DISKS_KEY = 'invertedDisks';
96
96
  export const USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY = 'useNodesEndpointInDiagnostics';
97
+ export const ENABLE_QUERY_MODES_FOR_EXPLAIN = 'enableQueryModesForExplain';
97
98
  export const SAVED_QUERIES_KEY = 'saved_queries';
98
99
  export const ASIDE_HEADER_COMPACT_KEY = 'asideHeaderCompact';
99
100
  export const QUERIES_HISTORY_KEY = 'queries_history';
@@ -118,6 +119,6 @@ export const DEFAULT_TABLE_SETTINGS = {
118
119
  } as const;
119
120
 
120
121
  export const TENANT_INITIAL_TAB_KEY = 'saved_tenant_initial_tab';
121
- export const QUERY_INITIAL_RUN_ACTION_KEY = 'query_initial_run_action';
122
+ export const QUERY_INITIAL_MODE_KEY = 'query_initial_mode';
122
123
 
123
124
  export const PARTITIONS_SELECTED_COLUMNS_KEY = 'partitionsSelectedColumns';
@@ -0,0 +1,25 @@
1
+ import type {AxiosError} from 'axios';
2
+
3
+ import type {IResponseError, NetworkError} from '../types/api/error';
4
+ import type {ErrorResponse as QueryErrorResponse} from '../types/api/query';
5
+ import type {QueryError} from '../types/store/query';
6
+
7
+ type RequestError = NetworkError | IResponseError | AxiosError | QueryErrorResponse | unknown;
8
+
9
+ const isNetworkError = (error: RequestError): error is NetworkError => {
10
+ return Boolean(
11
+ error &&
12
+ typeof error === 'object' &&
13
+ 'message' in error &&
14
+ (error as {message: unknown}).message === 'Network Error',
15
+ );
16
+ };
17
+
18
+ export const parseQueryError = (error: QueryError): QueryErrorResponse | string | undefined => {
19
+ if (isNetworkError(error)) {
20
+ return error.message;
21
+ }
22
+
23
+ // 401 Unauthorized error is handled by GenericAPI
24
+ return error ?? 'Unauthorized';
25
+ };
@@ -1,5 +1,5 @@
1
1
  import {TypedUseSelectorHook, useSelector} from 'react-redux';
2
2
 
3
- import {IRootState} from '../../store';
3
+ import {RootState} from '../../store';
4
4
 
5
- export const useTypedSelector: TypedUseSelectorHook<IRootState> = useSelector;
5
+ export const useTypedSelector: TypedUseSelectorHook<RootState> = useSelector;