ydb-embedded-ui 6.0.1 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +0 -2
- package/dist/components/DateRange/DateRange.scss +7 -0
- package/dist/components/NodeHostWrapper/NodeHostWrapper.js +1 -1
- package/dist/components/NodeHostWrapper/NodeHostWrapper.scss +0 -6
- package/dist/components/QueryResultTable/QueryResultTable.d.ts +2 -2
- package/dist/components/QueryResultTable/QueryResultTable.js +2 -1
- package/dist/components/QueryResultTable/QueryResultTable.scss +1 -0
- package/dist/components/ResizeableDataTable/ResizeableDataTable.d.ts +7 -0
- package/dist/components/ResizeableDataTable/ResizeableDataTable.js +14 -0
- package/dist/components/ResizeableDataTable/ResizeableDataTable.scss +8 -0
- package/dist/components/VirtualTable/ResizeHandler.d.ts +8 -0
- package/dist/components/VirtualTable/ResizeHandler.js +62 -0
- package/dist/components/VirtualTable/ResizeableVirtualTable.d.ts +6 -0
- package/dist/components/VirtualTable/ResizeableVirtualTable.js +16 -0
- package/dist/components/VirtualTable/TableHead.d.ts +3 -3
- package/dist/components/VirtualTable/TableHead.js +16 -31
- package/dist/components/VirtualTable/VirtualTable.d.ts +2 -4
- package/dist/components/VirtualTable/VirtualTable.scss +24 -4
- package/dist/components/VirtualTable/types.d.ts +3 -0
- package/dist/components/VirtualTable/utils.d.ts +2 -0
- package/dist/components/VirtualTable/utils.js +21 -0
- package/dist/containers/ClusterModeGuard/ClusterModeGuard.js +1 -1
- package/dist/containers/Clusters/Clusters.js +3 -2
- package/dist/containers/Clusters/Clusters.scss +5 -0
- package/dist/containers/Clusters/columns.d.ts +1 -0
- package/dist/containers/Clusters/columns.js +4 -3
- package/dist/containers/Nodes/Nodes.js +4 -4
- package/dist/containers/Nodes/Nodes.scss +0 -5
- package/dist/containers/Nodes/VirtualNodes.js +4 -6
- package/dist/containers/Nodes/getNodesColumns.d.ts +1 -0
- package/dist/containers/Nodes/getNodesColumns.js +9 -1
- package/dist/containers/PDiskPage/PDiskGroups.js +3 -3
- package/dist/containers/PDiskPage/PDiskPage.js +6 -1
- package/dist/containers/Storage/Storage.scss +0 -4
- package/dist/containers/Storage/StorageGroups/StorageGroups.js +3 -3
- package/dist/containers/Storage/StorageGroups/VirtualStorageGroups.js +3 -3
- package/dist/containers/Storage/StorageGroups/getStorageGroupsColumns.d.ts +3 -0
- package/dist/containers/Storage/StorageGroups/getStorageGroupsColumns.js +7 -3
- package/dist/containers/Storage/StorageNodes/StorageNodes.js +3 -3
- package/dist/containers/Storage/StorageNodes/VirtualStorageNodes.js +3 -3
- package/dist/containers/Storage/StorageNodes/getStorageNodesColumns.d.ts +3 -0
- package/dist/containers/Storage/StorageNodes/getStorageNodesColumns.js +2 -0
- package/dist/containers/Tablet/Tablet.scss +0 -4
- package/dist/containers/Tablet/TabletTable/TabletTable.js +5 -3
- package/dist/containers/Tenant/Acl/Acl.js +3 -2
- package/dist/containers/Tenant/Acl/Acl.scss +0 -6
- package/dist/containers/Tenant/Diagnostics/Consumers/Consumers.js +3 -3
- package/dist/containers/Tenant/Diagnostics/Consumers/Consumers.scss +2 -0
- package/dist/containers/Tenant/Diagnostics/Consumers/columns/columns.d.ts +1 -0
- package/dist/containers/Tenant/Diagnostics/Consumers/columns/columns.js +2 -0
- package/dist/containers/Tenant/Diagnostics/HotKeys/HotKeys.js +5 -4
- package/dist/containers/Tenant/Diagnostics/HotKeys/HotKeys.scss +1 -5
- package/dist/containers/Tenant/Diagnostics/Partitions/Partitions.js +8 -4
- package/dist/containers/Tenant/Diagnostics/Partitions/Partitions.scss +2 -0
- package/dist/containers/Tenant/Diagnostics/Partitions/PartitionsControls/PartitionsControls.js +1 -1
- package/dist/containers/Tenant/Diagnostics/Partitions/columns/Columns.scss +0 -8
- package/dist/containers/Tenant/Diagnostics/Partitions/columns/columns.d.ts +1 -0
- package/dist/containers/Tenant/Diagnostics/Partitions/columns/columns.js +11 -4
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByCpu.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByLoad.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopQueries.js +3 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopShards.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/TopNodesByMemory.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss +3 -7
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverviewTableLayout.d.ts +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverviewTableLayout.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopGroups.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.js +4 -2
- package/dist/containers/Tenant/Diagnostics/TopQueries/TopQueries.js +8 -11
- package/dist/containers/Tenant/Diagnostics/TopQueries/TopQueries.scss +2 -24
- package/dist/containers/Tenant/Diagnostics/TopQueries/getTopQueriesColumns.d.ts +1 -0
- package/dist/containers/Tenant/Diagnostics/TopQueries/getTopQueriesColumns.js +7 -0
- package/dist/containers/Tenant/Diagnostics/TopShards/Filters/Filters.d.ts +1 -2
- package/dist/containers/Tenant/Diagnostics/TopShards/Filters/Filters.js +3 -4
- package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.d.ts +0 -1
- package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.js +8 -10
- package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.scss +4 -15
- package/dist/containers/Tenant/Diagnostics/TopShards/getTopShardsColumns.d.ts +1 -0
- package/dist/containers/Tenant/Diagnostics/TopShards/getTopShardsColumns.js +5 -0
- package/dist/containers/Tenant/ObjectSummary/ObjectSummary.js +1 -1
- package/dist/containers/Tenant/ObjectSummary/ObjectSummary.scss +0 -6
- package/dist/containers/Tenant/Query/ExecuteResult/ExecuteResult.scss +1 -21
- package/dist/containers/Tenant/Query/ExplainResult/ExplainResult.js +4 -4
- package/dist/containers/Tenant/Query/ExplainResult/utils.d.ts +0 -3
- package/dist/containers/Tenant/Query/ExplainResult/utils.js +0 -34
- package/dist/containers/Tenant/Query/Preview/Preview.scss +6 -3
- package/dist/containers/Tenant/Query/QueriesHistory/QueriesHistory.js +4 -2
- package/dist/containers/Tenant/Query/QueriesHistory/QueriesHistory.scss +0 -1
- package/dist/containers/Tenant/Query/QueryEditor/QueryEditor.js +2 -1
- package/dist/containers/Tenant/Query/QueryEditor/helpers.js +5 -3
- package/dist/containers/Tenant/Query/SavedQueries/SavedQueries.js +4 -1
- package/dist/containers/Tenant/Query/SavedQueries/SavedQueries.scss +0 -1
- package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.d.ts +1 -2
- package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +4 -3
- package/dist/containers/Tenant/Schema/SchemaViewer/helpers.d.ts +1 -0
- package/dist/containers/Tenant/Schema/SchemaViewer/helpers.js +4 -2
- package/dist/containers/Tenant/Tenant.js +1 -1
- package/dist/containers/Tenants/Tenants.js +8 -3
- package/dist/containers/Tenants/Tenants.scss +13 -5
- package/dist/containers/UserSettings/i18n/en.json +2 -0
- package/dist/containers/UserSettings/i18n/index.d.ts +1 -1
- package/dist/containers/UserSettings/settings.d.ts +1 -0
- package/dist/containers/UserSettings/settings.js +7 -2
- package/dist/containers/Versions/GroupedNodesTree/GroupedNodesTree.scss +0 -2
- package/dist/containers/Versions/NodesTable/NodesTable.js +14 -9
- package/dist/services/api.d.ts +9 -1
- package/dist/services/api.js +5 -0
- package/dist/services/settings.js +2 -1
- package/dist/styles/mixins.scss +0 -47
- package/dist/types/api/autocomplete.d.ts +21 -0
- package/dist/types/api/autocomplete.js +1 -0
- package/dist/types/api/restartPDisk.d.ts +4 -0
- package/dist/types/api/restartPDisk.js +1 -0
- package/dist/utils/constants.d.ts +26 -10
- package/dist/utils/constants.js +1 -0
- package/dist/utils/hooks/useTableResize.d.ts +2 -7
- package/dist/utils/hooks/useTableResize.js +12 -24
- package/dist/utils/monaco/index.js +2 -0
- package/dist/utils/monaco/{yqlSuggestions → yql}/constants.d.ts +1 -0
- package/dist/utils/monaco/{yqlSuggestions → yql}/constants.js +1 -0
- package/dist/utils/monaco/{yqlSuggestions → yql}/generateSuggestions.d.ts +3 -3
- package/dist/utils/monaco/{yqlSuggestions → yql}/generateSuggestions.js +124 -64
- package/dist/utils/monaco/yql/registerLanguage.d.ts +1 -0
- package/dist/utils/monaco/yql/registerLanguage.js +8 -0
- package/dist/utils/monaco/{yqlSuggestions/registerCompletionItemProvider.js → yql/yql.completionItemProvider.js} +3 -2
- package/dist/utils/monaco/yql/yql.d.ts +7 -0
- package/dist/utils/monaco/yql/yql.js +180 -0
- package/dist/utils/monaco/yql/yql.keywords.d.ts +3 -0
- package/dist/utils/monaco/yql/yql.keywords.js +3 -0
- package/dist/utils/monaco/{yqlSuggestions → yql}/yqlSuggestions.js +14 -7
- package/package.json +12 -12
- package/dist/containers/Tenant/Diagnostics/TopShards/Filters/Filters.scss +0 -8
- /package/dist/utils/monaco/{yqlSuggestions/registerCompletionItemProvider.d.ts → yql/yql.completionItemProvider.d.ts} +0 -0
- /package/dist/utils/monaco/{yqlSuggestions → yql}/yqlSuggestions.d.ts +0 -0
package/dist/styles/mixins.scss
CHANGED
@@ -96,13 +96,6 @@
|
|
96
96
|
|
97
97
|
@mixin query-data-table() {
|
98
98
|
& .data-table {
|
99
|
-
$_: &;
|
100
|
-
|
101
|
-
&__table {
|
102
|
-
border-spacing: 0;
|
103
|
-
border-collapse: separate;
|
104
|
-
}
|
105
|
-
|
106
99
|
&__th,
|
107
100
|
&__td {
|
108
101
|
vertical-align: middle;
|
@@ -114,11 +107,6 @@
|
|
114
107
|
}
|
115
108
|
}
|
116
109
|
|
117
|
-
&__row,
|
118
|
-
&__sticky th {
|
119
|
-
height: 40px;
|
120
|
-
}
|
121
|
-
|
122
110
|
&__th {
|
123
111
|
box-shadow: inset 0 -1px 0 0 var(--g-tabs-color-divider);
|
124
112
|
}
|
@@ -170,41 +158,6 @@
|
|
170
158
|
}
|
171
159
|
}
|
172
160
|
|
173
|
-
@mixin table-styles {
|
174
|
-
& .data-table {
|
175
|
-
&__table {
|
176
|
-
width: 100%;
|
177
|
-
}
|
178
|
-
|
179
|
-
&__row,
|
180
|
-
&__sticky th {
|
181
|
-
height: 40px;
|
182
|
-
}
|
183
|
-
|
184
|
-
&__box {
|
185
|
-
.data-table__table-wrapper {
|
186
|
-
padding-bottom: 20px;
|
187
|
-
}
|
188
|
-
|
189
|
-
&_sticky-head_fixed {
|
190
|
-
overflow: initial;
|
191
|
-
}
|
192
|
-
}
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
@mixin table-sticky-styles {
|
197
|
-
& .data-table {
|
198
|
-
&__th {
|
199
|
-
height: auto;
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
& {
|
204
|
-
padding-bottom: 20px;
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
161
|
@mixin json-tree-styles {
|
209
162
|
// stylelint-disable
|
210
163
|
font-family: var(--g-font-family-monospace) !important;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* endpoint: /viewer/json/autocomplete
|
3
|
+
*
|
4
|
+
* source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/protos/viewer.proto
|
5
|
+
*/
|
6
|
+
export interface TQueryAutocomplete {
|
7
|
+
Success: boolean;
|
8
|
+
Error?: string[];
|
9
|
+
Result: TAutocompleteResult;
|
10
|
+
}
|
11
|
+
interface TAutocompleteResult {
|
12
|
+
Entities: TAutocompleteEntity[];
|
13
|
+
Total?: number;
|
14
|
+
}
|
15
|
+
export interface TAutocompleteEntity {
|
16
|
+
Name: string;
|
17
|
+
Type: AutocompleteEntityType;
|
18
|
+
Parent: string;
|
19
|
+
}
|
20
|
+
export type AutocompleteEntityType = 'unknown' | 'dir' | 'table' | 'pers_queue_group' | 'sub_domain' | 'rtmr_volume' | 'block_store_volume' | 'kesus' | 'solomon_volume' | 'table_index' | 'ext_sub_domain' | 'file_store' | 'column_store' | 'column_table' | 'cdc_stream' | 'sequence' | 'replication' | 'blob_depot' | 'external_table' | 'external_data_source' | 'view' | 'column' | 'index';
|
21
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -1,3 +1,5 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import type { Settings } from '@gravity-ui/react-data-table';
|
1
3
|
export declare const AUTO_RELOAD_INTERVAL: number;
|
2
4
|
export declare const DEFAULT_POLLING_INTERVAL: number;
|
3
5
|
export declare const KILOBYTE = 1000;
|
@@ -66,19 +68,32 @@ export declare const DEFAULT_IS_TENANT_SUMMARY_COLLAPSED = "default-is-tenant-su
|
|
66
68
|
export declare const DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED = "default-is-tenant-common-info-collapsed";
|
67
69
|
export declare const DEFAULT_IS_QUERY_RESULT_COLLAPSED = "default-is-query-result-collapsed";
|
68
70
|
export declare const DEFAULT_CLUSTER_TAB_KEY = "default-cluster-tab";
|
69
|
-
export declare const DEFAULT_TABLE_SETTINGS:
|
70
|
-
readonly displayIndices: false;
|
71
|
-
readonly stickyHead: "moving";
|
72
|
-
readonly syncHeadOnResize: true;
|
73
|
-
readonly dynamicRender: true;
|
74
|
-
readonly highlightRows: true;
|
75
|
-
};
|
71
|
+
export declare const DEFAULT_TABLE_SETTINGS: Settings;
|
76
72
|
export declare const TENANT_OVERVIEW_TABLES_SETTINGS: {
|
77
73
|
readonly stickyHead: "fixed";
|
78
74
|
readonly dynamicRender: false;
|
79
|
-
readonly displayIndices
|
80
|
-
readonly
|
81
|
-
readonly
|
75
|
+
readonly displayIndices?: boolean | undefined;
|
76
|
+
readonly stickyTop?: number | "auto" | undefined;
|
77
|
+
readonly syncHeadOnResize?: boolean | undefined;
|
78
|
+
readonly stickyFooter?: import("@gravity-ui/react-data-table").HeadPosition | undefined;
|
79
|
+
readonly stickyBottom?: number | "auto" | undefined;
|
80
|
+
readonly dynamicInnerRef?: import("react").Ref<ReactList> | undefined;
|
81
|
+
readonly dynamicRenderType?: "simple" | "uniform" | "variable" | undefined;
|
82
|
+
readonly dynamicItemSizeEstimator?: any;
|
83
|
+
readonly dynamicItemSizeGetter?: any;
|
84
|
+
readonly dynamicRenderMinSize?: number | undefined;
|
85
|
+
readonly dynamicRenderUseStaticSize?: boolean | undefined;
|
86
|
+
readonly dynamicRenderThreshold?: number | undefined;
|
87
|
+
readonly dynamicRenderScrollParentGetter?: any;
|
88
|
+
readonly dynamicRenderScrollParentViewportSizeGetter?: (() => number) | undefined;
|
89
|
+
readonly sortable?: boolean | undefined;
|
90
|
+
readonly externalSort?: boolean | undefined;
|
91
|
+
readonly disableSortReset?: boolean | undefined;
|
92
|
+
readonly defaultOrder?: import("@gravity-ui/react-data-table").OrderType | undefined;
|
93
|
+
readonly defaultResizeable?: boolean | undefined;
|
94
|
+
readonly highlightRows?: boolean | undefined;
|
95
|
+
readonly stripedRows?: boolean | undefined;
|
96
|
+
readonly headerMod?: "multiline" | "pre" | undefined;
|
82
97
|
};
|
83
98
|
export declare const QUERY_INITIAL_MODE_KEY = "query_initial_mode";
|
84
99
|
export declare const LAST_USED_QUERY_ACTION_KEY = "last_used_query_action";
|
@@ -88,3 +103,4 @@ export declare const USE_BACKEND_PARAMS_FOR_TABLES_KEY = "useBackendParamsForTab
|
|
88
103
|
export declare const QUERY_USE_MULTI_SCHEMA_KEY = "queryUseMultiSchema";
|
89
104
|
export declare const USE_CLUSTER_BALANCER_AS_BACKEND_KEY = "useClusterBalancerAsBacked";
|
90
105
|
export declare const ENABLE_AUTOCOMPLETE = "enableAutocomplete";
|
106
|
+
export declare const AUTOCOMPLETE_ON_ENTER = "autocompleteOnEnter";
|
package/dist/utils/constants.js
CHANGED
@@ -101,3 +101,4 @@ export const USE_BACKEND_PARAMS_FOR_TABLES_KEY = 'useBackendParamsForTables';
|
|
101
101
|
export const QUERY_USE_MULTI_SCHEMA_KEY = 'queryUseMultiSchema';
|
102
102
|
export const USE_CLUSTER_BALANCER_AS_BACKEND_KEY = 'useClusterBalancerAsBacked';
|
103
103
|
export const ENABLE_AUTOCOMPLETE = 'enableAutocomplete';
|
104
|
+
export const AUTOCOMPLETE_ON_ENTER = 'autocompleteOnEnter';
|
@@ -1,7 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
export type Column<T> = VirtualTableColumn<T> & DataTableColumn<T>;
|
4
|
-
export type TableColumnsWidthSetup = Record<string, number>;
|
5
|
-
export type HandleTableColumnsResize = (newSetup: TableColumnsWidthSetup) => void;
|
6
|
-
export declare const updateColumnsWidth: <T>(columns: Column<T>[], columnsWidthSetup: TableColumnsWidthSetup) => Column<T>[];
|
7
|
-
export declare const useTableResize: (localStorageKey: string) => [TableColumnsWidthSetup, HandleTableColumnsResize];
|
1
|
+
import type { ColumnWidthByName, HandleResize } from '@gravity-ui/react-data-table';
|
2
|
+
export declare const useTableResize: (localStorageKey?: string) => [ColumnWidthByName, HandleResize];
|
@@ -1,29 +1,17 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import { useTableResize as libUseTableResize } from '@gravity-ui/react-data-table';
|
3
3
|
import { settingsManager } from '../../services/settings';
|
4
|
-
export const updateColumnsWidth = (columns, columnsWidthSetup) => {
|
5
|
-
return columns.map((column) => {
|
6
|
-
var _a, _b;
|
7
|
-
const resizeable = (_a = column.resizeable) !== null && _a !== void 0 ? _a : DEFAULT_RESIZEABLE;
|
8
|
-
if (!resizeable) {
|
9
|
-
return column;
|
10
|
-
}
|
11
|
-
return Object.assign(Object.assign({}, column), { width: (_b = columnsWidthSetup[column.name]) !== null && _b !== void 0 ? _b : column.width });
|
12
|
-
});
|
13
|
-
};
|
14
4
|
export const useTableResize = (localStorageKey) => {
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return setup;
|
26
|
-
});
|
5
|
+
const getSizes = React.useCallback(() => {
|
6
|
+
if (!localStorageKey) {
|
7
|
+
return {};
|
8
|
+
}
|
9
|
+
return settingsManager.readUserSettingsValue(localStorageKey, {});
|
10
|
+
}, [localStorageKey]);
|
11
|
+
const saveSizes = React.useCallback((value) => {
|
12
|
+
if (localStorageKey) {
|
13
|
+
settingsManager.setUserSettingsValue(localStorageKey, value);
|
14
|
+
}
|
27
15
|
}, [localStorageKey]);
|
28
|
-
return
|
16
|
+
return libUseTableResize({ saveSizes, getSizes });
|
29
17
|
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { ColumnAliasSuggestion, KeywordSuggestion, YqlAutocompleteResult } from '@gravity-ui/websql-autocomplete';
|
2
|
-
import
|
1
|
+
import type { ColumnAliasSuggestion, KeywordSuggestion, YQLEntity, YqlAutocompleteResult } from '@gravity-ui/websql-autocomplete';
|
2
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
3
3
|
export declare function generateColumnsSuggestion(rangeToInsertSuggestion: monaco.IRange, suggestColumns: YqlAutocompleteResult['suggestColumns'] | undefined, database: string): Promise<monaco.languages.CompletionItem[]>;
|
4
4
|
export declare function generateColumnAliasesSuggestion(rangeToInsertSuggestion: monaco.IRange, suggestColumnAliases?: ColumnAliasSuggestion[]): {
|
5
5
|
label: string;
|
@@ -17,7 +17,7 @@ export declare function generateKeywordsSuggestion(rangeToInsertSuggestion: mona
|
|
17
17
|
range: monaco.IRange;
|
18
18
|
sortText: string;
|
19
19
|
}[];
|
20
|
-
export declare function generateEntitiesSuggestion(
|
20
|
+
export declare function generateEntitiesSuggestion(rangeToInsertSuggestion: monaco.IRange, suggestEntities: YQLEntity[], database: string, prefix?: string): Promise<monaco.languages.CompletionItem[]>;
|
21
21
|
export declare function generateSimpleFunctionsSuggestion(rangeToInsertSuggestion: monaco.IRange): Promise<monaco.languages.CompletionItem[]>;
|
22
22
|
export declare function generateSimpleTypesSuggestion(rangeToInsertSuggestion: monaco.IRange): Promise<monaco.languages.CompletionItem[]>;
|
23
23
|
export declare function generateUdfSuggestion(rangeToInsertSuggestion: monaco.IRange): Promise<monaco.languages.CompletionItem[]>;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
1
2
|
import { AggregateFunctions, Pragmas, SimpleFunctions, SimpleTypes, TableFunction, Udfs, WindowFunctions, } from './constants';
|
2
3
|
const CompletionItemKind = {
|
3
4
|
Method: 0,
|
@@ -30,6 +31,27 @@ const CompletionItemKind = {
|
|
30
31
|
Snippet: 27,
|
31
32
|
};
|
32
33
|
const re = /[\s'"-/@]/;
|
34
|
+
const suggestionEntityToAutocomplete = {
|
35
|
+
externalDataSource: ['external_data_source'],
|
36
|
+
replication: ['replication'],
|
37
|
+
table: ['table'],
|
38
|
+
tableStore: ['column_store'],
|
39
|
+
topic: ['pers_queue_group'],
|
40
|
+
view: ['view'],
|
41
|
+
//TODO: add after websql-autocomplete support indexex
|
42
|
+
// index: ['table_index', 'index'],
|
43
|
+
};
|
44
|
+
const commonSuggestionEntities = ['dir', 'unknown'];
|
45
|
+
function filterAutocompleteEntities(autocompleteEntities, suggestions) {
|
46
|
+
const suggestionsSet = suggestions.reduce((acc, el) => {
|
47
|
+
const autocompleteEntity = suggestionEntityToAutocomplete[el];
|
48
|
+
if (autocompleteEntity) {
|
49
|
+
autocompleteEntity.forEach((el) => acc.add(el));
|
50
|
+
}
|
51
|
+
return acc;
|
52
|
+
}, new Set(commonSuggestionEntities));
|
53
|
+
return autocompleteEntities.filter(({ Type }) => suggestionsSet.has(Type));
|
54
|
+
}
|
33
55
|
function wrapStringToBackticks(value) {
|
34
56
|
let result = value;
|
35
57
|
if (value.match(re)) {
|
@@ -38,11 +60,29 @@ function wrapStringToBackticks(value) {
|
|
38
60
|
return result;
|
39
61
|
}
|
40
62
|
function removeBackticks(value) {
|
41
|
-
let
|
63
|
+
let sliceStart = 0;
|
64
|
+
let sliceEnd = value.length;
|
42
65
|
if (value.startsWith('`')) {
|
43
|
-
|
66
|
+
sliceStart = 1;
|
67
|
+
}
|
68
|
+
if (value.endsWith('`')) {
|
69
|
+
sliceEnd = -1;
|
70
|
+
}
|
71
|
+
return value.slice(sliceStart, sliceEnd);
|
72
|
+
}
|
73
|
+
function removeStartSlash(value) {
|
74
|
+
if (value.startsWith('/')) {
|
75
|
+
return value.slice(1);
|
76
|
+
}
|
77
|
+
return value;
|
78
|
+
}
|
79
|
+
function normalizeEntityPrefix(value = '', database) {
|
80
|
+
let cleanedValue = removeStartSlash(removeBackticks(value));
|
81
|
+
const cleanedDatabase = removeStartSlash(database);
|
82
|
+
if (cleanedValue.startsWith(cleanedDatabase)) {
|
83
|
+
cleanedValue = cleanedValue.slice(cleanedDatabase.length);
|
44
84
|
}
|
45
|
-
return
|
85
|
+
return removeStartSlash(cleanedValue);
|
46
86
|
}
|
47
87
|
const SuggestionsWeight = {
|
48
88
|
suggestTemplates: 0,
|
@@ -58,50 +98,6 @@ const SuggestionsWeight = {
|
|
58
98
|
suggestUdfs: 10,
|
59
99
|
suggestSimpleTypes: 11,
|
60
100
|
};
|
61
|
-
const KEEP_CACHE_MILLIS = 5 * 60 * 1000;
|
62
|
-
function getColumnsWithCache() {
|
63
|
-
const cache = new Map();
|
64
|
-
return async (path) => {
|
65
|
-
var _a, _b, _c, _d;
|
66
|
-
const normalizedPath = removeBackticks(path);
|
67
|
-
const existed = cache.get(path);
|
68
|
-
if (existed) {
|
69
|
-
return existed;
|
70
|
-
}
|
71
|
-
const columns = [];
|
72
|
-
const data = await window.api.getDescribe({ path: normalizedPath });
|
73
|
-
if ((data === null || data === void 0 ? void 0 : data.Status) === 'StatusSuccess') {
|
74
|
-
const desc = data.PathDescription;
|
75
|
-
if ((_a = desc === null || desc === void 0 ? void 0 : desc.Table) === null || _a === void 0 ? void 0 : _a.Columns) {
|
76
|
-
for (const c of desc.Table.Columns) {
|
77
|
-
if (c.Name) {
|
78
|
-
columns.push(c.Name);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
if ((_c = (_b = desc === null || desc === void 0 ? void 0 : desc.ColumnTableDescription) === null || _b === void 0 ? void 0 : _b.Schema) === null || _c === void 0 ? void 0 : _c.Columns) {
|
83
|
-
for (const c of desc.ColumnTableDescription.Schema.Columns) {
|
84
|
-
if (c.Name) {
|
85
|
-
columns.push(c.Name);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
if ((_d = desc === null || desc === void 0 ? void 0 : desc.ExternalTableDescription) === null || _d === void 0 ? void 0 : _d.Columns) {
|
90
|
-
for (const c of desc.ExternalTableDescription.Columns) {
|
91
|
-
if (c.Name) {
|
92
|
-
columns.push(c.Name);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
cache.set(path, columns);
|
98
|
-
setTimeout(() => {
|
99
|
-
cache.delete(path);
|
100
|
-
}, KEEP_CACHE_MILLIS);
|
101
|
-
return columns;
|
102
|
-
};
|
103
|
-
}
|
104
|
-
const getColumns = getColumnsWithCache();
|
105
101
|
function getSuggestionIndex(suggestionType) {
|
106
102
|
return SuggestionsWeight[suggestionType];
|
107
103
|
}
|
@@ -127,28 +123,63 @@ async function getSimpleTypes() {
|
|
127
123
|
return SimpleTypes;
|
128
124
|
}
|
129
125
|
export async function generateColumnsSuggestion(rangeToInsertSuggestion, suggestColumns, database) {
|
130
|
-
var _a;
|
126
|
+
var _a, _b, _c;
|
131
127
|
if (!(suggestColumns === null || suggestColumns === void 0 ? void 0 : suggestColumns.tables)) {
|
132
128
|
return [];
|
133
129
|
}
|
134
130
|
const suggestions = [];
|
135
131
|
const multi = suggestColumns.tables.length > 1;
|
136
|
-
|
132
|
+
const normalizedTableNames = (_b = (_a = suggestColumns.tables) === null || _a === void 0 ? void 0 : _a.map((entity) => {
|
137
133
|
let normalizedEntityName = removeBackticks(entity.name);
|
138
|
-
|
139
|
-
|
140
|
-
normalizedEntityName = `${database}/${normalizedEntityName}`;
|
134
|
+
if (!normalizedEntityName.endsWith('/')) {
|
135
|
+
normalizedEntityName = `${normalizedEntityName}/`;
|
141
136
|
}
|
142
|
-
|
143
|
-
|
144
|
-
|
137
|
+
return normalizeEntityPrefix(normalizedEntityName, database);
|
138
|
+
})) !== null && _b !== void 0 ? _b : [];
|
139
|
+
// remove duplicates if any
|
140
|
+
const filteredTableNames = Array.from(new Set(normalizedTableNames));
|
141
|
+
const autocompleteResponse = await window.api.autocomplete({
|
142
|
+
database,
|
143
|
+
table: filteredTableNames,
|
144
|
+
limit: 1000,
|
145
|
+
});
|
146
|
+
if (!autocompleteResponse.Success) {
|
147
|
+
return [];
|
148
|
+
}
|
149
|
+
const tableNameToAliasMap = (_c = suggestColumns.tables) === null || _c === void 0 ? void 0 : _c.reduce((acc, entity) => {
|
150
|
+
var _a;
|
151
|
+
const normalizedEntityName = normalizeEntityPrefix(removeBackticks(entity.name), database);
|
152
|
+
const aliases = (_a = acc[normalizedEntityName]) !== null && _a !== void 0 ? _a : [];
|
153
|
+
if (entity.alias) {
|
154
|
+
aliases.push(entity.alias);
|
155
|
+
}
|
156
|
+
acc[normalizedEntityName] = aliases;
|
157
|
+
return acc;
|
158
|
+
}, {});
|
159
|
+
autocompleteResponse.Result.Entities.forEach((col) => {
|
160
|
+
if (col.Type !== 'column') {
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
const normalizedName = wrapStringToBackticks(col.Name);
|
164
|
+
const normalizedParentName = normalizeEntityPrefix(col.Parent, database);
|
165
|
+
const aliases = tableNameToAliasMap[normalizedParentName];
|
166
|
+
if (aliases === null || aliases === void 0 ? void 0 : aliases.length) {
|
167
|
+
aliases.forEach((a) => {
|
168
|
+
const columnNameSuggestion = `${a}.${normalizedName}`;
|
169
|
+
suggestions.push({
|
170
|
+
label: columnNameSuggestion,
|
171
|
+
insertText: columnNameSuggestion,
|
172
|
+
kind: CompletionItemKind.Field,
|
173
|
+
detail: 'Column',
|
174
|
+
range: rangeToInsertSuggestion,
|
175
|
+
sortText: suggestionIndexToWeight(getSuggestionIndex('suggestColumns')),
|
176
|
+
});
|
177
|
+
});
|
178
|
+
}
|
179
|
+
else {
|
145
180
|
let columnNameSuggestion = normalizedName;
|
146
|
-
if (
|
147
|
-
columnNameSuggestion = `${
|
148
|
-
}
|
149
|
-
else if (multi) {
|
150
|
-
// no need to wrap entity.name to backticks, because it's already with them if needed
|
151
|
-
columnNameSuggestion = `${entity.name}.${normalizedName}`;
|
181
|
+
if (multi) {
|
182
|
+
columnNameSuggestion = `${wrapStringToBackticks(normalizedParentName)}.${normalizedName}`;
|
152
183
|
}
|
153
184
|
suggestions.push({
|
154
185
|
label: columnNameSuggestion,
|
@@ -158,8 +189,8 @@ export async function generateColumnsSuggestion(rangeToInsertSuggestion, suggest
|
|
158
189
|
range: rangeToInsertSuggestion,
|
159
190
|
sortText: suggestionIndexToWeight(getSuggestionIndex('suggestColumns')),
|
160
191
|
});
|
161
|
-
}
|
162
|
-
}
|
192
|
+
}
|
193
|
+
});
|
163
194
|
return suggestions;
|
164
195
|
}
|
165
196
|
export function generateColumnAliasesSuggestion(rangeToInsertSuggestion, suggestColumnAliases) {
|
@@ -188,7 +219,36 @@ export function generateKeywordsSuggestion(rangeToInsertSuggestion, suggestKeywo
|
|
188
219
|
sortText: suggestionIndexToWeight(getSuggestionIndex('suggestKeywords')),
|
189
220
|
}));
|
190
221
|
}
|
191
|
-
export async function generateEntitiesSuggestion(
|
222
|
+
export async function generateEntitiesSuggestion(rangeToInsertSuggestion, suggestEntities, database, prefix) {
|
223
|
+
const normalizedPrefix = normalizeEntityPrefix(prefix, database);
|
224
|
+
const data = await window.api.autocomplete({ database, prefix: normalizedPrefix, limit: 1000 });
|
225
|
+
const withBackticks = prefix === null || prefix === void 0 ? void 0 : prefix.startsWith('`');
|
226
|
+
if (data.Success) {
|
227
|
+
const filteredEntities = filterAutocompleteEntities(data.Result.Entities, suggestEntities);
|
228
|
+
return filteredEntities.reduce((acc, { Name, Type }) => {
|
229
|
+
const isDir = Type === 'dir';
|
230
|
+
const label = isDir ? `${Name}/` : Name;
|
231
|
+
let labelAsSnippet;
|
232
|
+
if (isDir && !withBackticks) {
|
233
|
+
labelAsSnippet = `\`${label}$0\``;
|
234
|
+
}
|
235
|
+
acc.push({
|
236
|
+
label,
|
237
|
+
insertText: labelAsSnippet !== null && labelAsSnippet !== void 0 ? labelAsSnippet : label,
|
238
|
+
kind: isDir ? CompletionItemKind.Folder : CompletionItemKind.Text,
|
239
|
+
insertTextRules: labelAsSnippet
|
240
|
+
? monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
|
241
|
+
: monaco.languages.CompletionItemInsertTextRule.None,
|
242
|
+
detail: Type,
|
243
|
+
range: rangeToInsertSuggestion,
|
244
|
+
command: label.endsWith('/')
|
245
|
+
? { id: 'editor.action.triggerSuggest', title: '' }
|
246
|
+
: undefined,
|
247
|
+
sortText: suggestionIndexToWeight(getSuggestionIndex('suggestEntity')),
|
248
|
+
});
|
249
|
+
return acc;
|
250
|
+
}, []);
|
251
|
+
}
|
192
252
|
return [];
|
193
253
|
}
|
194
254
|
export async function generateSimpleFunctionsSuggestion(rangeToInsertSuggestion) {
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function registerYqlLanguage(): void;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import * as monaco from 'monaco-editor';
|
2
|
+
import { LANGUAGE_YQL_ID } from './constants';
|
3
|
+
import { conf, getLanguage } from './yql';
|
4
|
+
export function registerYqlLanguage() {
|
5
|
+
monaco.languages.register({ id: LANGUAGE_YQL_ID });
|
6
|
+
monaco.languages.setMonarchTokensProvider(LANGUAGE_YQL_ID, getLanguage());
|
7
|
+
monaco.languages.setLanguageConfiguration(LANGUAGE_YQL_ID, conf);
|
8
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as monaco from 'monaco-editor';
|
2
|
+
import { LANGUAGE_YQL_ID } from './constants';
|
2
3
|
import { createProvideSuggestionsFunction } from './yqlSuggestions';
|
3
4
|
let completionProvider;
|
4
5
|
function disableCodeSuggestions() {
|
@@ -8,8 +9,8 @@ function disableCodeSuggestions() {
|
|
8
9
|
}
|
9
10
|
export function registerYQLCompletionItemProvider(database) {
|
10
11
|
disableCodeSuggestions();
|
11
|
-
completionProvider = monaco.languages.registerCompletionItemProvider(
|
12
|
-
triggerCharacters: [' ', '
|
12
|
+
completionProvider = monaco.languages.registerCompletionItemProvider(LANGUAGE_YQL_ID, {
|
13
|
+
triggerCharacters: [' ', '', ',', '.', '`', '(', '/'],
|
13
14
|
provideCompletionItems: createProvideSuggestionsFunction(database),
|
14
15
|
});
|
15
16
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type * as monaco from 'monaco-editor';
|
2
|
+
export declare const conf: monaco.languages.LanguageConfiguration;
|
3
|
+
interface LanguageOptions {
|
4
|
+
ansi?: boolean;
|
5
|
+
}
|
6
|
+
export declare function getLanguage({ ansi, }?: LanguageOptions): monaco.languages.IMonarchLanguage & Record<string, unknown>;
|
7
|
+
export {};
|