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

Net Fetch in Electron #3069

Merged
merged 13 commits into from
Jun 6, 2024
47 changes: 26 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,35 @@
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"overrides": [
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loosens up the eslint rules so I can @ts-ignore and use any type.

"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", {
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}],
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-explicit-any": ["off", {}],
"@typescript-eslint/ban-ts-comment": ["off", {}],
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
Expand All @@ -24,23 +46,6 @@
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
6 changes: 6 additions & 0 deletions apps/zui/src/core/electron-zed-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {Client} from "@brimdata/zed-node"
import {net} from "electron"

export class ElectronZedClient extends Client {
fetch = net.fetch
}
3 changes: 2 additions & 1 deletion apps/zui/src/core/main/main-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import keytar from "keytar"
import {EventEmitter} from "events"
import os from "os"
import {Client, Lake} from "@brimdata/zed-node"

Check failure on line 5 in apps/zui/src/core/main/main-object.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

'Client' is defined but never used. Allowed unused vars must match /^_/u
import {Store as ReduxStore} from "redux"
import url from "url"
import {
Expand Down Expand Up @@ -30,6 +30,7 @@
import {Abortables} from "src/app/core/models/abortables"
import * as zui from "src/zui"
import log from "electron-log"
import {ElectronZedClient} from "../electron-zed-client"

export class MainObject {
public isQuitting = false
Expand Down Expand Up @@ -135,7 +136,7 @@
const lakeData = Lakes.id(lakeId)(this.store.getState())
const lake = createLake(lakeData)
const auth = await this.dispatch(getAuthToken(lake))
return new Client(lake.getAddress(), {auth})
return new ElectronZedClient(lake.getAddress(), {auth})
}

async createDefaultClient() {
Expand Down
3 changes: 2 additions & 1 deletion packages/zed-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"dependencies": {
"@brimdata/zed-js": "workspace:*",
"fs-extra": "^11.1.1"
"fs-extra": "^11.1.1",
"node-fetch": "^2.6.2"
},
"peerDependencies": {
"zed": "*"
Expand Down
4 changes: 3 additions & 1 deletion packages/zed-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
getLoadContentType,
jsonHeader,
} from '@brimdata/zed-js';
// @ts-ignore
import nodeFetch from 'node-fetch';

export class Client extends BaseClient {
public fetch = globalThis.fetch;
public fetch = (...args: any[]) => nodeFetch(...args);

async load(
data: string | NodeJS.ReadableStream,
Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,7 @@ __metadata:
"@brimdata/zed-js": "workspace:*"
"@types/fs-extra": ^11.0.1
fs-extra: ^11.1.1
node-fetch: ^2.6.2
zed: "github:brimdata/zed#main"
peerDependencies:
zed: "*"
Expand Down Expand Up @@ -14358,6 +14359,20 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:^2.6.2":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-gyp-build@npm:^4.3.0":
version: 4.6.0
resolution: "node-gyp-build@npm:4.6.0"
Expand Down
Loading