Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .changeset/bright-peas-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/local-explorer-ui": minor
---

Add initial data studio with D1 and Durable Objects support

Adds a data studio interface to the local explorer UI, allowing you to browse and interact with D1 databases and Durable Objects during local development. The studio provides table browsing, query execution, and data editing capabilities.
7 changes: 7 additions & 0 deletions .changeset/loud-taxis-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/unenv-preset": minor
---

Use the native workerd `node:perf_hooks` module and `Performance` global classes when available

They are enabled when the `enable_nodejs_perf_hooks_module` compatibility flag is set. This feature is currently experimental and requires the above flag and `experimental` compatibility flag to be set.
3 changes: 3 additions & 0 deletions codeowners.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ ignore = [".changeset", "fixtures"]
# Show detailed file-to-owner mapping in PR comments
detailed_reviewers = true

# Don't dismiss stale reviews when new changes are pushed
disable_smart_dismissal = true

# Suppress warnings for intentionally unowned files (e.g. pnpm-lock.yaml)
suppress_unowned_warning = true

Expand Down
39 changes: 29 additions & 10 deletions packages/edge-preview-authenticated-proxy/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ function createMockFetchImplementation() {
const request = new Request(input, init);
const url = new URL(request.url);

if (url.origin === "https://workers-logging.cfdata.org") {
// Ignore prometheus logging requests
return new Response("OK", { status: 200 });
}

// Only intercept requests to our mock remote URL
if (url.origin !== MOCK_REMOTE_URL) {
return new Response("OK", { status: 200 });
console.error(`Request to unexpected URL: ${request.url}`);
return new Response("BAD", { status: 500 });
}

if (url.pathname === "/exchange") {
Expand Down Expand Up @@ -80,8 +86,6 @@ afterEach(() => {
});

describe("Preview Worker", () => {
let tokenId: string | null = null;

it("should obtain token from exchange_url", async ({ expect }) => {
const resp = await SELF.fetch(
`https://preview.devprod.cloudflare.dev/exchange?exchange_url=${encodeURIComponent(
Expand Down Expand Up @@ -139,7 +143,7 @@ describe("Preview Worker", () => {
).toMatchInlineSnapshot(
'"token=00000000-0000-0000-0000-000000000000; Domain=random-data.preview.devprod.cloudflare.dev; HttpOnly; Secure; Partitioned; SameSite=None"'
);
tokenId = (resp.headers.get("set-cookie") ?? "")
const tokenId = (resp.headers.get("set-cookie") ?? "")
.split(";")[0]
.split("=")[1];
resp = await SELF.fetch(
Expand All @@ -152,9 +156,7 @@ describe("Preview Worker", () => {
}
);

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignoring this test type error for sake of turborepo PR
const json = (await resp.json()) as any;

const json = await resp.json();
expect(json).toMatchObject({
url: `${MOCK_REMOTE_URL}/`,
headers: expect.arrayContaining([["cf-workers-preview-token", token]]),
Expand All @@ -180,10 +182,22 @@ describe("Preview Worker", () => {
).toMatchInlineSnapshot(
'"token=00000000-0000-0000-0000-000000000000; Domain=random-data.preview.devprod.cloudflare.dev; HttpOnly; Secure; Partitioned; SameSite=None"'
);
tokenId = (resp.headers.get("set-cookie") ?? "")
.split(";")[0]
.split("=")[1];
});

async function getToken() {
const resp = await SELF.fetch(
`https://random-data.preview.devprod.cloudflare.dev/.update-preview-token?token=TEST_TOKEN&prewarm=${encodeURIComponent(
`${MOCK_REMOTE_URL}/prewarm`
)}&remote=${encodeURIComponent(
MOCK_REMOTE_URL
)}&suffix=${encodeURIComponent("/hello?world")}`,
{
method: "GET",
redirect: "manual",
}
);
return (resp.headers.get("set-cookie") ?? "").split(";")[0].split("=")[1];
}
it("should reject invalid prewarm url", async ({ expect }) => {
vi.spyOn(console, "error").mockImplementation(() => {});
const resp = await SELF.fetch(
Expand All @@ -210,6 +224,7 @@ describe("Preview Worker", () => {
});

it("should convert cookie to header", async ({ expect }) => {
const tokenId = await getToken();
const resp = await SELF.fetch(
`https://random-data.preview.devprod.cloudflare.dev`,
{
Expand All @@ -229,6 +244,7 @@ describe("Preview Worker", () => {
});
});
it("should not follow redirects", async ({ expect }) => {
const tokenId = await getToken();
const resp = await SELF.fetch(
`https://random-data.preview.devprod.cloudflare.dev/redirect`,
{
Expand All @@ -247,6 +263,7 @@ describe("Preview Worker", () => {
expect(await resp.text()).toMatchInlineSnapshot('""');
});
it("should return method", async ({ expect }) => {
const tokenId = await getToken();
const resp = await SELF.fetch(
`https://random-data.preview.devprod.cloudflare.dev/method`,
{
Expand All @@ -261,6 +278,7 @@ describe("Preview Worker", () => {
expect(await resp.text()).toMatchInlineSnapshot('"PUT"');
});
it("should return header", async ({ expect }) => {
const tokenId = await getToken();
const resp = await SELF.fetch(
`https://random-data.preview.devprod.cloudflare.dev/header`,
{
Expand All @@ -276,6 +294,7 @@ describe("Preview Worker", () => {
expect(await resp.text()).toMatchInlineSnapshot('"custom"');
});
it("should return status", async ({ expect }) => {
const tokenId = await getToken();
const resp = await SELF.fetch(
`https://random-data.preview.devprod.cloudflare.dev/status`,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default defineWorkersConfig({
},
},
},
retry: 2,
},
resolve: {
// promjs has broken package.json (main points to lib/index.js but files are at root)
Expand Down
7 changes: 7 additions & 0 deletions packages/local-explorer-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@
"@cloudflare/kumo": "^1.5.0",
"@cloudflare/workers-editor-shared": "^0.1.1",
"@codemirror/autocomplete": "^6.20.0",
"@codemirror/commands": "^6.10.2",
"@codemirror/lang-sql": "^6.10.0",
"@codemirror/language": "^6.12.1",
"@codemirror/state": "^6.5.4",
"@codemirror/view": "^6.39.14",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@floating-ui/react": "^0.27.18",
"@lezer/common": "^1.5.1",
"@lezer/highlight": "^1.2.3",
"@phosphor-icons/react": "^2.1.10",
"@tailwindcss/vite": "^4.0.15",
"@tanstack/react-router": "^1.158.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/local-explorer-ui/src/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { CaretRightIcon } from "@phosphor-icons/react";
import { Fragment } from "react";
import type { FC, ReactNode } from "react";
import type { FC, PropsWithChildren, ReactNode } from "react";

interface BreadcrumbsProps {
interface BreadcrumbsProps extends PropsWithChildren {
icon: FC;
items: Array<ReactNode>;
title: string;
}

export function Breadcrumbs({
children,
icon: Icon,
items,
title,
Expand All @@ -26,6 +27,8 @@ export function Breadcrumbs({
{item}
</Fragment>
))}

{children}
</div>
);
}
40 changes: 35 additions & 5 deletions packages/local-explorer-ui/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Collapsible } from "@base-ui/react/collapsible";
import { cn } from "@cloudflare/kumo";
import { CaretRightIcon, DatabaseIcon } from "@phosphor-icons/react";
import { CaretRightIcon, CubeIcon, DatabaseIcon } from "@phosphor-icons/react";
import { Link } from "@tanstack/react-router";
import CloudflareLogo from "../assets/icons/cloudflare-logo.svg?react";
import KVIcon from "../assets/icons/kv.svg?react";
import type { D1DatabaseResponse, WorkersKvNamespace } from "../api";
import type {
D1DatabaseResponse,
WorkersKvNamespace,
WorkersNamespace,
} from "../api";
import type { FileRouteTypes } from "../routeTree.gen";
import type { FC } from "react";

Expand Down Expand Up @@ -92,18 +96,22 @@ interface SidebarProps {
currentPath: string;
d1Error: string | null;
databases: D1DatabaseResponse[];
doError: string | null;
doNamespaces: WorkersNamespace[];
kvError: string | null;
kvNamespaces: WorkersKvNamespace[];
loading: boolean;
namespaces: WorkersKvNamespace[];
}

export function Sidebar({
currentPath,
d1Error,
databases,
doError,
doNamespaces,
kvError,
kvNamespaces,
loading,
namespaces,
}: SidebarProps) {
return (
<aside className="w-sidebar bg-bg-secondary border-r border-border flex flex-col">
Expand All @@ -126,7 +134,7 @@ export function Sidebar({
emptyLabel="No namespaces"
error={kvError}
icon={KVIcon}
items={namespaces.map((ns) => ({
items={kvNamespaces.map((ns) => ({
id: ns.id,
isActive: currentPath === `/kv/${ns.id}`,
label: ns.title,
Expand Down Expand Up @@ -156,6 +164,28 @@ export function Sidebar({
loading={loading}
title="D1 Databases"
/>

<SidebarItemGroup
emptyLabel="No namespaces"
error={doError}
icon={CubeIcon}
items={doNamespaces.map((ns) => {
const className = ns.class ?? ns.name ?? ns.id ?? "Unknown";
return {
id: ns.id as string,
isActive:
currentPath === `/do/${className}` ||
currentPath.startsWith(`/do/${className}/`),
label: className,
link: {
params: { className },
to: "/do/$className",
},
};
})}
loading={loading}
title="Durable Objects"
/>
</aside>
);
}
Loading
Loading