@marimo-team/frontend 0.23.16-dev4 → 0.23.16-dev40
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/dist/assets/{CellStatus-BalYv0pK.js → CellStatus-C6Cj3oJc.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-DI7mV-Gw.js → ConnectedDataExplorerComponent-CMaZapRd.js} +1 -1
- package/dist/assets/{ErrorBoundary-C7_5jjWi.js → ErrorBoundary-DzTD8LVq.js} +1 -1
- package/dist/assets/{ImperativeModal-BIavOiUv.js → ImperativeModal-fY-ZfT0b.js} +1 -1
- package/dist/assets/{JsonOutput-CkCD-FgM.js → JsonOutput-CyzvjIjx.js} +12 -12
- package/dist/assets/{LazyAnyLanguageCodeMirror-sVm_hz8A.js → LazyAnyLanguageCodeMirror-B2JvSXP-.js} +2 -2
- package/dist/assets/{MarimoErrorOutput-DO2k2fA5.js → MarimoErrorOutput-CIuzXFFo.js} +4 -4
- package/dist/assets/{RSPContexts-CgC81f0I.js → RSPContexts-WiCgGm__.js} +1 -1
- package/dist/assets/RenderHTML-Cd-PP5ZR.js +1 -0
- package/dist/assets/{RunButton-BKRupqr7.js → RunButton-CnYWedW4.js} +1 -1
- package/dist/assets/{add-cell-with-ai-CEZtaZCK.js → add-cell-with-ai-ByOBQT99.js} +8 -8
- package/dist/assets/add-connection-dialog-C97ylgk0.js +170 -0
- package/dist/assets/{agent-panel-CHB6t7Zy.js → agent-panel-Dxo9WUKV.js} +5 -5
- package/dist/assets/ai-model-dropdown-Bvqy98cI.js +5 -0
- package/dist/assets/{alert-dialog-BXegNC0I.js → alert-dialog-Bb8Lz8ko.js} +1 -1
- package/dist/assets/{any-language-editor-DCpZRrpx.js → any-language-editor--tRHs8C_.js} +1 -1
- package/dist/assets/{app-config-button-NrM9ywXA.js → app-config-button-v1lG63C2.js} +1 -1
- package/dist/assets/{button-eIihcbUw.js → button-DDGiD1NW.js} +1 -1
- package/dist/assets/{cache-panel-wllSTlbM.js → cache-panel-DcQUeUpg.js} +1 -1
- package/dist/assets/{capabilities-B09j1Eor.js → capabilities-DoEg0XwL.js} +1 -1
- package/dist/assets/{cell-editor-B5JVq7_q.js → cell-editor-BKrHbyX_.js} +16 -16
- package/dist/assets/cell-link-w5IbCQV4.js +1 -0
- package/dist/assets/cells-DzyDERZy.js +235 -0
- package/dist/assets/{chat-display-BG08ltQ3.js → chat-display-Ccgk4vbE.js} +1 -1
- package/dist/assets/{chat-panel-P2CzCtXJ.js → chat-panel--53TIc3t.js} +4 -4
- package/dist/assets/{chat-ui-fAJZAoTD.js → chat-ui-B5rBxgsw.js} +4 -4
- package/dist/assets/{column-preview-Dne1dIt0.js → column-preview-Cb8R9kfl.js} +1 -1
- package/dist/assets/{command-CAJLPEBq.js → command-Dqxie4gq.js} +1 -1
- package/dist/assets/{command-palette-iOCqUIs1.js → command-palette-B1S9PjZi.js} +1 -1
- package/dist/assets/{common-CD6Mj8n6.js → common-CJ3baa6D.js} +1 -1
- package/dist/assets/components-DpUIWGaj.js +1 -0
- package/dist/assets/config-B-Q7J_6d.js +1 -0
- package/dist/assets/{config-COUOIPEq.js → config-BJVx3eBW.js} +1 -1
- package/dist/assets/{copy-BtTOqPTS.js → copy-Bxb1_Gtw.js} +1 -1
- package/dist/assets/{copy-icon-C2pG0ZNK.js → copy-icon-neDQUo4Q.js} +1 -1
- package/dist/assets/{createReducer-C7kZ8zEe.js → createReducer-DGx5Af-C.js} +1 -1
- package/dist/assets/{datasource-ySAiC9gr.js → datasource-D_VcQMEn.js} +2 -2
- package/dist/assets/{dates-D-kIKDYA.js → dates-C2LWzsCZ.js} +1 -1
- package/dist/assets/{dependency-graph-panel-BF23EwcD.js → dependency-graph-panel-DY5lvPDx.js} +3 -3
- package/dist/assets/{dialog-D1DEsRZ2.js → dialog-BCVepWLJ.js} +1 -1
- package/dist/assets/{dist-ByVeMWkr.js → dist-BLN8PNJV.js} +1 -1
- package/dist/assets/dist-CiVShZKM.js +2 -0
- package/dist/assets/{documentation-panel-e9Fi9R7e.js → documentation-panel-CGhwxsXK.js} +1 -1
- package/dist/assets/download-DpS57jyt.js +9 -0
- package/dist/assets/{dropdown-menu-BFZLnWeO.js → dropdown-menu-dHmZR8bI.js} +1 -1
- package/dist/assets/{edit-page-7X3HYey7.js → edit-page-DA765yQV.js} +6 -6
- package/dist/assets/{error-banner-B6eIlxzg.js → error-banner-BSxEOIn2.js} +1 -1
- package/dist/assets/error-entries-CTYMwfsh.js +8 -0
- package/dist/assets/{error-panel-DdsUL6b7.js → error-panel-DGAkG5kW.js} +1 -1
- package/dist/assets/{es-1D83cgiu.js → es-gYgfF8y5.js} +1 -1
- package/dist/assets/{esm-BL7jQmzn.js → esm-B30N1GS0.js} +1 -1
- package/dist/assets/{field-BeZbVzXA.js → field-BsxD35VE.js} +1 -1
- package/dist/assets/{file-explorer-panel-Ntq1-VbF.js → file-explorer-panel-BKUo-MDh.js} +3 -3
- package/dist/assets/{file-icons-Cb54mIL8.js → file-icons-DfWENcb8.js} +1 -1
- package/dist/assets/{file-name-input-BWFcK1ey.js → file-name-input-CNVZtm5K.js} +1 -1
- package/dist/assets/floating-outline-LitP0wCD.js +1 -0
- package/dist/assets/focus-CNKbm-Xz.js +1 -0
- package/dist/assets/{form-B6BkSCJb.js → form-nHzLTU1m.js} +2 -2
- package/dist/assets/{formats-ClEFGPy-.js → formats-DzmLpc9A.js} +1 -1
- package/dist/assets/{formatting-B_41gSF5.js → formatting-CDf6w1Kt.js} +1 -1
- package/dist/assets/{fullscreen-dUjPYOmm.js → fullscreen-CTDqNQr6.js} +1 -1
- package/dist/assets/{gallery-page-CWQQAYpa.js → gallery-page-CJ3ms1Hn.js} +1 -1
- package/dist/assets/{glide-data-editor-lMARFWHS.js → glide-data-editor-j2igs9Y_.js} +1 -1
- package/dist/assets/home-page-DM9Z_IJ7.js +4 -0
- package/dist/assets/{html-to-image-CwmX28T9.js → html-to-image-JaxFFZcr.js} +2 -2
- package/dist/assets/index-C7_REKh1.js +38 -0
- package/dist/assets/index-D6Dp_PFj.css +2 -0
- package/dist/assets/{input-CqrUjynb.js → input-JxFwu-3G.js} +1 -1
- package/dist/assets/kiosk-mode-BumOFEtY.js +1 -0
- package/dist/assets/{label-BElwWzf0.js → label-CqjrpwRC.js} +1 -1
- package/dist/assets/{layout-CUlZijwG.js → layout-B29hqiiK.js} +5 -5
- package/dist/assets/{links-CToBjIIj.js → links-CZr5bjvo.js} +1 -1
- package/dist/assets/logs-panel-CQRPYS8j.js +1 -0
- package/dist/assets/{markdown-renderer-QvXG0CRk.js → markdown-renderer-sEayY9-m.js} +2 -2
- package/dist/assets/{menu-items-DbSLBfXR.js → menu-items-CCi6aOPm.js} +1 -1
- package/dist/assets/{mermaid-Bh0flEIb.js → mermaid-CYN0wOyG.js} +1 -1
- package/dist/assets/{name-cell-input-C6cukQ9k.js → name-cell-input-B-aj1KH3.js} +1 -1
- package/dist/assets/node-sql-parser-Si4oZ2P-.js +68 -0
- package/dist/assets/{numbers-CeeaFKqu.js → numbers-rmawRqQP.js} +1 -1
- package/dist/assets/{outline-panel-BPlg9_CE.js → outline-panel-BOryk60D.js} +1 -1
- package/dist/assets/{packages-panel-BzQF60rG.js → packages-panel-DoYDLty3.js} +1 -1
- package/dist/assets/pair-with-agent-modal-BCRSACei.js +4 -0
- package/dist/assets/panels-Bb4fIHgH.js +4 -0
- package/dist/assets/{popover-DrHQ3KEt.js → popover-Bcz1Zikb.js} +1 -1
- package/dist/assets/process-output-d-LEMtGI.js +1 -0
- package/dist/assets/{radio-group-CLBjGkt5.js → radio-group-DfioQthW.js} +1 -1
- package/dist/assets/{readonly-code-display-D63oRtBP.js → readonly-code-display-C9fu8tvK.js} +1 -1
- package/dist/assets/{readonly-python-code-CW_G5e4E.js → readonly-python-code-DHxOnQGj.js} +1 -1
- package/dist/assets/{renderShortcut-BZLr8D7H.js → renderShortcut-Bl8_FVn8.js} +1 -1
- package/dist/assets/{reveal-component-BLMTmd8T.js → reveal-component-5jf0W625.js} +60 -60
- package/dist/assets/{run-page-B6pgDYEJ.js → run-page-BMKx9ld_.js} +1 -1
- package/dist/assets/{runs-D51Xwrsk.js → runs-DBTXqJHS.js} +1 -1
- package/dist/assets/scratchpad-panel-C8z8vzBX.js +1 -0
- package/dist/assets/{scroll-to-bottom-button-Cgr10kaJ.js → scroll-to-bottom-button-C8yfT4wq.js} +1 -1
- package/dist/assets/{secrets-panel-Cc5KDBk6.js → secrets-panel-6J6wcuVR.js} +1 -1
- package/dist/assets/{select-B5TFNjmU.js → select-BP75_5jJ.js} +1 -1
- package/dist/assets/{session-CEFnN9Cq.js → session-BmukRjSi.js} +1 -1
- package/dist/assets/{session-panel-Y0Oon0sD.js → session-panel-BVVk-02h.js} +1 -1
- package/dist/assets/{share-CYpcX4N4.js → share-852X_cqy.js} +1 -1
- package/dist/assets/{skeleton-D3QPxqWC.js → skeleton-Bubr9pIj.js} +1 -1
- package/dist/assets/slides-DkEgzTJB.css +1 -0
- package/dist/assets/{snippets-panel-CXpGflMO.js → snippets-panel-U2-iok-c.js} +1 -1
- package/dist/assets/{spec-CzqcmYQk.js → spec-C7opZZRp.js} +1 -1
- package/dist/assets/{state-BvdK8eiw.js → state-D10U2MwA.js} +1 -1
- package/dist/assets/{state-WBgc7MiA.js → state-DDag0B_B.js} +1 -1
- package/dist/assets/state-DtziTd1T.js +3 -0
- package/dist/assets/{state-DBzEQtWz.js → state-DxQhUsG9.js} +1 -1
- package/dist/assets/{strings-Djnbwmfl.js → strings--BknHX9C.js} +1 -1
- package/dist/assets/{swiper-component-DInvCxhI.js → swiper-component-g8EXE911.js} +1 -1
- package/dist/assets/switch-OVajJBPR.js +1 -0
- package/dist/assets/{terminal-D3IQBBYo.js → terminal-217O8hlZ.js} +1 -1
- package/dist/assets/{textarea-CpFfEUet.js → textarea-Bmzmbbpo.js} +1 -1
- package/dist/assets/{tooltip-CFX4fYHU.js → tooltip-4bZlU7jl.js} +1 -1
- package/dist/assets/{tooltip-HLb6RxVp.js → tooltip-B7U4xkIN.js} +1 -1
- package/dist/assets/{tracing-CKn3gWHw.js → tracing-B5XFvMmV.js} +1 -1
- package/dist/assets/{tracing-panel-BU-o_LCd.js → tracing-panel-DnR2bYDe.js} +2 -2
- package/dist/assets/{tree-actions-CsC2XmGo.js → tree-actions-Dx9CDaxV.js} +1 -1
- package/dist/assets/{useBoolean-D89u30n-.js → useBoolean-CFj86iac.js} +1 -1
- package/dist/assets/useCellActionButton-DypR3yDt.js +1 -0
- package/dist/assets/{useDeleteCell-EPH4kcG7.js → useDeleteCell-vMXAr3rY.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-CZnK7N2L.js → useDependencyPanelTab-CwdwKf7A.js} +1 -1
- package/dist/assets/useEventListener-C0195JsF.js +1 -0
- package/dist/assets/{useHotkey-DIuRH8Wu.js → useHotkey-DLZvrRZT.js} +1 -1
- package/dist/assets/{useIframeCapabilities-Ccb4fvKc.js → useIframeCapabilities-j6fR_dBA.js} +1 -1
- package/dist/assets/{useInstallPackage-BRbUAUFn.js → useInstallPackage-WiYBwhUO.js} +1 -1
- package/dist/assets/{useInterval-CC0vKpWm.js → useInterval-CWBTUy5W.js} +1 -1
- package/dist/assets/useNotebookActions-jWIcmpv0.js +12 -0
- package/dist/assets/{useRunCells-CSSF_mJ0.js → useRunCells-C2dvU2jA.js} +1 -1
- package/dist/assets/{useSplitCell-9Qz93yPZ.js → useSplitCell-C1tubdNi.js} +1 -1
- package/dist/assets/{useTheme-KXqAyDPC.js → useTheme-Bxv9B31g.js} +1 -1
- package/dist/assets/{utils-Z80SV4_d.js → utils-BWBBpCkT.js} +1 -1
- package/dist/assets/{vega-component-Cie3ag_T.js → vega-component-Db8KjZJG.js} +1 -1
- package/dist/assets/{write-secret-modal-DEEn7sZV.js → write-secret-modal-3-v-dHVj.js} +1 -1
- package/dist/index.html +68 -68
- package/package.json +3 -4
- package/src/__mocks__/requests.ts +45 -4
- package/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap +174 -21
- package/src/components/data-table/__tests__/chart-spec-model.test.ts +102 -1
- package/src/components/data-table/column-summary/chart-spec-model.tsx +163 -103
- package/src/components/data-table/column-summary/legacy-chart-spec.ts +15 -7
- package/src/components/data-table/column-summary/utils.ts +26 -7
- package/src/components/data-table/types.ts +1 -1
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +99 -18
- package/src/components/editor/actions/__tests__/pdf-export.test.ts +0 -4
- package/src/components/editor/actions/pair-with-agent-commands.ts +21 -10
- package/src/components/editor/actions/pair-with-agent-modal.tsx +2 -2
- package/src/components/editor/actions/pdf-export.ts +1 -4
- package/src/components/editor/actions/useNotebookActions.tsx +7 -13
- package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
- package/src/components/editor/cell/code/cell-editor.tsx +13 -7
- package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +25 -0
- package/src/components/editor/chrome/panels/logs-panel.tsx +12 -2
- package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +50 -0
- package/src/components/editor/connections/storage/__tests__/as-code.test.ts +87 -8
- package/src/components/editor/connections/storage/as-code.ts +40 -21
- package/src/components/editor/connections/storage/schemas.ts +83 -42
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +1 -1
- package/src/components/slides/__tests__/cell-output-block.test.tsx +40 -0
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +33 -0
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +198 -0
- package/src/components/slides/reveal-component.tsx +25 -19
- package/src/components/slides/slide-cell-view.tsx +1 -1
- package/src/components/slides/slide-scroll-hint.tsx +161 -0
- package/src/components/slides/slides.css +4 -2
- package/src/components/static-html/share-modal.tsx +1 -1
- package/src/components/ui/input.tsx +1 -1
- package/src/core/cells/__tests__/cells.test.ts +12 -2
- package/src/core/cells/__tests__/logs.test.ts +5 -5
- package/src/core/cells/cells.ts +17 -4
- package/src/core/cells/document-changes.ts +1 -0
- package/src/core/cells/logs.ts +14 -4
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +396 -100
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +128 -540
- package/src/core/codemirror/copilot/language-server.ts +182 -70
- package/src/core/codemirror/copilot/transport.ts +15 -207
- package/src/core/codemirror/copilot/types.ts +9 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -30
- package/src/core/codemirror/find-replace/navigate.ts +2 -0
- package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +24 -3
- package/src/core/codemirror/go-to-definition/commands.ts +3 -0
- package/src/core/codemirror/keymaps/__tests__/keymaps.test.ts +31 -2
- package/src/core/codemirror/keymaps/keymaps.ts +12 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +443 -61
- package/src/core/codemirror/language/languages/python.ts +23 -11
- package/src/core/codemirror/language/languages/sql/completion-store.ts +5 -1
- package/src/core/codemirror/language/languages/sql/sql.ts +210 -3
- package/src/core/codemirror/lsp/__tests__/federated-lsp.test.ts +161 -0
- package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +53 -0
- package/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts +25 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +598 -156
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +112 -0
- package/src/core/codemirror/lsp/federated-lsp.ts +76 -23
- package/src/core/codemirror/lsp/log-messages.ts +37 -0
- package/src/core/codemirror/lsp/normalize-markdown-math.ts +8 -4
- package/src/core/codemirror/lsp/notebook-lsp.ts +220 -56
- package/src/core/codemirror/lsp/transports.ts +8 -1
- package/src/core/codemirror/lsp/types.ts +68 -8
- package/src/core/codemirror/lsp/utils.ts +14 -0
- package/src/core/codemirror/utils.ts +28 -0
- package/src/core/hotkeys/hotkeys.ts +0 -2
- package/src/core/islands/__tests__/bridge.test.ts +107 -0
- package/src/core/islands/bridge.ts +16 -0
- package/src/core/lsp/__tests__/transport.test.ts +509 -337
- package/src/core/lsp/transport.ts +304 -132
- package/src/core/mode.ts +10 -0
- package/src/core/network/__tests__/api.test.ts +42 -0
- package/src/core/network/__tests__/connection.test.ts +45 -0
- package/src/core/network/__tests__/requests-lazy.test.ts +32 -1
- package/src/core/network/__tests__/requests-network.test.ts +21 -0
- package/src/core/network/api.ts +27 -0
- package/src/core/network/connection.ts +15 -0
- package/src/core/network/requests-lazy.ts +1 -0
- package/src/core/network/requests-network.ts +14 -8
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +22 -6
- package/src/core/rtc/state.ts +9 -0
- package/src/core/static/download-html.ts +5 -14
- package/src/core/wasm/bridge.ts +4 -2
- package/src/core/wasm/worker/types.ts +5 -2
- package/src/css/app/codemirror.css +16 -2
- package/src/plugins/impl/FormPlugin.tsx +1 -1
- package/src/plugins/impl/__tests__/FormPlugin.test.tsx +162 -0
- package/src/stories/log-viewer.stories.tsx +12 -6
- package/src/utils/__tests__/download.test.tsx +24 -1
- package/src/utils/download.ts +11 -6
- package/dist/assets/RenderHTML-BCvU9dYz.js +0 -1
- package/dist/assets/add-connection-dialog-B-jCRNTN.js +0 -170
- package/dist/assets/ai-model-dropdown-DXgLphFa.js +0 -5
- package/dist/assets/cell-link-DqBkyAFe.js +0 -1
- package/dist/assets/cells-Cf7bHHq3.js +0 -229
- package/dist/assets/components-BH6gDVv6.js +0 -1
- package/dist/assets/config-BbOTTCYY.js +0 -1
- package/dist/assets/dist-BCMBu0rO.js +0 -2
- package/dist/assets/download-BomYt3nl.js +0 -9
- package/dist/assets/error-entries-Birw-8VX.js +0 -8
- package/dist/assets/floating-outline-wz-WSRgP.js +0 -1
- package/dist/assets/focus-DiEyfiAG.js +0 -1
- package/dist/assets/home-page-DJ4jJsZj.js +0 -4
- package/dist/assets/index-A71LAt6h.css +0 -2
- package/dist/assets/index-CMZzy-dF.js +0 -38
- package/dist/assets/kiosk-mode-ABm3oYgq.js +0 -1
- package/dist/assets/logs-panel-iFV4ZJ9b.js +0 -1
- package/dist/assets/node-sql-parser-BWgUjcfV.js +0 -68
- package/dist/assets/pair-with-agent-modal-CKOYwOYw.js +0 -4
- package/dist/assets/panels-Dj45fW-v.js +0 -4
- package/dist/assets/process-output-BEhIGfkO.js +0 -1
- package/dist/assets/scratchpad-panel-B0mEqBNk.js +0 -1
- package/dist/assets/slides-MCbMDtlY.css +0 -1
- package/dist/assets/state-BZQc7xxL.js +0 -3
- package/dist/assets/switch-CvweaCXq.js +0 -1
- package/dist/assets/useCellActionButton-CRfIEVB5.js +0 -1
- package/dist/assets/useEventListener-B_w3A283.js +0 -1
- package/dist/assets/useNotebookActions-DTXAoukG.js +0 -12
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "@codemirror/
|
|
7
|
-
import { PostgreSQL } from "@codemirror/lang-sql";
|
|
3
|
+
import { CompletionContext } from "@codemirror/autocomplete";
|
|
4
|
+
import type { CompletionSource } from "@codemirror/autocomplete";
|
|
5
|
+
import { PostgreSQL, sql } from "@codemirror/lang-sql";
|
|
6
|
+
import { forEachDiagnostic, forceLinting } from "@codemirror/lint";
|
|
8
7
|
import { EditorState, type Extension } from "@codemirror/state";
|
|
8
|
+
import { EditorView } from "@codemirror/view";
|
|
9
9
|
import { DuckDBDialect } from "@marimo-team/codemirror-sql/dialects";
|
|
10
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
11
11
|
import type { CellId } from "@/core/cells/ids";
|
|
12
12
|
import type {
|
|
13
13
|
CompletionConfig,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
setLatestEngineSelected,
|
|
21
21
|
} from "@/core/datasets/data-source-connections";
|
|
22
22
|
import { type ConnectionName, DUCKDB_ENGINE } from "@/core/datasets/engines";
|
|
23
|
+
import { ValidateSQL } from "@/core/datasets/request-registry";
|
|
23
24
|
import { datasetsAtom } from "@/core/datasets/state";
|
|
24
25
|
import type { DatasetsState } from "@/core/datasets/types";
|
|
25
26
|
import type { HotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
@@ -27,10 +28,11 @@ import { store } from "@/core/state/jotai";
|
|
|
27
28
|
import type { PlaceholderType } from "../../config/types";
|
|
28
29
|
import { TestSQLCompletionStore } from "../languages/sql/completion-store";
|
|
29
30
|
import {
|
|
31
|
+
exportedForTesting,
|
|
30
32
|
SQLLanguageAdapter,
|
|
31
33
|
type SQLLanguageAdapterMetadata,
|
|
32
34
|
} from "../languages/sql/sql";
|
|
33
|
-
import { languageMetadataField } from "../metadata";
|
|
35
|
+
import { languageMetadataField, updateLanguageMetadata } from "../metadata";
|
|
34
36
|
|
|
35
37
|
const adapter = new SQLLanguageAdapter();
|
|
36
38
|
|
|
@@ -634,6 +636,389 @@ _df = mo.sql(
|
|
|
634
636
|
});
|
|
635
637
|
});
|
|
636
638
|
|
|
639
|
+
describe("SQL analysis features", () => {
|
|
640
|
+
const metadata: SQLLanguageAdapterMetadata = {
|
|
641
|
+
dataframeName: "_df",
|
|
642
|
+
quotePrefix: "f",
|
|
643
|
+
commentLines: [],
|
|
644
|
+
showOutput: true,
|
|
645
|
+
engine: TEST_ENGINE,
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
const createConnection = (
|
|
649
|
+
columns: string[],
|
|
650
|
+
includeDefaultSchema = true,
|
|
651
|
+
): DataSourceConnection => ({
|
|
652
|
+
name: TEST_ENGINE,
|
|
653
|
+
dialect: "postgres",
|
|
654
|
+
display_name: "PostgreSQL",
|
|
655
|
+
source: "postgres",
|
|
656
|
+
default_database: "test_db",
|
|
657
|
+
default_schema: includeDefaultSchema ? "public" : undefined,
|
|
658
|
+
databases: [
|
|
659
|
+
{
|
|
660
|
+
name: "test_db",
|
|
661
|
+
dialect: "postgres",
|
|
662
|
+
schemas: [
|
|
663
|
+
{
|
|
664
|
+
name: "public",
|
|
665
|
+
tables: [
|
|
666
|
+
{
|
|
667
|
+
name: "users",
|
|
668
|
+
source: "postgres",
|
|
669
|
+
source_type: "local",
|
|
670
|
+
type: "table",
|
|
671
|
+
num_columns: columns.length,
|
|
672
|
+
num_rows: 0,
|
|
673
|
+
variable_name: null,
|
|
674
|
+
columns: columns.map((name) => ({
|
|
675
|
+
name,
|
|
676
|
+
external_type: "string",
|
|
677
|
+
type: "string",
|
|
678
|
+
sample_values: [],
|
|
679
|
+
})),
|
|
680
|
+
},
|
|
681
|
+
],
|
|
682
|
+
},
|
|
683
|
+
],
|
|
684
|
+
},
|
|
685
|
+
],
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
const createCompletionContext = (doc: string, pos: number) => {
|
|
689
|
+
const state = EditorState.create({
|
|
690
|
+
doc,
|
|
691
|
+
extensions: [languageMetadataField.init(() => metadata)],
|
|
692
|
+
});
|
|
693
|
+
const view = new EditorView({ state });
|
|
694
|
+
return {
|
|
695
|
+
context: new CompletionContext(view.state, pos, true, view),
|
|
696
|
+
view,
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
const getLabels = async (
|
|
701
|
+
source: CompletionSource,
|
|
702
|
+
context: CompletionContext,
|
|
703
|
+
) => {
|
|
704
|
+
const result = await source(context);
|
|
705
|
+
return result?.options.map((option) => option.label) ?? [];
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
beforeEach(() => {
|
|
709
|
+
store.set(datasetsAtom, { tables: [] } as unknown as DatasetsState);
|
|
710
|
+
store.set(dataSourceConnectionsAtom, {
|
|
711
|
+
connectionsMap: new Map([
|
|
712
|
+
[TEST_ENGINE, createConnection(["id", "name"])],
|
|
713
|
+
]),
|
|
714
|
+
latestEngineSelected: TEST_ENGINE,
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
it("resolves alias completions from the latest connection schema", async () => {
|
|
719
|
+
const analysis = exportedForTesting.createSQLAnalysis();
|
|
720
|
+
const doc = "SELECT u. FROM users u";
|
|
721
|
+
const { context, view } = createCompletionContext(doc, "SELECT u.".length);
|
|
722
|
+
|
|
723
|
+
expect(await getLabels(analysis.aliasCompletionSource, context)).toEqual(
|
|
724
|
+
expect.arrayContaining(["id", "name"]),
|
|
725
|
+
);
|
|
726
|
+
|
|
727
|
+
store.set(dataSourceConnectionsAtom, {
|
|
728
|
+
connectionsMap: new Map([
|
|
729
|
+
[TEST_ENGINE, createConnection(["id", "name", "email"])],
|
|
730
|
+
]),
|
|
731
|
+
latestEngineSelected: TEST_ENGINE,
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
expect(await getLabels(analysis.aliasCompletionSource, context)).toContain(
|
|
735
|
+
"email",
|
|
736
|
+
);
|
|
737
|
+
view.destroy();
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
it("resolves aliases when the only schema is implicit", async () => {
|
|
741
|
+
store.set(dataSourceConnectionsAtom, {
|
|
742
|
+
connectionsMap: new Map([
|
|
743
|
+
[TEST_ENGINE, createConnection(["id", "name"], false)],
|
|
744
|
+
]),
|
|
745
|
+
latestEngineSelected: TEST_ENGINE,
|
|
746
|
+
});
|
|
747
|
+
const analysis = exportedForTesting.createSQLAnalysis();
|
|
748
|
+
const doc = "SELECT u. FROM users u";
|
|
749
|
+
const { context, view } = createCompletionContext(doc, "SELECT u.".length);
|
|
750
|
+
|
|
751
|
+
expect(await getLabels(analysis.aliasCompletionSource, context)).toEqual(
|
|
752
|
+
expect.arrayContaining(["id", "name"]),
|
|
753
|
+
);
|
|
754
|
+
view.destroy();
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
it("preserves top-level namespaces when promoting default-schema tables", () => {
|
|
758
|
+
const connection = createConnection(["id"]);
|
|
759
|
+
const database = connection.databases[0]!;
|
|
760
|
+
const publicSchema = database.schemas[0]!;
|
|
761
|
+
const usersTable = publicSchema.tables[0]!;
|
|
762
|
+
store.set(dataSourceConnectionsAtom, {
|
|
763
|
+
connectionsMap: new Map([
|
|
764
|
+
[
|
|
765
|
+
TEST_ENGINE,
|
|
766
|
+
{
|
|
767
|
+
...connection,
|
|
768
|
+
databases: [
|
|
769
|
+
{
|
|
770
|
+
...database,
|
|
771
|
+
schemas: [
|
|
772
|
+
{
|
|
773
|
+
...publicSchema,
|
|
774
|
+
tables: [
|
|
775
|
+
...publicSchema.tables,
|
|
776
|
+
{ ...usersTable, name: "analytics" },
|
|
777
|
+
{ ...usersTable, name: "test_db" },
|
|
778
|
+
],
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
name: "analytics",
|
|
782
|
+
tables: [{ ...usersTable, name: "events" }],
|
|
783
|
+
},
|
|
784
|
+
],
|
|
785
|
+
},
|
|
786
|
+
],
|
|
787
|
+
},
|
|
788
|
+
],
|
|
789
|
+
]),
|
|
790
|
+
latestEngineSelected: TEST_ENGINE,
|
|
791
|
+
});
|
|
792
|
+
const state = EditorState.create({
|
|
793
|
+
extensions: [languageMetadataField.init(() => metadata)],
|
|
794
|
+
});
|
|
795
|
+
const view = new EditorView({ state });
|
|
796
|
+
|
|
797
|
+
expect(exportedForTesting.getSchema(view)).toMatchObject({
|
|
798
|
+
analytics: {
|
|
799
|
+
self: { label: "analytics", type: "schema" },
|
|
800
|
+
children: {
|
|
801
|
+
events: { self: { label: "events", type: "table" } },
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
public: {
|
|
805
|
+
children: {
|
|
806
|
+
analytics: { self: { label: "analytics", type: "table" } },
|
|
807
|
+
test_db: { self: { label: "test_db", type: "table" } },
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
test_db: {
|
|
811
|
+
self: { label: "test_db", type: "database" },
|
|
812
|
+
},
|
|
813
|
+
});
|
|
814
|
+
view.destroy();
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
it("resolves a table literally named self", async () => {
|
|
818
|
+
store.set(datasetsAtom, {
|
|
819
|
+
tables: [
|
|
820
|
+
{
|
|
821
|
+
name: "self",
|
|
822
|
+
columns: [{ name: "value", type: "string" }],
|
|
823
|
+
},
|
|
824
|
+
],
|
|
825
|
+
} as DatasetsState);
|
|
826
|
+
const analysis = exportedForTesting.createSQLAnalysis();
|
|
827
|
+
const doc = "SELECT s. FROM self s";
|
|
828
|
+
const { context, view } = createCompletionContext(doc, "SELECT s.".length);
|
|
829
|
+
|
|
830
|
+
expect(await getLabels(analysis.aliasCompletionSource, context)).toContain(
|
|
831
|
+
"value",
|
|
832
|
+
);
|
|
833
|
+
view.destroy();
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
it("completes declared CTE columns", async () => {
|
|
837
|
+
const analysis = exportedForTesting.createSQLAnalysis();
|
|
838
|
+
const doc =
|
|
839
|
+
"WITH active_users(user_id, user_email) AS (SELECT id, email FROM users) " +
|
|
840
|
+
"SELECT active_users. FROM active_users";
|
|
841
|
+
const pos = doc.indexOf("active_users.") + "active_users.".length;
|
|
842
|
+
const { context, view } = createCompletionContext(doc, pos);
|
|
843
|
+
|
|
844
|
+
expect(await getLabels(analysis.cteCompletionSource, context)).toEqual(
|
|
845
|
+
expect.arrayContaining(["user_id", "user_email"]),
|
|
846
|
+
);
|
|
847
|
+
view.destroy();
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
it("completes columns from tables in the current statement", async () => {
|
|
851
|
+
const analysis = exportedForTesting.createSQLAnalysis();
|
|
852
|
+
const doc = "SELECT na FROM users";
|
|
853
|
+
const { context, view } = createCompletionContext(doc, "SELECT na".length);
|
|
854
|
+
|
|
855
|
+
expect(await getLabels(analysis.columnCompletionSource, context)).toContain(
|
|
856
|
+
"name",
|
|
857
|
+
);
|
|
858
|
+
view.destroy();
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
it("reports semantic diagnostics as warnings", async () => {
|
|
862
|
+
const adapter = new SQLLanguageAdapter();
|
|
863
|
+
const extensions = adapter.getExtension(
|
|
864
|
+
{} as CellId,
|
|
865
|
+
{} as CompletionConfig,
|
|
866
|
+
{} as HotkeyProvider,
|
|
867
|
+
{} as PlaceholderType,
|
|
868
|
+
{
|
|
869
|
+
diagnostics: { sql_linter: true },
|
|
870
|
+
} as LSPConfig & { diagnostics: DiagnosticsConfig },
|
|
871
|
+
);
|
|
872
|
+
const state = EditorState.create({
|
|
873
|
+
doc: "SELECT missing FROM users",
|
|
874
|
+
extensions: [languageMetadataField.init(() => metadata), ...extensions],
|
|
875
|
+
});
|
|
876
|
+
const view = new EditorView({ state });
|
|
877
|
+
|
|
878
|
+
forceLinting(view);
|
|
879
|
+
await vi.waitFor(() => {
|
|
880
|
+
const diagnostics: Array<{ message: string; severity: string }> = [];
|
|
881
|
+
forEachDiagnostic(view.state, (diagnostic) => {
|
|
882
|
+
diagnostics.push(diagnostic);
|
|
883
|
+
});
|
|
884
|
+
expect(diagnostics).toContainEqual(
|
|
885
|
+
expect.objectContaining({
|
|
886
|
+
message: "Column 'missing' not found in table 'users'",
|
|
887
|
+
severity: "warning",
|
|
888
|
+
}),
|
|
889
|
+
);
|
|
890
|
+
});
|
|
891
|
+
view.destroy();
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
it("does not report unknown tables", async () => {
|
|
895
|
+
const adapter = new SQLLanguageAdapter();
|
|
896
|
+
const extensions = adapter.getExtension(
|
|
897
|
+
{} as CellId,
|
|
898
|
+
{} as CompletionConfig,
|
|
899
|
+
{} as HotkeyProvider,
|
|
900
|
+
{} as PlaceholderType,
|
|
901
|
+
{
|
|
902
|
+
diagnostics: { sql_linter: true },
|
|
903
|
+
} as LSPConfig & { diagnostics: DiagnosticsConfig },
|
|
904
|
+
);
|
|
905
|
+
const state = EditorState.create({
|
|
906
|
+
doc: "SELECT missing FROM users; SELECT * FROM unknown_table",
|
|
907
|
+
extensions: [languageMetadataField.init(() => metadata), ...extensions],
|
|
908
|
+
});
|
|
909
|
+
const view = new EditorView({ state });
|
|
910
|
+
|
|
911
|
+
forceLinting(view);
|
|
912
|
+
await vi.waitFor(() => {
|
|
913
|
+
const diagnostics: string[] = [];
|
|
914
|
+
forEachDiagnostic(view.state, (diagnostic) => {
|
|
915
|
+
diagnostics.push(diagnostic.message);
|
|
916
|
+
});
|
|
917
|
+
expect(diagnostics).toEqual([
|
|
918
|
+
"Column 'missing' not found in table 'users'",
|
|
919
|
+
]);
|
|
920
|
+
});
|
|
921
|
+
view.destroy();
|
|
922
|
+
});
|
|
923
|
+
|
|
924
|
+
it("invalidates analysis caches when the engine changes", async () => {
|
|
925
|
+
const mssqlEngine = "mssql_engine" as ConnectionName;
|
|
926
|
+
const postgresEngine = "postgres_engine" as ConnectionName;
|
|
927
|
+
store.set(dataSourceConnectionsAtom, {
|
|
928
|
+
connectionsMap: new Map([
|
|
929
|
+
[
|
|
930
|
+
mssqlEngine,
|
|
931
|
+
{
|
|
932
|
+
...createConnection([]),
|
|
933
|
+
name: mssqlEngine,
|
|
934
|
+
dialect: "mssql",
|
|
935
|
+
},
|
|
936
|
+
],
|
|
937
|
+
[
|
|
938
|
+
postgresEngine,
|
|
939
|
+
{
|
|
940
|
+
...createConnection([]),
|
|
941
|
+
name: postgresEngine,
|
|
942
|
+
dialect: "postgres",
|
|
943
|
+
},
|
|
944
|
+
],
|
|
945
|
+
]),
|
|
946
|
+
latestEngineSelected: mssqlEngine,
|
|
947
|
+
});
|
|
948
|
+
const analysis = exportedForTesting.createSQLAnalysis();
|
|
949
|
+
const state = EditorState.create({
|
|
950
|
+
doc: "SELECT TOP 1 * FROM users",
|
|
951
|
+
extensions: [
|
|
952
|
+
languageMetadataField.init(() => ({
|
|
953
|
+
...metadata,
|
|
954
|
+
engine: mssqlEngine,
|
|
955
|
+
})),
|
|
956
|
+
],
|
|
957
|
+
});
|
|
958
|
+
const view = new EditorView({ state });
|
|
959
|
+
|
|
960
|
+
const before = await analysis.structureAnalyzer.analyzeDocument(view.state);
|
|
961
|
+
expect(before[0]?.isValid).toBe(true);
|
|
962
|
+
|
|
963
|
+
view.dispatch({
|
|
964
|
+
effects: updateLanguageMetadata.of({ engine: postgresEngine }),
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
const after = await analysis.structureAnalyzer.analyzeDocument(view.state);
|
|
968
|
+
expect(after[0]?.isValid).toBe(false);
|
|
969
|
+
view.destroy();
|
|
970
|
+
});
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
describe("CustomSqlParser", () => {
|
|
974
|
+
afterEach(() => {
|
|
975
|
+
vi.useRealTimers();
|
|
976
|
+
vi.restoreAllMocks();
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
it("uses backend DuckDB validation", async () => {
|
|
980
|
+
vi.useFakeTimers();
|
|
981
|
+
const error = {
|
|
982
|
+
message: "Backend syntax error",
|
|
983
|
+
line: 1,
|
|
984
|
+
column: 1,
|
|
985
|
+
severity: "error" as const,
|
|
986
|
+
};
|
|
987
|
+
const request = vi.spyOn(ValidateSQL, "request").mockResolvedValue({
|
|
988
|
+
error: null,
|
|
989
|
+
parse_result: { success: false, errors: [error] },
|
|
990
|
+
request_id: "request-id",
|
|
991
|
+
validate_result: null,
|
|
992
|
+
});
|
|
993
|
+
const state = EditorState.create({
|
|
994
|
+
doc: "SELECT",
|
|
995
|
+
extensions: [
|
|
996
|
+
languageMetadataField.init(() => ({
|
|
997
|
+
dataframeName: "_df",
|
|
998
|
+
quotePrefix: "f",
|
|
999
|
+
commentLines: [],
|
|
1000
|
+
showOutput: true,
|
|
1001
|
+
engine: DUCKDB_ENGINE,
|
|
1002
|
+
})),
|
|
1003
|
+
],
|
|
1004
|
+
});
|
|
1005
|
+
const parser = new exportedForTesting.CustomSqlParser();
|
|
1006
|
+
parser.setFocusState(true);
|
|
1007
|
+
|
|
1008
|
+
const result = parser.validateSql("SELECT", { state });
|
|
1009
|
+
await vi.runAllTimersAsync();
|
|
1010
|
+
|
|
1011
|
+
await expect(result).resolves.toEqual([error]);
|
|
1012
|
+
expect(request).toHaveBeenCalledWith(
|
|
1013
|
+
expect.objectContaining({
|
|
1014
|
+
engine: DUCKDB_ENGINE,
|
|
1015
|
+
onlyParse: true,
|
|
1016
|
+
query: "SELECT",
|
|
1017
|
+
}),
|
|
1018
|
+
);
|
|
1019
|
+
});
|
|
1020
|
+
});
|
|
1021
|
+
|
|
637
1022
|
describe("tablesCompletionSource", () => {
|
|
638
1023
|
const mockStore = store;
|
|
639
1024
|
const completionStore = new TestSQLCompletionStore();
|
|
@@ -1523,6 +1908,7 @@ describe("tablesCompletionSource", () => {
|
|
|
1523
1908
|
|
|
1524
1909
|
const completionSource = completionStore.getCompletionSource(TEST_ENGINE);
|
|
1525
1910
|
expect(completionSource?.defaultTable).toBe("users");
|
|
1911
|
+
expect(completionSource?.defaultSchema).toBe("public");
|
|
1526
1912
|
expect(completionSource?.dialect).toBe(PostgreSQL);
|
|
1527
1913
|
});
|
|
1528
1914
|
|
|
@@ -1654,17 +2040,7 @@ describe("tablesCompletionSource", () => {
|
|
|
1654
2040
|
`);
|
|
1655
2041
|
});
|
|
1656
2042
|
|
|
1657
|
-
|
|
1658
|
-
const testDatasets = [
|
|
1659
|
-
{
|
|
1660
|
-
name: "dataset1",
|
|
1661
|
-
columns: [
|
|
1662
|
-
{ name: "col1", type: "number" },
|
|
1663
|
-
{ name: "col2", type: "string" },
|
|
1664
|
-
],
|
|
1665
|
-
},
|
|
1666
|
-
];
|
|
1667
|
-
|
|
2043
|
+
describe("completion sources", () => {
|
|
1668
2044
|
describe("SQL Completions", () => {
|
|
1669
2045
|
const completionStore = new TestSQLCompletionStore();
|
|
1670
2046
|
|
|
@@ -1695,54 +2071,57 @@ describe("tablesCompletionSource", () => {
|
|
|
1695
2071
|
|
|
1696
2072
|
return EditorState.create({
|
|
1697
2073
|
doc,
|
|
1698
|
-
extensions: [
|
|
2074
|
+
extensions: [
|
|
2075
|
+
languageMetadataField.init(() => defaultMetadata),
|
|
2076
|
+
sql({ dialect: PostgreSQL }),
|
|
2077
|
+
],
|
|
1699
2078
|
});
|
|
1700
2079
|
};
|
|
1701
2080
|
|
|
1702
2081
|
const createCompletionContext = (
|
|
1703
2082
|
state: EditorState,
|
|
1704
2083
|
pos: number,
|
|
1705
|
-
matchText?: string,
|
|
1706
|
-
matchFrom?: number,
|
|
1707
2084
|
): CompletionContext => {
|
|
1708
|
-
return
|
|
1709
|
-
pos,
|
|
1710
|
-
explicit: false,
|
|
1711
|
-
matchBefore: matchText
|
|
1712
|
-
? () => ({
|
|
1713
|
-
from: matchFrom || pos - matchText.length,
|
|
1714
|
-
to: pos,
|
|
1715
|
-
text: matchText,
|
|
1716
|
-
})
|
|
1717
|
-
: () => null,
|
|
1718
|
-
state,
|
|
1719
|
-
aborted: false,
|
|
1720
|
-
tokenBefore: () => null,
|
|
1721
|
-
} as unknown as CompletionContext;
|
|
2085
|
+
return new CompletionContext(state, pos, false);
|
|
1722
2086
|
};
|
|
1723
2087
|
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
2088
|
+
const getCompletionSources = (
|
|
2089
|
+
extensions: readonly Extension[],
|
|
2090
|
+
): readonly CompletionSource[] | undefined => {
|
|
2091
|
+
for (const extension of extensions) {
|
|
2092
|
+
if (Array.isArray(extension)) {
|
|
2093
|
+
const sources = getCompletionSources(extension);
|
|
2094
|
+
if (sources) {
|
|
2095
|
+
return sources;
|
|
2096
|
+
}
|
|
2097
|
+
continue;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
const config = extension as {
|
|
2101
|
+
value?: { override?: readonly CompletionSource[] };
|
|
2102
|
+
};
|
|
2103
|
+
if (config.value?.override) {
|
|
2104
|
+
return config.value.override;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
return undefined;
|
|
1729
2108
|
};
|
|
1730
2109
|
|
|
1731
2110
|
describe("tablesCompletionSource", () => {
|
|
1732
|
-
it("should return null when no connection exists", () => {
|
|
2111
|
+
it("should return null when no connection exists", async () => {
|
|
1733
2112
|
const state = createEditorState("SELECT * FROM ");
|
|
1734
2113
|
const ctx = createCompletionContext(state, 14);
|
|
1735
2114
|
|
|
1736
2115
|
const adapter = new SQLLanguageAdapter();
|
|
1737
2116
|
const extensions = adapter.getExtension(...TEST_EXTENSION_ARGS);
|
|
1738
|
-
const completion =
|
|
2117
|
+
const completion = getCompletionSources(extensions)?.[0];
|
|
1739
2118
|
|
|
1740
2119
|
expect(completion).toBeDefined();
|
|
1741
|
-
const result = completion!(ctx);
|
|
2120
|
+
const result = await completion!(ctx);
|
|
1742
2121
|
expect(result).toBeNull();
|
|
1743
2122
|
});
|
|
1744
2123
|
|
|
1745
|
-
it("should provide table completions when connection exists", () => {
|
|
2124
|
+
it("should provide table completions when connection exists", async () => {
|
|
1746
2125
|
const mockConnection: DataSourceConnection = {
|
|
1747
2126
|
name: TEST_ENGINE,
|
|
1748
2127
|
dialect: "postgres",
|
|
@@ -1794,19 +2173,19 @@ describe("tablesCompletionSource", () => {
|
|
|
1794
2173
|
const state = createEditorState("SELECT * FROM u", {
|
|
1795
2174
|
engine: TEST_ENGINE,
|
|
1796
2175
|
});
|
|
1797
|
-
const ctx = createCompletionContext(state, 15
|
|
2176
|
+
const ctx = createCompletionContext(state, 15);
|
|
1798
2177
|
|
|
1799
2178
|
const adapter = new SQLLanguageAdapter();
|
|
1800
2179
|
const extensions = adapter.getExtension(...TEST_EXTENSION_ARGS);
|
|
1801
|
-
const completion =
|
|
2180
|
+
const completion = getCompletionSources(extensions)?.[0];
|
|
1802
2181
|
|
|
1803
2182
|
expect(completion).toBeDefined();
|
|
1804
|
-
const result = completion!(ctx);
|
|
2183
|
+
const result = await completion!(ctx);
|
|
1805
2184
|
expect(result).toBeDefined();
|
|
1806
2185
|
expect(result?.options.length).toBeGreaterThan(0);
|
|
1807
2186
|
});
|
|
1808
2187
|
|
|
1809
|
-
it("should include local datasets in completions", () => {
|
|
2188
|
+
it("should include local datasets in completions", async () => {
|
|
1810
2189
|
const mockConnection: DataSourceConnection = {
|
|
1811
2190
|
name: TEST_ENGINE,
|
|
1812
2191
|
dialect: "duckdb",
|
|
@@ -1825,14 +2204,14 @@ describe("tablesCompletionSource", () => {
|
|
|
1825
2204
|
const state = createEditorState("SELECT * FROM d", {
|
|
1826
2205
|
engine: TEST_ENGINE,
|
|
1827
2206
|
});
|
|
1828
|
-
const ctx = createCompletionContext(state, 15
|
|
2207
|
+
const ctx = createCompletionContext(state, 15);
|
|
1829
2208
|
|
|
1830
2209
|
const adapter = new SQLLanguageAdapter();
|
|
1831
2210
|
const extensions = adapter.getExtension(...TEST_EXTENSION_ARGS);
|
|
1832
|
-
const completion =
|
|
2211
|
+
const completion = getCompletionSources(extensions)?.[0];
|
|
1833
2212
|
|
|
1834
2213
|
expect(completion).toBeDefined();
|
|
1835
|
-
const result
|
|
2214
|
+
const result = await completion!(ctx);
|
|
1836
2215
|
expect(result).toBeDefined();
|
|
1837
2216
|
expect(result?.options.some((opt) => opt.label === "dataset1")).toBe(
|
|
1838
2217
|
true,
|
|
@@ -1841,7 +2220,7 @@ describe("tablesCompletionSource", () => {
|
|
|
1841
2220
|
});
|
|
1842
2221
|
|
|
1843
2222
|
describe("customKeywordCompletionSource", () => {
|
|
1844
|
-
it("should provide SQL keyword completions", () => {
|
|
2223
|
+
it("should provide SQL keyword completions", async () => {
|
|
1845
2224
|
const mockConnection: DataSourceConnection = {
|
|
1846
2225
|
name: TEST_ENGINE,
|
|
1847
2226
|
dialect: "postgres",
|
|
@@ -1858,21 +2237,21 @@ describe("tablesCompletionSource", () => {
|
|
|
1858
2237
|
const state = createEditorState("SEL", {
|
|
1859
2238
|
engine: TEST_ENGINE,
|
|
1860
2239
|
});
|
|
1861
|
-
const ctx = createCompletionContext(state, 3
|
|
2240
|
+
const ctx = createCompletionContext(state, 3);
|
|
1862
2241
|
|
|
1863
2242
|
const adapter = new SQLLanguageAdapter();
|
|
1864
2243
|
const extensions = adapter.getExtension(...TEST_EXTENSION_ARGS);
|
|
1865
|
-
const completion =
|
|
2244
|
+
const completion = getCompletionSources(extensions)?.[2];
|
|
1866
2245
|
|
|
1867
2246
|
expect(completion).toBeDefined();
|
|
1868
|
-
const result
|
|
2247
|
+
const result = await completion!(ctx);
|
|
1869
2248
|
expect(result).toBeDefined();
|
|
1870
2249
|
expect(result?.options.some((opt) => opt.label === "SELECT")).toBe(
|
|
1871
2250
|
true,
|
|
1872
2251
|
);
|
|
1873
2252
|
});
|
|
1874
2253
|
|
|
1875
|
-
it("should not provide keyword completions after dot", () => {
|
|
2254
|
+
it("should not provide keyword completions after dot", async () => {
|
|
1876
2255
|
const mockConnection: DataSourceConnection = {
|
|
1877
2256
|
name: TEST_ENGINE,
|
|
1878
2257
|
dialect: "postgres",
|
|
@@ -1889,14 +2268,14 @@ describe("tablesCompletionSource", () => {
|
|
|
1889
2268
|
const state = createEditorState("SELECT users.n", {
|
|
1890
2269
|
engine: TEST_ENGINE,
|
|
1891
2270
|
});
|
|
1892
|
-
const ctx = createCompletionContext(state, 14
|
|
2271
|
+
const ctx = createCompletionContext(state, 14);
|
|
1893
2272
|
|
|
1894
2273
|
const adapter = new SQLLanguageAdapter();
|
|
1895
2274
|
const extensions = adapter.getExtension(...TEST_EXTENSION_ARGS);
|
|
1896
|
-
const completion =
|
|
2275
|
+
const completion = getCompletionSources(extensions)?.[2];
|
|
1897
2276
|
|
|
1898
2277
|
expect(completion).toBeDefined();
|
|
1899
|
-
const result = completion!(ctx);
|
|
2278
|
+
const result = await completion!(ctx);
|
|
1900
2279
|
expect(result).toBeNull();
|
|
1901
2280
|
});
|
|
1902
2281
|
|
|
@@ -1925,13 +2304,16 @@ describe("tablesCompletionSource", () => {
|
|
|
1925
2304
|
it("should be included in extension overrides", () => {
|
|
1926
2305
|
const adapter = new SQLLanguageAdapter();
|
|
1927
2306
|
const extensions = adapter.getExtension(...TEST_EXTENSION_ARGS);
|
|
1928
|
-
const completion =
|
|
2307
|
+
const completion = getCompletionSources(extensions);
|
|
1929
2308
|
|
|
1930
2309
|
expect(completion).toBeDefined();
|
|
1931
|
-
expect(completion).toHaveLength(
|
|
2310
|
+
expect(completion).toHaveLength(6);
|
|
1932
2311
|
});
|
|
1933
2312
|
});
|
|
1934
2313
|
});
|
|
2314
|
+
});
|
|
2315
|
+
|
|
2316
|
+
it("should return local tables", () => {
|
|
1935
2317
|
mockStore.set(datasetsAtom, { tables: testDatasets } as DatasetsState);
|
|
1936
2318
|
|
|
1937
2319
|
const mockConnection: DataSourceConnection = {
|