Skip to content

Commit

Permalink
Merge branch 'develop' into experimental-standable-react
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Nov 7, 2024
2 parents df0b1e1 + 51ed73f commit d462d91
Show file tree
Hide file tree
Showing 61 changed files with 1,413 additions and 346 deletions.
5 changes: 4 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const config: Config = {
coveragePathIgnorePatterns: ["<rootDir>/.*.tsx$"],
globals: {
window: {},
},
testEnvironment: "node",
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
Expand Down
7 changes: 7 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import crypto from "crypto";

Object.defineProperty(window, "crypto", {
value: {
randomUUID: crypto.randomUUID,
},
});
60 changes: 47 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-sql": "^6.5.5",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@justmiracle/result": "^1.2.0",
"@lezer/common": "^1.2.1",
Expand Down Expand Up @@ -79,14 +80,16 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^0.2.0",
"cookies-next": "^4.1.1",
"cookies-next": "^4.3.0",
"deep-equal": "^2.2.3",
"dexie": "^4.0.8",
"dotenv": "^16.4.5",
"drizzle-orm": "^0.30.1",
"eslint-plugin-jest": "^27.6.3",
"file-saver": "^2.0.5",
"immer": "^10.1.1",
"libsql-stateless-easy": "^1.6.11",
"lodash": "^4.17.21",
"lucia": "^3.2.0",
"lucide-react": "^0.309.0",
"magic-bytes.js": "^1.10.0",
Expand All @@ -107,6 +110,7 @@
"@types/deep-equal": "^1.0.4",
"@types/file-saver": "^2.0.7",
"@types/jest": "^29.5.11",
"@types/lodash": "^4.17.9",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
4 changes: 1 addition & 3 deletions src/app/(public)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ function SupportDriver() {
<DatabaseBlock center link="#">
<PostgreIcon />
<span>PostgreSQL</span>
<span className="text-xs -mt-2 text-yellow-500">
Coming Soon 7th Oct 2024
</span>
<span className="text-xs -mt-2 text-yellow-500">Coming Soon</span>
</DatabaseBlock>

<DatabaseBlock center link="/databases/mysql">
Expand Down
7 changes: 7 additions & 0 deletions src/app/(theme)/client/[[...driver]]/page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ValtownDriver from "@/drivers/valtown-driver";

import MyStudio from "@/components/my-studio";
import CloudflareD1Driver from "@/drivers/cloudflare-d1-driver";
import StarbaseDriver from "@/drivers/starbase-driver";

export default function ClientPageBody() {
const driver = useMemo(() => {
Expand All @@ -27,7 +28,13 @@ export default function ClientPageBody() {
"x-account-id": config.username ?? "",
"x-database-id": config.database ?? "",
});
} else if (config.driver === "starbase") {
return new StarbaseDriver("/proxy/starbase", {
Authorization: "Bearer " + (config.token ?? ""),
"x-starbase-url": config.url ?? "",
});
}

return new TursoDriver(config.url, config.token as string, true);
}, []);

Expand Down
6 changes: 6 additions & 0 deletions src/app/(theme)/client/s/[[...driver]]/page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useMemo } from "react";
import MyStudio from "@/components/my-studio";
import IndexdbSavedDoc from "@/drivers/saved-doc/indexdb-saved-doc";
import CloudflareD1Driver from "@/drivers/cloudflare-d1-driver";
import StarbaseDriver from "@/drivers/starbase-driver";

export default function ClientPageBody() {
const params = useSearchParams();
Expand Down Expand Up @@ -35,6 +36,11 @@ export default function ClientPageBody() {
"x-account-id": conn.config.username ?? "",
"x-database-id": conn.config.database ?? "",
});
} else if (conn.driver === "starbase") {
return new StarbaseDriver("/proxy/starbase", {
Authorization: "Bearer " + (conn.config.token ?? ""),
"x-starbase-url": conn.config.url ?? "",
});
}

