@finos/legend-query-builder 4.17.89 → 4.17.90
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.
- package/lib/components/sql-playground/SQLPlaygroundEditor.d.ts +29 -0
- package/lib/components/sql-playground/SQLPlaygroundEditor.d.ts.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundEditor.js +122 -0
- package/lib/components/sql-playground/SQLPlaygroundEditor.js.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundExplorer.d.ts +35 -0
- package/lib/components/sql-playground/SQLPlaygroundExplorer.d.ts.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundExplorer.js +157 -0
- package/lib/components/sql-playground/SQLPlaygroundExplorer.js.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundGrid.d.ts +24 -0
- package/lib/components/sql-playground/SQLPlaygroundGrid.d.ts.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundGrid.js +143 -0
- package/lib/components/sql-playground/SQLPlaygroundGrid.js.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundPanel.d.ts +20 -0
- package/lib/components/sql-playground/SQLPlaygroundPanel.d.ts.map +1 -0
- package/lib/components/sql-playground/SQLPlaygroundPanel.js +43 -0
- package/lib/components/sql-playground/SQLPlaygroundPanel.js.map +1 -0
- package/lib/data-access-overview.css +1 -1
- package/lib/index.css +17 -1
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/sql-playground/AbstractSQLPlaygroundState.d.ts +48 -0
- package/lib/stores/sql-playground/AbstractSQLPlaygroundState.d.ts.map +1 -0
- package/lib/stores/sql-playground/AbstractSQLPlaygroundState.js +125 -0
- package/lib/stores/sql-playground/AbstractSQLPlaygroundState.js.map +1 -0
- package/lib/stores/sql-playground/LegendSQLPlaygroundState.d.ts +35 -0
- package/lib/stores/sql-playground/LegendSQLPlaygroundState.d.ts.map +1 -0
- package/lib/stores/sql-playground/LegendSQLPlaygroundState.js +78 -0
- package/lib/stores/sql-playground/LegendSQLPlaygroundState.js.map +1 -0
- package/lib/stores/sql-playground/SqlPlaygroundAccessorExplorerState.d.ts +98 -0
- package/lib/stores/sql-playground/SqlPlaygroundAccessorExplorerState.d.ts.map +1 -0
- package/lib/stores/sql-playground/SqlPlaygroundAccessorExplorerState.js +370 -0
- package/lib/stores/sql-playground/SqlPlaygroundAccessorExplorerState.js.map +1 -0
- package/package.json +7 -7
- package/src/components/sql-playground/SQLPlaygroundEditor.tsx +201 -0
- package/src/components/sql-playground/SQLPlaygroundExplorer.tsx +329 -0
- package/src/components/sql-playground/SQLPlaygroundGrid.tsx +245 -0
- package/src/components/sql-playground/SQLPlaygroundPanel.tsx +170 -0
- package/src/index.ts +10 -0
- package/src/stores/sql-playground/AbstractSQLPlaygroundState.ts +156 -0
- package/src/stores/sql-playground/LegendSQLPlaygroundState.ts +120 -0
- package/src/stores/sql-playground/SqlPlaygroundAccessorExplorerState.ts +596 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { AbstractSQLPlaygroundState } from '../../stores/sql-playground/AbstractSQLPlaygroundState.js';
|
|
17
|
+
import type { SQLPlaygroundAccessorExplorerState } from '../../stores/sql-playground/SqlPlaygroundAccessorExplorerState.js';
|
|
18
|
+
export interface SQLPlaygroundPanelProps {
|
|
19
|
+
playgroundState: AbstractSQLPlaygroundState;
|
|
20
|
+
advancedMode: boolean;
|
|
21
|
+
disableDragDrop?: boolean;
|
|
22
|
+
enableDarkMode?: boolean;
|
|
23
|
+
accessorExplorerState?: SQLPlaygroundAccessorExplorerState;
|
|
24
|
+
showAccessorExplorer?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const PlaygroundSQLCodeEditor: ((props: SQLPlaygroundPanelProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=SQLPlaygroundEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLPlaygroundEditor.d.ts","sourceRoot":"","sources":["../../../src/components/sql-playground/SQLPlaygroundEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkBH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AAC5G,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,mEAAmE,CAAC;AAK5H,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,0BAA0B,CAAC;IAC5C,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,kCAAkC,CAAC;IAC3D,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAgBD,eAAO,MAAM,uBAAuB,WAC1B,uBAAuB;;CA0IhC,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { observer } from 'mobx-react-lite';
|
|
18
|
+
import { PanelDropZone } from '@finos/legend-art';
|
|
19
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
20
|
+
import { useCommands } from '@finos/legend-application';
|
|
21
|
+
import { CODE_EDITOR_LANGUAGE, CODE_EDITOR_THEME, getBaseCodeEditorOptions, } from '@finos/legend-code-editor';
|
|
22
|
+
import { editor as monacoEditorAPI, languages as monacoLanguagesAPI, } from 'monaco-editor';
|
|
23
|
+
import { useDrop } from 'react-dnd';
|
|
24
|
+
import { isString } from '@finos/legend-shared';
|
|
25
|
+
const SQL_DROP_NODE_DND_TYPE = 'SQL_DROP_NODE_DND_TYPE';
|
|
26
|
+
const toCompletionItems = (labels) => labels.map((label) => ({
|
|
27
|
+
label,
|
|
28
|
+
kind: monacoLanguagesAPI.CompletionItemKind.Keyword,
|
|
29
|
+
insertTextRules: monacoLanguagesAPI.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
30
|
+
insertText: `${label} `,
|
|
31
|
+
}));
|
|
32
|
+
export const PlaygroundSQLCodeEditor = observer((props) => {
|
|
33
|
+
const { playgroundState, disableDragDrop = false, enableDarkMode = false, } = props;
|
|
34
|
+
const codeEditorRef = useRef(null);
|
|
35
|
+
const sqlIdentifierSuggestionProviderDisposer = useRef(undefined);
|
|
36
|
+
const [editor, setEditor] = useState();
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!editor && codeEditorRef.current) {
|
|
39
|
+
const element = codeEditorRef.current;
|
|
40
|
+
playgroundState.setTheme(enableDarkMode ? 'dark' : 'light');
|
|
41
|
+
const newEditor = monacoEditorAPI.create(element, {
|
|
42
|
+
...getBaseCodeEditorOptions(),
|
|
43
|
+
theme: playgroundState.theme === 'light'
|
|
44
|
+
? CODE_EDITOR_THEME.GITHUB_LIGHT
|
|
45
|
+
: CODE_EDITOR_THEME.DEFAULT_DARK,
|
|
46
|
+
language: CODE_EDITOR_LANGUAGE.SQL,
|
|
47
|
+
padding: {
|
|
48
|
+
top: 10,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
newEditor.onDidChangeModelContent(() => {
|
|
52
|
+
const currentVal = newEditor.getValue();
|
|
53
|
+
playgroundState.setSQLText(currentVal);
|
|
54
|
+
});
|
|
55
|
+
newEditor.setModel(playgroundState.sqlEditorTextModel);
|
|
56
|
+
if (playgroundState.sqlEditorViewState) {
|
|
57
|
+
newEditor.restoreViewState(playgroundState.sqlEditorViewState);
|
|
58
|
+
}
|
|
59
|
+
newEditor.focus();
|
|
60
|
+
playgroundState.setSQLEditor(newEditor);
|
|
61
|
+
setEditor(newEditor);
|
|
62
|
+
}
|
|
63
|
+
}, [playgroundState, editor, enableDarkMode]);
|
|
64
|
+
useCommands(playgroundState);
|
|
65
|
+
if (editor) {
|
|
66
|
+
sqlIdentifierSuggestionProviderDisposer.current?.dispose();
|
|
67
|
+
sqlIdentifierSuggestionProviderDisposer.current =
|
|
68
|
+
monacoLanguagesAPI.registerCompletionItemProvider(CODE_EDITOR_LANGUAGE.SQL, {
|
|
69
|
+
triggerCharacters: [],
|
|
70
|
+
provideCompletionItems: async (model, position, context) => {
|
|
71
|
+
let suggestions = [];
|
|
72
|
+
if (context.triggerKind ===
|
|
73
|
+
monacoLanguagesAPI.CompletionTriggerKind.Invoke) {
|
|
74
|
+
const labels = playgroundState.getCodeCompletionSuggestions();
|
|
75
|
+
suggestions = suggestions.concat(toCompletionItems(labels));
|
|
76
|
+
}
|
|
77
|
+
return { suggestions };
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
useEffect(() => () => {
|
|
82
|
+
if (editor) {
|
|
83
|
+
playgroundState.setSQLEditorViewState(editor.saveViewState() ?? undefined);
|
|
84
|
+
editor.dispose();
|
|
85
|
+
sqlIdentifierSuggestionProviderDisposer.current?.dispose();
|
|
86
|
+
}
|
|
87
|
+
}, [playgroundState, editor]);
|
|
88
|
+
const handleSqlEditorNodeDrop = useCallback((item) => {
|
|
89
|
+
if (isString(item.text)) {
|
|
90
|
+
if (playgroundState.sqlEditor) {
|
|
91
|
+
const currentValue = playgroundState.sqlEditorTextModel.getValue();
|
|
92
|
+
const lines = currentValue.split('\n');
|
|
93
|
+
const position = playgroundState.sqlEditor.getPosition() ?? {
|
|
94
|
+
lineNumber: lines.length,
|
|
95
|
+
column: lines.at(-1)?.length ?? 0,
|
|
96
|
+
};
|
|
97
|
+
playgroundState.sqlEditor.executeEdits('', [
|
|
98
|
+
{
|
|
99
|
+
range: {
|
|
100
|
+
startLineNumber: position.lineNumber,
|
|
101
|
+
startColumn: position.column,
|
|
102
|
+
endLineNumber: position.lineNumber,
|
|
103
|
+
endColumn: position.column,
|
|
104
|
+
},
|
|
105
|
+
text: item.text,
|
|
106
|
+
forceMoveMarkers: true,
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
playgroundState.setSQLText(playgroundState.sqlEditorTextModel.getValue());
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [playgroundState]);
|
|
113
|
+
const [{ isDatabaseNodeDragOver }, dropConnector] = useDrop(() => ({
|
|
114
|
+
accept: [SQL_DROP_NODE_DND_TYPE],
|
|
115
|
+
drop: (item) => handleSqlEditorNodeDrop(item),
|
|
116
|
+
collect: (monitor) => ({
|
|
117
|
+
isDatabaseNodeDragOver: monitor.isOver({ shallow: true }),
|
|
118
|
+
}),
|
|
119
|
+
}), [handleSqlEditorNodeDrop]);
|
|
120
|
+
return (_jsx("div", { className: "sql-playground__code-editor", children: _jsx(PanelDropZone, { className: "sql-playground__code-editor__content", isDragOver: isDatabaseNodeDragOver, dropTargetConnector: dropConnector, disabled: disableDragDrop, children: _jsx("div", { className: "code-editor__container", children: _jsx("div", { className: "code-editor__body", ref: codeEditorRef }) }) }) }));
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=SQLPlaygroundEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLPlaygroundEditor.js","sourceRoot":"","sources":["../../../src/components/sql-playground/SQLPlaygroundEditor.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,MAAM,IAAI,eAAe,EACzB,SAAS,IAAI,kBAAkB,GAEhC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAWxD,MAAM,iBAAiB,GAAG,CACxB,MAAgB,EACqB,EAAE,CACvC,MAAM,CAAC,GAAG,CACR,CAAC,KAAK,EAAE,EAAE,CACR,CAAC;IACC,KAAK;IACL,IAAI,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO;IACnD,eAAe,E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AAI,EAAE,CAAC,IAAI,EAAQ,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC;QACnD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrB,sBAAsB,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAC1D,CAAC;KACH,CAAC,EACF,CAAC,uBAAuB,CAAC,CAC1B,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAC,6BAA6B,YAC1C,KAAC,aAAa,IACZ,SAAS,EAAC,sCAAsC,EAChD,UAAU,EAAE,sBAAsB,EAClC,mBAAmB,EAAE,aAAa,EAClC,QAAQ,EAAE,eAAe,YAEzB,cAAK,SAAS,EAAC,wBAAwB,YACrC,cAAK,SAAS,EAAC,mBAAmB,EAAC,GAAG,EAAE,aAAa,GAAI,GACrD,GACQ,GACZ,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { type TreeData } from '@finos/legend-art';
|
|
18
|
+
import { type AccessorExplorerTreeNodeData, type SQLPlaygroundAccessorExplorerState, type AccessorExplorerTreeNodeContainerProps } from '../../stores/sql-playground/SqlPlaygroundAccessorExplorerState.js';
|
|
19
|
+
import { type V1_RelationTypeColumn } from '@finos/legend-graph';
|
|
20
|
+
export declare const renderColumnTypeIcon: (type: V1_RelationTypeColumn) => React.ReactNode;
|
|
21
|
+
export declare const AccessorExplorerTreeNodeContainer: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<AccessorExplorerTreeNodeContainerProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>>;
|
|
22
|
+
export declare const SQLAccessorExplorer: ((props: {
|
|
23
|
+
accessorExplorerState: SQLPlaygroundAccessorExplorerState;
|
|
24
|
+
treeData: TreeData<AccessorExplorerTreeNodeData>;
|
|
25
|
+
isReadOnly?: boolean;
|
|
26
|
+
treeNodeContainerComponent?: React.FC<AccessorExplorerTreeNodeContainerProps> | undefined;
|
|
27
|
+
}) => import("react/jsx-runtime").JSX.Element) & {
|
|
28
|
+
displayName: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const SQLPlaygroundExplorer: ((props: {
|
|
31
|
+
accessorExplorerState: SQLPlaygroundAccessorExplorerState;
|
|
32
|
+
}) => import("react/jsx-runtime").JSX.Element) & {
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=SQLPlaygroundExplorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLPlaygroundExplorer.d.ts","sourceRoot":"","sources":["../../../src/components/sql-playground/SQLPlaygroundExplorer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,EAcL,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,4BAA4B,EAQjC,KAAK,kCAAkC,EACvC,KAAK,sCAAsC,EAC5C,MAAM,mEAAmE,CAAC;AAC3E,OAAO,EAEL,KAAK,qBAAqB,EAK3B,MAAM,qBAAqB,CAAC;AAiC7B,eAAO,MAAM,oBAAoB,GAC/B,MAAM,qBAAqB,KAC1B,KAAK,CAAC,SAwBR,CAAC;AA0CF,eAAO,MAAM,iCAAiC,6LAgD7C,CAAC;AAEF,eAAO,MAAM,mBAAmB,WACtB;IACN,qBAAqB,EAAE,kCAAkC,CAAC;IAC1D,QAAQ,EAAE,QAAQ,CAAC,4BAA4B,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EACvB,KAAK,CAAC,EAAE,CAAC,sCAAsC,CAAC,GAChD,SAAS,CAAC;CACf;;CAkDF,CAAC;AA6CF,eAAO,MAAM,qBAAqB,WACxB;IAAE,qBAAqB,EAAE,kCAAkC,CAAA;CAAE;;CAoBtE,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import React, { forwardRef, useRef } from 'react';
|
|
18
|
+
import { TreeView, StringTypeIcon, HashtagIcon, ClockIcon, QuestionCircleIcon, ChevronDownIcon, ChevronRightIcon, compareLabelFn, AccessPointIcon, PURE_FlatDataStoreIcon, PURE_DatabaseTableIcon, PURE_IngestIcon, PanelLoadingIndicator, } from '@finos/legend-art';
|
|
19
|
+
import { flowResult } from 'mobx';
|
|
20
|
+
import { AccessorExplorerTreeColumnNodeData, AccessorExplorerTreeDataProductNodeData, AccessorExplorerTreeIngestNodeData, AccessorExplorerTreeAccessPointNodeData, AccessorExplorerTreeAccessPointGroupNodeData, AccessorExplorerTreeDatasetNodeData, AccessorExplorerTreeHeaderNodeData, } from '../../stores/sql-playground/SqlPlaygroundAccessorExplorerState.js';
|
|
21
|
+
import { PRECISE_PRIMITIVE_TYPE, V1_PackageableType, PRIMITIVE_TYPE, V1_AccessPoint, extractElementNameFromPath, } from '@finos/legend-graph';
|
|
22
|
+
import { observer } from 'mobx-react-lite';
|
|
23
|
+
import { useApplicationStore } from '@finos/legend-application';
|
|
24
|
+
import { useDrag } from 'react-dnd';
|
|
25
|
+
const SQL_DROP_NODE_DND_TYPE = 'SQL_DROP_NODE_DND_TYPE';
|
|
26
|
+
const STRING_TYPE_NAMES = new Set([
|
|
27
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.VARCHAR),
|
|
28
|
+
]);
|
|
29
|
+
const NUMERIC_TYPE_NAMES = new Set([
|
|
30
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.BIG_INT),
|
|
31
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.DECIMAL),
|
|
32
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.DOUBLE),
|
|
33
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.FLOAT),
|
|
34
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.INT),
|
|
35
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.NUMERIC),
|
|
36
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.SMALL_INT),
|
|
37
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.TINY_INT),
|
|
38
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.U_BIG_INT),
|
|
39
|
+
]);
|
|
40
|
+
const DATE_TYPE_NAMES = new Set([
|
|
41
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.STRICTDATE),
|
|
42
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.STRICTTIME),
|
|
43
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.DATETIME),
|
|
44
|
+
extractElementNameFromPath(PRECISE_PRIMITIVE_TYPE.TIMESTAMP),
|
|
45
|
+
extractElementNameFromPath(PRIMITIVE_TYPE.STRICTDATE),
|
|
46
|
+
]);
|
|
47
|
+
export const renderColumnTypeIcon = (type) => {
|
|
48
|
+
const rawType = type.genericType.rawType;
|
|
49
|
+
if (rawType instanceof V1_PackageableType) {
|
|
50
|
+
const typeName = extractElementNameFromPath(rawType.fullPath);
|
|
51
|
+
if (STRING_TYPE_NAMES.has(typeName)) {
|
|
52
|
+
return (_jsx(StringTypeIcon, { className: "relation-source-tree__icon relation-source-tree__icon__string" }));
|
|
53
|
+
}
|
|
54
|
+
if (NUMERIC_TYPE_NAMES.has(typeName)) {
|
|
55
|
+
return (_jsx(HashtagIcon, { className: "relation-source-tree__icon relation-source-tree__icon__number" }));
|
|
56
|
+
}
|
|
57
|
+
if (DATE_TYPE_NAMES.has(typeName)) {
|
|
58
|
+
return (_jsx(ClockIcon, { className: "relation-source-tree__icon relation-source-tree__icon__time" }));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return (_jsx(QuestionCircleIcon, { className: "relation-source-tree__icon relation-source-tree__icon__unknown" }));
|
|
62
|
+
};
|
|
63
|
+
const getAccessorNodeIcon = (node) => {
|
|
64
|
+
if (node instanceof AccessorExplorerTreeColumnNodeData) {
|
|
65
|
+
return renderColumnTypeIcon(node.column);
|
|
66
|
+
}
|
|
67
|
+
if (node instanceof AccessorExplorerTreeDataProductNodeData) {
|
|
68
|
+
return (_jsx("div", { className: "Accessor-schema-explorer__icon--schema", children: _jsx(AccessPointIcon, {}) }));
|
|
69
|
+
}
|
|
70
|
+
if (node instanceof AccessorExplorerTreeIngestNodeData) {
|
|
71
|
+
return (_jsx("div", { className: "Accessor-schema-explorer__icon--schema", children: _jsx(PURE_IngestIcon, {}) }));
|
|
72
|
+
}
|
|
73
|
+
if (node instanceof AccessorExplorerTreeAccessPointGroupNodeData) {
|
|
74
|
+
return (_jsx("div", { className: "Accessor-schema-explorer__icon--table", children: _jsx(PURE_FlatDataStoreIcon, {}) }));
|
|
75
|
+
}
|
|
76
|
+
if (node instanceof AccessorExplorerTreeAccessPointNodeData ||
|
|
77
|
+
node instanceof AccessorExplorerTreeDatasetNodeData) {
|
|
78
|
+
return (_jsx("div", { className: "Accessor-schema-explorer__icon--table", children: _jsx(PURE_DatabaseTableIcon, {}) }));
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
export const AccessorExplorerTreeNodeContainer = observer(forwardRef(function AccessorExplorerTreeNodeContainer(props, ref) {
|
|
83
|
+
const { node, level, onNodeSelect, innerProps } = props;
|
|
84
|
+
const { toggleCheckedNode } = innerProps;
|
|
85
|
+
const isExpandable = Boolean(!node.childrenIds || node.childrenIds.length) &&
|
|
86
|
+
!(node instanceof AccessorExplorerTreeColumnNodeData);
|
|
87
|
+
const nodeExpandIcon = isExpandable ? (node.isOpen ? (_jsx(ChevronDownIcon, {})) : (_jsx(ChevronRightIcon, {}))) : (_jsx("div", {}));
|
|
88
|
+
const nodeTypeIcon = getAccessorNodeIcon(node);
|
|
89
|
+
const toggleExpandNode = () => {
|
|
90
|
+
onNodeSelect?.(node);
|
|
91
|
+
if (!isExpandable) {
|
|
92
|
+
toggleCheckedNode(node);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return (_jsxs("div", { className: `tree-view__node__container Accessor-schema-explorer__node__container Accessor-schema-explorer__node__container--level-${Math.min(level, 6)}`, ref: ref, onClick: toggleExpandNode, children: [_jsx("div", { className: "tree-view__node__icon Accessor-schema-explorer__node__icon__group", children: _jsx("div", { className: "Accessor-schema-explorer__expand-icon", children: nodeExpandIcon }) }), nodeTypeIcon && (_jsx("div", { className: "Accessor-schema-explorer__type-icon", children: nodeTypeIcon })), _jsx("div", { className: "tree-view__node__label Accessor-schema-explorer__node__label", children: node.label })] }));
|
|
96
|
+
}));
|
|
97
|
+
export const SQLAccessorExplorer = observer((props) => {
|
|
98
|
+
const { treeData, accessorExplorerState, treeNodeContainerComponent } = props;
|
|
99
|
+
const applicationStore = useApplicationStore();
|
|
100
|
+
const onNodeSelect = (node) => {
|
|
101
|
+
flowResult(accessorExplorerState.onNodeSelect(node, treeData)).catch(applicationStore.alertUnhandledError);
|
|
102
|
+
};
|
|
103
|
+
const getChildNodes = (node) => accessorExplorerState
|
|
104
|
+
.getChildNodes(node, treeData)
|
|
105
|
+
?.sort(compareLabelFn) ?? [];
|
|
106
|
+
const isPartiallySelected = (node) => {
|
|
107
|
+
if (node instanceof AccessorExplorerTreeDataProductNodeData &&
|
|
108
|
+
!node.isChecked) {
|
|
109
|
+
return (accessorExplorerState
|
|
110
|
+
.getChildNodes(node, treeData)
|
|
111
|
+
?.some((childNode) => childNode.isChecked) ?? false);
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
};
|
|
115
|
+
const toggleCheckedNode = (node) => accessorExplorerState.toggleCheckedNode(node, treeData);
|
|
116
|
+
return (_jsx(TreeView, { className: "Accessor-schema-explorer", components: {
|
|
117
|
+
TreeNodeContainer: treeNodeContainerComponent ?? AccessorExplorerTreeNodeContainer,
|
|
118
|
+
}, innerProps: {
|
|
119
|
+
toggleCheckedNode,
|
|
120
|
+
isPartiallySelected,
|
|
121
|
+
}, treeData: treeData, onNodeSelect: onNodeSelect, getChildNodes: getChildNodes }));
|
|
122
|
+
});
|
|
123
|
+
const SQLPlaygroundAccessorExplorerTreeNodeContainer = observer((props) => {
|
|
124
|
+
const { node } = props;
|
|
125
|
+
const ref = useRef(null);
|
|
126
|
+
const isDraggable = !(node instanceof AccessorExplorerTreeHeaderNodeData) &&
|
|
127
|
+
!(node instanceof AccessorExplorerTreeAccessPointGroupNodeData);
|
|
128
|
+
const dragText = node instanceof AccessorExplorerTreeColumnNodeData
|
|
129
|
+
? node.owner instanceof V1_AccessPoint
|
|
130
|
+
? `${node.parentId}.${node.label}`
|
|
131
|
+
: `${node.owner.name}.${node.label}`
|
|
132
|
+
: node instanceof AccessorExplorerTreeAccessPointNodeData
|
|
133
|
+
? `${node.dataProductPath}.${node.accessPoint.id}`
|
|
134
|
+
: node instanceof AccessorExplorerTreeDatasetNodeData
|
|
135
|
+
? `${node.parentId}.${node.dataset.name}`
|
|
136
|
+
: node instanceof AccessorExplorerTreeDataProductNodeData
|
|
137
|
+
? node.id
|
|
138
|
+
: node instanceof AccessorExplorerTreeIngestNodeData
|
|
139
|
+
? node.id
|
|
140
|
+
: node.id;
|
|
141
|
+
const [, dragConnector] = useDrag(() => ({
|
|
142
|
+
type: SQL_DROP_NODE_DND_TYPE,
|
|
143
|
+
item: {
|
|
144
|
+
text: dragText,
|
|
145
|
+
},
|
|
146
|
+
canDrag: isDraggable,
|
|
147
|
+
}), [node, isDraggable]);
|
|
148
|
+
if (isDraggable) {
|
|
149
|
+
dragConnector(ref);
|
|
150
|
+
}
|
|
151
|
+
return _jsx(AccessorExplorerTreeNodeContainer, { ...props, ref: ref });
|
|
152
|
+
});
|
|
153
|
+
export const SQLPlaygroundExplorer = observer((props) => {
|
|
154
|
+
const { accessorExplorerState } = props;
|
|
155
|
+
return (_jsxs("div", { className: "sql-playground__explorer", children: [_jsx(PanelLoadingIndicator, { isLoading: Boolean(accessorExplorerState.isGeneratingAccessor) }), accessorExplorerState.treeData && (_jsx(SQLAccessorExplorer, { treeData: accessorExplorerState.treeData, accessorExplorerState: accessorExplorerState, treeNodeContainerComponent: SQLPlaygroundAccessorExplorerTreeNodeContainer }))] }));
|
|
156
|
+
});
|
|
157
|
+
//# sourceMappingURL=SQLPlaygroundExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQL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E;IACvE,MAAM,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IAExC,OAAO,CACL,eAAK,SAAS,EAAC,0BAA0B,aACvC,KAAC,qBAAqB,IACpB,SAAS,EAAE,OAAO,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,GAC9D,EACD,qBAAqB,CAAC,QAAQ,IAAI,CACjC,KAAC,mBAAmB,IAClB,QAAQ,EAAE,qBAAqB,CAAC,QAAQ,EACxC,qBAAqB,EAAE,qBAAqB,EAC5C,0BAA0B,EACxB,8CAA8C,GAEhD,CACH,IACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PlayGroundSQLExecutionResultGrid: ((props: {
|
|
17
|
+
result: string;
|
|
18
|
+
useAdvancedGrid?: boolean;
|
|
19
|
+
useLocalMode?: boolean;
|
|
20
|
+
enableDarkMode?: boolean;
|
|
21
|
+
}) => import("react/jsx-runtime").JSX.Element) & {
|
|
22
|
+
displayName: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=SQLPlaygroundGrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLPlaygroundGrid.d.ts","sourceRoot":"","sources":["../../../src/components/sql-playground/SQLPlaygroundGrid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0EH,eAAO,MAAM,gCAAgC,WACnC;IACN,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;;CAsJF,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { observer } from 'mobx-react-lite';
|
|
18
|
+
import { BlankPanelContent, clsx } from '@finos/legend-art';
|
|
19
|
+
import { useCallback } from 'react';
|
|
20
|
+
import { at, isString, parseCSVString, isNonNullable, isNumber, isValidURL, } from '@finos/legend-shared';
|
|
21
|
+
import { DataGrid, } from '@finos/legend-lego/data-grid';
|
|
22
|
+
const parseExecutionResultData = (data) => {
|
|
23
|
+
const lines = data.split('\n').filter((line) => line.trim().length);
|
|
24
|
+
if (lines.length) {
|
|
25
|
+
const columns = parseCSVString(at(lines, 0)) ?? [];
|
|
26
|
+
const rowData = lines
|
|
27
|
+
.slice(1)
|
|
28
|
+
.map((item) => {
|
|
29
|
+
const rowItems = parseCSVString(item);
|
|
30
|
+
if (!rowItems) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const row = {};
|
|
34
|
+
columns.forEach((column, idx) => {
|
|
35
|
+
row[column] = rowItems[idx] ?? '';
|
|
36
|
+
});
|
|
37
|
+
return row;
|
|
38
|
+
})
|
|
39
|
+
.filter(isNonNullable);
|
|
40
|
+
return { rowData, columns };
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
44
|
+
const TDSResultCellRenderer = observer((params) => {
|
|
45
|
+
const cellValue = params.value;
|
|
46
|
+
const formattedCellValue = () => {
|
|
47
|
+
if (isNumber(cellValue)) {
|
|
48
|
+
return Intl.NumberFormat('en-US', {
|
|
49
|
+
maximumFractionDigits: 4,
|
|
50
|
+
}).format(Number(cellValue));
|
|
51
|
+
}
|
|
52
|
+
return cellValue;
|
|
53
|
+
};
|
|
54
|
+
const cellValueUrlLink = isString(cellValue) && isValidURL(cellValue) ? cellValue : undefined;
|
|
55
|
+
return (_jsx("div", { className: clsx('query-builder__result__values__table__cell'), children: cellValueUrlLink ? (_jsx("a", { href: cellValueUrlLink, target: "_blank", rel: "noreferrer", children: cellValueUrlLink })) : (_jsx("span", { children: formattedCellValue() })) }));
|
|
56
|
+
});
|
|
57
|
+
export const PlayGroundSQLExecutionResultGrid = observer((props) => {
|
|
58
|
+
const { result, useAdvancedGrid, useLocalMode, enableDarkMode = false, } = props;
|
|
59
|
+
const data = parseExecutionResultData(result);
|
|
60
|
+
const darkMode = enableDarkMode;
|
|
61
|
+
if (!data) {
|
|
62
|
+
return (_jsx(BlankPanelContent, { children: `Can't parse result, displaying raw form:\n${result}` }));
|
|
63
|
+
}
|
|
64
|
+
if (useAdvancedGrid) {
|
|
65
|
+
if (useLocalMode) {
|
|
66
|
+
const localcolDefs = data.columns.map((colName) => ({
|
|
67
|
+
minWidth: 150,
|
|
68
|
+
sortable: true,
|
|
69
|
+
resizable: true,
|
|
70
|
+
field: colName,
|
|
71
|
+
flex: 1,
|
|
72
|
+
enablePivot: true,
|
|
73
|
+
enableRowGroup: true,
|
|
74
|
+
enableValue: true,
|
|
75
|
+
allowedAggFuncs: ['count'],
|
|
76
|
+
}));
|
|
77
|
+
return (_jsx("div", { className: clsx('sql-playground__result__grid', {
|
|
78
|
+
'ag-theme-balham': !darkMode,
|
|
79
|
+
'ag-theme-balham-dark': darkMode,
|
|
80
|
+
}), children: _jsx(DataGrid, { rowData: data.rowData, gridOptions: {
|
|
81
|
+
suppressScrollOnNewData: true,
|
|
82
|
+
rowSelection: {
|
|
83
|
+
mode: 'multiRow',
|
|
84
|
+
checkboxes: false,
|
|
85
|
+
headerCheckbox: false,
|
|
86
|
+
},
|
|
87
|
+
pivotPanelShow: 'always',
|
|
88
|
+
rowGroupPanelShow: 'always',
|
|
89
|
+
cellSelection: true,
|
|
90
|
+
},
|
|
91
|
+
// NOTE: when column definition changed, we need to force refresh the cell to make sure the cell renderer is updated
|
|
92
|
+
// See https://stackoverflow.com/questions/56341073/how-to-refresh-an-ag-grid-when-a-change-occurs-inside-a-custom-cell-renderer-com
|
|
93
|
+
onRowDataUpdated: (params) => {
|
|
94
|
+
params.api.refreshCells({ force: true });
|
|
95
|
+
}, suppressFieldDotNotation: true, suppressContextMenu: false, columnDefs: localcolDefs, sideBar: ['columns', 'filters'] }) }));
|
|
96
|
+
}
|
|
97
|
+
const colDefs = data.columns.map((colName) => ({
|
|
98
|
+
minWidth: 150,
|
|
99
|
+
sortable: true,
|
|
100
|
+
resizable: true,
|
|
101
|
+
field: colName,
|
|
102
|
+
flex: 1,
|
|
103
|
+
cellRenderer: TDSResultCellRenderer,
|
|
104
|
+
filter: true,
|
|
105
|
+
}));
|
|
106
|
+
const getContextMenuItems = useCallback((params) => [
|
|
107
|
+
'copy',
|
|
108
|
+
'copyWithHeaders',
|
|
109
|
+
{
|
|
110
|
+
name: 'Copy Row Value',
|
|
111
|
+
action: () => {
|
|
112
|
+
params.api.copySelectedRowsToClipboard();
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
], []);
|
|
116
|
+
return (_jsx("div", { className: clsx('sql-playground__result__grid', {
|
|
117
|
+
'ag-theme-balham': !darkMode,
|
|
118
|
+
'ag-theme-balham-dark': darkMode,
|
|
119
|
+
}), children: _jsx(DataGrid, { rowData: data.rowData, overlayNoRowsTemplate: `<div class="sql-playground__result__grid--empty">No results</div>`, gridOptions: {
|
|
120
|
+
suppressScrollOnNewData: true,
|
|
121
|
+
rowSelection: {
|
|
122
|
+
mode: 'multiRow',
|
|
123
|
+
checkboxes: false,
|
|
124
|
+
headerCheckbox: false,
|
|
125
|
+
},
|
|
126
|
+
cellSelection: true,
|
|
127
|
+
}, onRowDataUpdated: (params) => {
|
|
128
|
+
params.api.refreshCells({ force: true });
|
|
129
|
+
}, suppressFieldDotNotation: true, suppressClipboardPaste: false, suppressContextMenu: false, columnDefs: colDefs, getContextMenuItems: (params) => getContextMenuItems(params) }) }));
|
|
130
|
+
}
|
|
131
|
+
return (_jsx("div", { className: clsx('sql-playground__result__grid', {
|
|
132
|
+
'ag-theme-balham': !darkMode,
|
|
133
|
+
'ag-theme-balham-dark': darkMode,
|
|
134
|
+
}), children: _jsx(DataGrid, { rowData: data.rowData, overlayNoRowsTemplate: `<div class="sql-playground__result__grid--empty">No results</div>`, alwaysShowVerticalScroll: true, suppressFieldDotNotation: true, columnDefs: data.columns.map((column) => ({
|
|
135
|
+
minWidth: 150,
|
|
136
|
+
sortable: true,
|
|
137
|
+
resizable: true,
|
|
138
|
+
headerName: column,
|
|
139
|
+
field: column,
|
|
140
|
+
flex: 1,
|
|
141
|
+
})) }) }));
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=SQLPlaygroundGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLPlaygroundGrid.js","sourceRoot":"","sources":["../../../src/components/sql-playground/SQLPlaygroundGrid.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;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,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAC5D,GACE,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,cACE,SAAS,EAAE,IAAI,CAAC,8BAA8B,EAAE;YAC9C,iBAAiB,EAAE,CAAC,QAAQ;YAC5B,sBAAsB,EAAE,QAAQ;SACjC,CAAC,YAEF,KAAC,QAAQ,IACP,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,qBAAqB,EAAE,mEAAmE,EAC1F,wBAAwB,EAAE,IAAI,EAC9B,wBAAwB,EAAE,IAAI,EAC9B,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBACxC,QAAQ,EAAE,GAAG;gBACb,QAAQ,EAAE,IAAI;gBACd,SAAS,EAAE,IAAI;gBACf,UAAU,EAAE,MAAM;gBAClB,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,CAAC;aACR,CAAC,CAAC,GACH,GACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { type SQLPlaygroundPanelProps } from './SQLPlaygroundEditor.js';
|
|
17
|
+
export declare const SQLPlaygroundEditorResultPanel: ((props: SQLPlaygroundPanelProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=SQLPlaygroundPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLPlaygroundPanel.d.ts","sourceRoot":"","sources":["../../../src/components/sql-playground/SQLPlaygroundPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,8BAA8B,WACjC,uBAAuB;;CAqIhC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { observer } from 'mobx-react-lite';
|
|
18
|
+
import { CheckSquareIcon, clsx, PanelLoadingIndicator, PlayIcon, ResizablePanel, ResizablePanelGroup, ResizablePanelSplitter, SquareIcon, } from '@finos/legend-art';
|
|
19
|
+
import { prettyDuration } from '@finos/legend-shared';
|
|
20
|
+
import { PlaygroundSQLCodeEditor, } from './SQLPlaygroundEditor.js';
|
|
21
|
+
import { PlayGroundSQLExecutionResultGrid } from './SQLPlaygroundGrid.js';
|
|
22
|
+
import { SQLPlaygroundExplorer } from './SQLPlaygroundExplorer.js';
|
|
23
|
+
export const SQLPlaygroundEditorResultPanel = observer((props) => {
|
|
24
|
+
const { playgroundState, advancedMode, disableDragDrop = false, enableDarkMode = false, accessorExplorerState, showAccessorExplorer = false, } = props;
|
|
25
|
+
const executeRawSQL = () => {
|
|
26
|
+
playgroundState.executeRawSQL();
|
|
27
|
+
};
|
|
28
|
+
const resultDescription = playgroundState.sqlExecutionResult
|
|
29
|
+
? `query ran in ${prettyDuration(playgroundState.sqlExecutionResult.sqlDuration, {
|
|
30
|
+
ms: true,
|
|
31
|
+
})}`
|
|
32
|
+
: undefined;
|
|
33
|
+
const toggleLocalMode = () => {
|
|
34
|
+
playgroundState.toggleIsLocalModeEnabled();
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs(ResizablePanelGroup, { orientation: "vertical", children: [showAccessorExplorer && accessorExplorerState && (_jsxs(ResizablePanel, { size: 280, minSize: 240, maxSize: 600, children: [_jsx(PanelLoadingIndicator, { isLoading: accessorExplorerState.isGeneratingAccessor }), accessorExplorerState.treeData && (_jsx(SQLPlaygroundExplorer, { accessorExplorerState: accessorExplorerState }))] })), _jsx(ResizablePanelSplitter, {}), _jsx(ResizablePanel, { children: _jsx("div", { className: "panel sql-playground__sql-editor", children: _jsxs(ResizablePanelGroup, { orientation: "horizontal", children: [_jsx(ResizablePanel, { children: _jsx(PlaygroundSQLCodeEditor, { playgroundState: playgroundState, advancedMode: advancedMode, disableDragDrop: disableDragDrop, enableDarkMode: enableDarkMode }) }), _jsx(ResizablePanelSplitter, {}), _jsxs(ResizablePanel, { size: 300, children: [_jsxs("div", { className: clsx('panel__header', {
|
|
37
|
+
'panel__header--dark': enableDarkMode,
|
|
38
|
+
}), children: [_jsxs("div", { className: "panel__header__title", children: [_jsx("div", { className: "panel__header__title__label", children: "result" }), playgroundState.executeRawSQLState.isInProgress && (_jsx("div", { className: "panel__header__title__label__status", children: "Running SQL..." })), _jsx("div", { className: "query-builder__result__analytics", children: !playgroundState.executeRawSQLState.isInProgress &&
|
|
39
|
+
(resultDescription ?? '') })] }), _jsx("div", { className: !enableDarkMode ? 'light-mode' : '', children: _jsxs("div", { className: "panel__header__actions query-builder__result__header__actions", children: [advancedMode && (_jsxs("div", { className: "query-builder__result__advanced__mode", children: [_jsx("div", { className: "query-builder__result__advanced__mode__label", children: "Local Mode" }), _jsx("button", { "aria-label": "local mode", className: clsx('query-builder__result__advanced__mode__toggler__btn', {
|
|
40
|
+
'query-builder__result__advanced__mode__toggler__btn--toggled': playgroundState.isLocalModeEnabled,
|
|
41
|
+
}), onClick: toggleLocalMode, tabIndex: -1, children: playgroundState.isLocalModeEnabled ? (_jsx(CheckSquareIcon, {})) : (_jsx(SquareIcon, {})) })] })), _jsx("div", { className: "query-builder__result__execute-btn btn__dropdown-combo btn__dropdown-combo--primary", children: _jsxs("button", { className: "btn__dropdown-combo__label", onClick: executeRawSQL, disabled: playgroundState.executeRawSQLState.isInProgress, tabIndex: -1, children: [_jsx(PlayIcon, { className: "btn__dropdown-combo__label__icon" }), _jsx("div", { className: "btn__dropdown-combo__label__title", children: "Run Query" })] }) })] }) })] }), playgroundState.sqlExecutionResult !== undefined && (_jsx(PlayGroundSQLExecutionResultGrid, { result: playgroundState.sqlExecutionResult.value, useAdvancedGrid: advancedMode, useLocalMode: playgroundState.isLocalModeEnabled, enableDarkMode: enableDarkMode })), playgroundState.sqlExecutionResult === undefined && _jsx("div", {})] })] }) }) })] }));
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=SQLPlaygroundPanel.js.map
|