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

feat: duckdb-wasm query UI [DRAFT] #39

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"serve": "vite preview"
},
"dependencies": {
"@codemirror/lang-sql": "^0.20.0",
"@duckdb/duckdb-wasm": "^1.14.1",
"@githubocto/flat-ui": "^0.13.5",
"@octokit/rest": "^18.3.5",
"@popperjs/core": "^2.9.1",
Expand All @@ -15,6 +17,7 @@
"@types/lodash": "^4.14.168",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.truncate": "^4.0.6",
"@uiw/react-codemirror": "^4.7.0",
"classcat": "^5.0.3",
"d3-dsv": "^2.0.0",
"date-fns": "^2.19.0",
Expand All @@ -27,15 +30,17 @@
"query-string": "^6.14.1",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-error-boundary": "^3.1.4",
"react-head": "^3.4.0",
"react-hot-toast": "^1.0.2",
"react-icons": "^4.2.0",
"react-popper": "^2.2.4",
"react-portal": "^4.2.1",
"react-query": "^3.12.1",
"react-query": "^3.39.0",
"react-router-dom": "^5.2.0",
"reakit": "^1.3.8",
"store2": "^2.12.0",
"use-debounce": "^8.0.1",
"use-query-params": "^1.2.2",
"vite-plugin-rewrite-all": "^0.1.2",
"wretch": "^1.7.4",
Expand All @@ -44,17 +49,17 @@
},
"devDependencies": {
"@octokit/types": "^6.12.2",
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/forms": "^0.5.1",
"@types/nprogress": "^0.2.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-portal": "^4.0.2",
"@types/react-router-dom": "^5.1.7",
"@vitejs/plugin-react-refresh": "^1.3.1",
"@vitejs/plugin-react": "^1.3.2",
"autoprefixer": "^10.2.5",
"postcss": "^8.2.8",
"tailwindcss": "^2.1.2",
"tailwindcss": "^3.0.24",
"typescript": "^4.1.2",
"vite": "^2.0.5"
"vite": "^2.9.9"
}
}
22 changes: 11 additions & 11 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import wretch from "wretch";
import { Endpoints } from "@octokit/types";
import { csvParse, tsvParse } from "d3-dsv";
import store from "store2";
import wretch from "wretch";
import YAML from "yaml";

import { Repo, Repository } from "../types";
import { csvParse, tsvParse } from "d3-dsv";
import { Repo } from "../types";

export type listCommitsResponse =
Endpoints["GET /repos/{owner}/{repo}/commits"]["response"];
Expand Down Expand Up @@ -153,13 +152,7 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
"yaml",
];
if (!validTypes.includes(fileType)) return [];
// const githubWretch = cachedPat
// ? wretch(
// `https://raw.githubusercontent.com/${owner}/${name}/${sha}/${filename}`
// ).auth(`token ${cachedPat}`)
// :

let res;
const text = await wretch(
`https://raw.githubusercontent.com/${owner}/${name}/${sha}/${filename}`
)
Expand Down Expand Up @@ -213,14 +206,15 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
} else {
return [
{
content: text,
invalidValue: stringifyValue(text),
},
];
}
} catch (e) {
console.log(e);
return [
{
content: text,
invalidValue: stringifyValue(text),
},
];
Expand All @@ -229,6 +223,7 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
if (typeof data !== "object") {
return [
{
content: text,
invalidValue: stringifyValue(data),
},
];
Expand All @@ -238,6 +233,7 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
if (isArray) {
return [
{
content: text,
value: data,
},
];
Expand All @@ -255,19 +251,22 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
if (!Array.isArray(value)) {
return {
key,
content: text,
invalidValue: stringifyValue(value),
};
}

if (typeof value[0] === "string") {
return {
key,
content: text,
value: value.map((d) => ({ value: d })),
};
}

return {
key,
content: text,
value,
};
});
Expand All @@ -278,6 +277,7 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
});
return [
{
content: text,
value: parsedData,
},
];
Expand Down
Loading