return new TursoDriver(conn.config.url, conn.config.token, true);
Expand Down
12 changes: 12 additions & 0 deletions src/app/(theme)/connect/driver-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
MySQLIcon,
RqliteIcon,
SQLiteIcon,
StarbaseIcon,
TursoIcon,
ValtownIcon,
} from "@/components/icons/outerbase-icon";
Expand Down Expand Up @@ -84,6 +85,17 @@ export default function DriverDropdown({
</div>
</DropdownMenuItem>

<DropdownMenuItem
onClick={() => {
onSelect("starbase");
}}
>
<div className="flex gap-4 px-2 items-center h-8">
<StarbaseIcon className="w-6 h-6" />
<div className="font-semibold">StarbaseDB</div>
</div>
</DropdownMenuItem>

<DropdownMenuSeparator />

<DropdownMenuItem
Expand Down
12 changes: 7 additions & 5 deletions src/app/(theme)/connect/saved-connection-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ export default function ConnectionItemCard({
: `/client/r?p=${conn.id}`
}
>
<div className="py-4 shrink-0 ml-3 mr-2 flex flex-col gap-3">
<div className="flex gap-2">
<div className="w-10 h-10 bg-accent flex justify-center items-center rounded">
<div className="py-4 shrink-0 ml-3 mr-2 flex flex-col gap-3 flex-1">
<div className="flex gap-2 overflow-hidden">
<div className="w-10 h-10 bg-accent flex justify-center items-center rounded flex-shrink-0">
<DatabaseIcon className="w-6 h-6 text-accent-foreground" />
</div>

<div>
<div className="line-clamp-1 text-primary">{conn.name}</div>
<div className="flex-1">
<div className="text-primary text-ellipsis overflow-hidden whitespace-nowrap w-[220px]">
{conn.name}
</div>
<div className="text-xs text-muted-foreground">
{DRIVER_DETAIL[conn.driver ?? "turso"].displayName}
</div>
Expand Down
38 changes: 38 additions & 0 deletions src/app/(theme)/connect/saved-connection-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CloudflareIcon,
RqliteIcon,
SQLiteIcon,
StarbaseIcon,
TursoIcon,
ValtownIcon,
} from "@/components/icons/outerbase-icon";
Expand Down Expand Up @@ -91,6 +92,41 @@ export const DRIVER_DETAIL: Record<SupportedDriver, DriverDetail> =
},
],
},
starbase: {
name: "starbase",
displayName: "StarbaseDB",
icon: StarbaseIcon,
disableRemote: true,
prefill: "",
fields: [
{
name: "url",
title: "Endpoint",
required: true,
type: "text",
secret: false,
invalidate: (url: string): null | string => {
const trimmedUrl = url.trim();
const valid =
trimmedUrl.startsWith("https://") ||
trimmedUrl.startsWith("http://");

if (!valid) {
return "Endpoint must start with https:// or http://";
}

return null;
},
},
{
name: "token",
title: "API Token",
required: true,
type: "text",
secret: true,
},
],
},
"cloudflare-d1": {
name: "cloudflare-d1",
displayName: "Cloudflare D1",
Expand Down Expand Up @@ -211,8 +247,10 @@ export type SupportedDriver =
| "turso"
| "rqlite"
| "valtown"
| "starbase"
| "cloudflare-d1"
| "sqlite-filehandler";

export type SavedConnectionStorage = "remote" | "local";
export type SavedConnectionLabel = "gray" | "red" | "yellow" | "green" | "blue";

Expand Down
25 changes: 25 additions & 0 deletions src/app/(theme)/embed/starbase/page-client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";
import { Studio } from "@/components/gui/studio";
import { IframeSQLiteDriver } from "@/drivers/iframe-driver";
import { useSearchParams } from "next/navigation";
import { useEffect, useMemo } from "react";

export default function EmbedPageClient() {
const searchParams = useSearchParams();
const driver = useMemo(
() => new IframeSQLiteDriver({ supportPragmaList: false }),
[]
);

useEffect(() => {
return driver.listen();
}, [driver]);

return (
<Studio
driver={driver}
name={searchParams.get("name") || "Unnamed Connection"}
color={searchParams.get("color") || "blue"}
/>
);
}
10 changes: 10 additions & 0 deletions src/app/(theme)/embed/starbase/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import ThemeLayout from "../../theme_layout";
import EmbedPageClient from "./page-client";

export default async function EmbedPage() {
return (
<ThemeLayout overrideTheme={"dark"} disableToggle={true}>
<EmbedPageClient />
</ThemeLayout>
);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/app/fonts/a
Binary file not shown.
Binary file added src/app/fonts/d.woff
Binary file not shown.
Binary file added src/app/fonts/l
Binary file not shown.
Loading

0 comments on commit d462d91

Please sign in to comment.