Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove JS Zed Query Parser #2972

Merged
merged 47 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
efe9106
wip
mattnibs Jan 10, 2024
7e82877
New Folder Setup
jameskerr Jan 11, 2024
934f640
Zui Tests Passing
jameskerr Jan 11, 2024
39b030f
Zed Wasm Complete
jameskerr Jan 16, 2024
6c80015
Integrate Zed Wasm into Zui
jameskerr Jan 16, 2024
d530273
Integration Zed Wasm
jameskerr Jan 17, 2024
95b763f
Test Pass
jameskerr Jan 17, 2024
cd19ab6
Merge
jameskerr Jan 17, 2024
bc9346c
Lint Fix
jameskerr Jan 17, 2024
68b03c9
Only test chromium
jameskerr Jan 17, 2024
e76911b
Add Playwright Deps
jameskerr Jan 17, 2024
9829a33
CI
jameskerr Jan 17, 2024
44cb836
Merge remote-tracking branch 'origin/main' into wasm-parser
jameskerr Feb 21, 2024
596cece
Remove deps
jameskerr Feb 22, 2024
bd85774
Remove usage in Zui
jameskerr Feb 22, 2024
a56bdc3
Add a Way to Query the Default Local Lake
jameskerr Feb 22, 2024
c9b364c
Use the Compile Endpoint
jameskerr Feb 23, 2024
84ea49e
Merge remote-tracking branch 'origin/main' into wasm-parser
jameskerr Feb 23, 2024
5a553cb
Query Info Reducer
jameskerr Feb 24, 2024
3be329a
Fix Error Display
jameskerr Feb 26, 2024
86b8e52
Use the current lake's compile endpoint
jameskerr Feb 27, 2024
c1bb708
Remove Syntax Check in Submit Search
jameskerr Feb 27, 2024
86bf01f
Add isFetching to QueryInfo
jameskerr Feb 27, 2024
94b5519
Paginate the same way every time
jameskerr Feb 27, 2024
976c0e2
Properly handle error case
jameskerr Feb 27, 2024
14fc6e3
Get Query Info Asyncronously
jameskerr Feb 27, 2024
76ce4d6
Remove aggregation state from results
jameskerr Feb 27, 2024
4da3d6e
Remove aggregtaion from Results
jameskerr Feb 27, 2024
9884132
Add Async Tasks Api
jameskerr Feb 28, 2024
6efaf2a
Add a Run method to Async Task
jameskerr Mar 5, 2024
0e85afb
Return the error as an object.
jameskerr Mar 5, 2024
b953b1f
Refactor Run Histogram Query
jameskerr Mar 5, 2024
f4964b6
Add canPaginate to Results Default False
jameskerr Mar 5, 2024
d331ab6
Remove LIMIT and Aggregation from Results Slice
jameskerr Mar 5, 2024
8f0bd19
Merge remote-tracking branch 'origin/main' into wasm-parser
jameskerr Mar 20, 2024
1fa0b66
Clear Up Terms
jameskerr Mar 20, 2024
b028542
Rename to createEditorSnapshot
jameskerr Mar 20, 2024
8304d83
Add Docs
jameskerr Mar 20, 2024
4001f37
Add Query Session Model .reset()
jameskerr Mar 21, 2024
e9683df
History only pushed if valid
jameskerr Mar 21, 2024
65d6956
Renamed to getSessionRouteParentId
jameskerr Mar 21, 2024
414c094
Removed QueriesApi.open
jameskerr Mar 26, 2024
25bd72e
Removed Remote Queries Feature
jameskerr Mar 26, 2024
f5dddf7
Lint Fix
jameskerr Mar 26, 2024
318b5e7
Add gutter to histogram and pin dialogs
jameskerr Mar 26, 2024
0b294b3
Reset the preview load form
jameskerr Mar 26, 2024
58d7751
Fallback to named query snapshot if none exists on the session
jameskerr Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/actions/setup-zui/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Setup Zui
description: Shared steps for setting up Zui in workflows
runs:
using: "composite"
using: 'composite'
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand All @@ -21,6 +21,10 @@ runs:
run: yarn --inline-builds
shell: bash

- name: Install Playwright Deps
run: yarn workspace @brimdata/zed-wasm run playwright install
shell: bash

- name: Yarn Build
run: yarn run build
shell: bash
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.10.0
18.18.2
1 change: 0 additions & 1 deletion apps/zui/.node-version

This file was deleted.

1 change: 0 additions & 1 deletion apps/zui/.swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
"type": "commonjs",
"ignoreDynamic": true
}

}
1 change: 1 addition & 0 deletions apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"release-insiders": "electron-builder --config electron-builder-insiders.json --publish always"
},
"dependencies": {
"@brimdata/zed-wasm": "workspace:*",
"keytar": "^7.7.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/zui/scripts/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const context = await esbuild.context({
platform: "node",
sourcemap: true,
target: "node16",
external: ["keytar", "electron"],
external: ["keytar", "electron", "@brimdata/zed-wasm"],
tsconfig: "./tsconfig.json",
})

Expand Down
4 changes: 3 additions & 1 deletion apps/zui/src/core/query/run.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ResultStream} from "@brimdata/zed-js"
import ErrorFactory from "src/js/models/ErrorFactory"
import ast from "src/js/models/ast"
import Current from "src/js/state/Current"
import Results from "src/js/state/Results"
import {Thunk} from "src/js/state/types"
Expand All @@ -20,7 +21,8 @@ export function firstPage(opts: {id: string; query: string}): Thunk {
const {id, query} = opts
const key = Current.getLocation(getState()).key
const tabId = api.current.tabId
dispatch(Results.init({query, key, id, tabId}))
const aggregation = (await ast(query)).hasAnalytics()
dispatch(Results.init({query, key, id, tabId, aggregation}))
dispatch(run(id))
}
}
Expand Down
8 changes: 3 additions & 5 deletions apps/zui/src/domain/editor/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as zed from "@brimdata/zed-js"
import program from "src/js/models/program"
import {drillDown} from "src/js/models/program"
import {
appendQueryCountBy,
appendQueryExclude,
Expand Down Expand Up @@ -88,14 +88,12 @@ export const newSearchWithValue = createHandler(

export const pivotToValues = createHandler(
"editor.pivotToValues",
({select, dispatch}) => {
async ({select, dispatch}) => {
const field = select(Selection.getField)
const query = select(Editor.getValue)
// So this only works if the count() by field is in the editor, not in a pin.
const record = field.rootRecord
const newProgram = program(query)
.drillDown(record as zed.Record)
.string()
const newProgram = await drillDown(query, record as zed.Record)

if (newProgram) {
dispatch(Editor.setValue(newProgram))
Expand Down
21 changes: 20 additions & 1 deletion apps/zui/src/electron/run-main/run-protocol-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import {app, protocol} from "electron"
import {app, protocol, net} from "electron"
import path from "path"
import {pathToFileURL} from "url"

protocol.registerSchemesAsPrivileged([
{
scheme: "app-asset",
privileges: {standard: true, supportFetchAPI: true, bypassCSP: true},
},
])

export function runProtocolHandlers() {
app.whenReady().then(() => {
Expand All @@ -10,5 +18,16 @@ export function runProtocolHandlers() {
const absPath = path.join(rootPath, relPath)
callback(absPath)
})

protocol.handle("app-asset", (request) => {
const {host, pathname, href} = new URL(request.url)
if (host === "node_modules") {
const path = pathname.slice(1)
const file = require.resolve(path)
const url = pathToFileURL(file).toString()
return net.fetch(url, {bypassCustomProtocolHandlers: true})
}
throw new Error("Unknown App Asset " + href)
})
})
}
11 changes: 11 additions & 0 deletions apps/zui/src/js/initializers/init-zed-wasm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import {initZedWasm} from "@brimdata/zed-wasm/dist/browser.js"

export async function initializeZedWasm() {
if (!globalThis.zedWasm) {
const resp = fetch(
"app-asset://node_modules/@brimdata/zed-wasm/dist/main.wasm"
)
globalThis.zedWasm = await initZedWasm(resp)
}
}
2 changes: 2 additions & 0 deletions apps/zui/src/js/initializers/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {initLake} from "./init-lake"
import {initializeTabs} from "./init-tabs"
import {initializeMonaco} from "./init-monaco"
import {initializePluginContextSync} from "./init-plugin-context-sync"
import {initializeZedWasm} from "./init-zed-wasm"
import toast from "react-hot-toast"
import {startTransition} from "react"
import {initResizeListener} from "./init-resize-listener"
Expand Down Expand Up @@ -60,5 +61,6 @@ export default async function initialize(
initializeMonaco()
initializePluginContextSync(store)
initResizeListener()
await initializeZedWasm()
return {store, api}
}
22 changes: 21 additions & 1 deletion apps/zui/src/js/models/ast.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import {toFieldPath} from "../zed-script/toZedScript"

function parse(s: string) {
return globalThis.zedWasm.parse(s)
}

type ColumnName = string | string[]

export default function ast(tree: any) {
export default async function ast(string: string) {
let tree
try {
let res = await parse(string)
if (res.error) throw res.error
tree = res.ast
} catch (error) {
console.error(error)
tree = {error}
}

return {
valid() {
return !tree.error
Expand All @@ -27,6 +41,12 @@ export default function ast(tree: any) {
self() {
return tree
},
hasAnalytics() {
for (const proc of this.getProcs()) {
if (ANALYTIC_PROCS.includes(proc.kind)) return true
}
return false
},
}
}

Expand Down
Loading
Loading