Skip to content

Commit 4e435c5

Browse files
fix: use supported PostgreSQL driver with Hyperdrive (#1487)
1 parent 2ba8162 commit 4e435c5

47 files changed

Lines changed: 1231 additions & 709 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎harness-tests/core/database-context.test.ts‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ vi.mock('~/server/runtime/host.server', () => ({
2323
return true
2424
},
2525
}))
26-
vi.mock('postgres', () => ({
27-
default: vi.fn(() => {
28-
const client = {
29-
execute: vi.fn(async () => []),
30-
end: vi.fn(async () => {}),
26+
vi.mock('pg', () => ({
27+
Pool: class {
28+
constructor() {
29+
const client = {
30+
execute: vi.fn(async () => ({ rows: [] })),
31+
on: vi.fn(),
32+
end: vi.fn(async () => {}),
33+
}
34+
runtime.clients.push(client)
35+
return client
3136
}
32-
runtime.clients.push(client)
33-
return client
34-
}),
37+
},
3538
}))
36-
vi.mock('drizzle-orm/postgres-js', () => ({
39+
vi.mock('drizzle-orm/node-postgres', () => ({
3740
drizzle: (client: { execute: ReturnType<typeof vi.fn> }) => client,
3841
}))
3942

‎harness-tests/core/workspace-sync-publisher.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ beforeEach(() => {
7575
mocks.member.mockImplementation(async () =>
7676
membership ? { generation: membership } : undefined,
7777
)
78-
mocks.execute.mockResolvedValue([{ revision: 1 }])
78+
mocks.execute.mockResolvedValue({ rows: [{ revision: 1 }] })
7979
mocks.fetch.mockImplementation(async (request: Request) => {
8080
if (request.method === 'PUT') return new Response(null, { status: 200 })
8181
if (request.method === 'HEAD')

‎package.json‎

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,25 @@
6363
"deploy:staging": "node scripts/deploy-worker-staging.mjs"
6464
},
6565
"dependencies": {
66+
"@ag-ui/core": "0.1.1-canary.beta.0",
67+
"@babel/parser": "7.29.9",
68+
"@babel/types": "7.29.8",
69+
"@base-ui/react": "^1.8.0",
70+
"@cfworker/json-schema": "^4.1.1",
6671
"@codemirror/lang-css": "^6.3.1",
6772
"@codemirror/lang-html": "^6.4.12",
6873
"@codemirror/lang-javascript": "^6.2.5",
6974
"@codemirror/lang-json": "^6.0.2",
7075
"@codemirror/language": "^6.12.4",
7176
"@codemirror/state": "^6.7.1",
77+
"@dnd-kit/dom": "^0.5.0",
78+
"@dnd-kit/react": "^0.5.0",
79+
"@durable-streams/client": "^0.2.7",
80+
"@durable-streams/server-cloudflare": "^0.1.1",
81+
"@durable-streams/tanstack-ai-transport": "^0.0.10",
7282
"@fingerprintjs/fingerprintjs-pro-react": "^2.7.1",
7383
"@floating-ui/react": "^0.27.19",
84+
"@js-temporal/polyfill": "^0.5.1",
7485
"@lezer/highlight": "^1.2.3",
7586
"@modelcontextprotocol/sdk": "^1.31.0",
7687
"@octokit/graphql": "^9.0.3",
@@ -89,8 +100,15 @@
89100
"@tanstack/ai": "^0.58.0",
90101
"@tanstack/ai-anthropic": "^0.18.6",
91102
"@tanstack/ai-client": "^0.31.1",
103+
"@tanstack/ai-cloudflare": "0.1.5",
104+
"@tanstack/ai-gemini": "0.31.2",
105+
"@tanstack/ai-grok": "0.18.10",
106+
"@tanstack/ai-groq": "0.7.9",
92107
"@tanstack/ai-openai": "^0.22.6",
93108
"@tanstack/ai-openrouter": "^0.19.9",
109+
"@tanstack/ai-react": "^0.27.3",
110+
"@tanstack/ai-typesafe": "0.1.1",
111+
"@tanstack/ai-vercel-gateway": "0.2.16",
94112
"@tanstack/charts": "1.0.0",
95113
"@tanstack/create": "^0.70.1",
96114
"@tanstack/highlight": "^1.0.0",
@@ -130,18 +148,24 @@
130148
"drizzle-orm": "^0.45.2",
131149
"encoding-sniffer": "^0.2.1",
132150
"esbuild-wasm": "0.27.4",
151+
"fflate": "^0.8.3",
133152
"figma-squircle": "^1.1.0",
134153
"gifenc": "^1.0.3",
135154
"gray-matter": "^4.0.3",
136155
"iconv-lite": "^0.7.2",
156+
"jose": "^6.2.12",
137157
"jszip": "^3.10.1",
158+
"linkify-it": "^6.1.0",
138159
"lru-cache": "^11.2.7",
160+
"lucide-react": "^1.49.0",
139161
"maath": "^0.10.8",
140162
"match-sorter": "^8.3.0",
141163
"mermaid": "^11.14.0",
164+
"motion": "^13.4.6",
142165
"octane": "0.1.13",
143166
"parse5": "^7.3.0",
144167
"parse5-parser-stream": "^7.1.2",
168+
"pg": "^8.23.1",
145169
"postgres": "^3.4.8",
146170
"react": "19.2.3",
147171
"react-colorful": "^5.6.1",
@@ -163,33 +187,11 @@
163187
"xstate": "^5.30.0",
164188
"yaml": "^2.9.0",
165189
"zod": "^4.3.6",
166-
"zustand": "^5.0.12",
167-
"@ag-ui/core": "0.1.1-canary.beta.0",
168-
"@babel/parser": "7.29.9",
169-
"@babel/types": "7.29.8",
170-
"@base-ui/react": "^1.8.0",
171-
"@cfworker/json-schema": "^4.1.1",
172-
"@dnd-kit/dom": "^0.5.0",
173-
"@dnd-kit/react": "^0.5.0",
174-
"@durable-streams/client": "^0.2.7",
175-
"@durable-streams/server-cloudflare": "^0.1.1",
176-
"@durable-streams/tanstack-ai-transport": "^0.0.10",
177-
"@js-temporal/polyfill": "^0.5.1",
178-
"@tanstack/ai-cloudflare": "0.1.5",
179-
"@tanstack/ai-gemini": "0.31.2",
180-
"@tanstack/ai-grok": "0.18.10",
181-
"@tanstack/ai-groq": "0.7.9",
182-
"@tanstack/ai-react": "^0.27.3",
183-
"@tanstack/ai-typesafe": "0.1.1",
184-
"@tanstack/ai-vercel-gateway": "0.2.16",
185-
"fflate": "^0.8.3",
186-
"jose": "^6.2.12",
187-
"linkify-it": "^6.1.0",
188-
"lucide-react": "^1.49.0",
189-
"motion": "^13.4.6"
190+
"zustand": "^5.0.12"
190191
},
191192
"devDependencies": {
192193
"@cloudflare/vite-plugin": "^1.62.5",
194+
"@cloudflare/workers-types": "^5.20260930.2",
193195
"@content-collections/core": "^0.14.3",
194196
"@content-collections/vite": "^0.2.9",
195197
"@tanstack/devtools-vite": "^0.7.0",
@@ -200,6 +202,7 @@
200202
"@types/d3-scale": "4.0.9",
201203
"@types/d3-shape": "3.1.8",
202204
"@types/hast": "^3.0.4",
205+
"@types/linkify-it": "^5.0.0",
203206
"@types/node": "^25.5.0",
204207
"@types/pg": "^8.20.0",
205208
"@types/react": "^19.2.14",
@@ -211,6 +214,7 @@
211214
"drizzle-kit": "^0.31.10",
212215
"esbuild": "^0.27.4",
213216
"husky": "^9.1.7",
217+
"miniflare": "5.20260921.0-alpha",
214218
"npm-run-all": "^4.1.5",
215219
"oxfmt": "^0.43.0",
216220
"oxlint": "^1.58.0",
@@ -223,11 +227,8 @@
223227
"tsx": "^4.21.0",
224228
"typescript": "^6.0.2",
225229
"vite": "^8.0.16",
226-
"wrangler": "^4.147.0",
227-
"@cloudflare/workers-types": "^5.20260930.2",
228-
"@types/linkify-it": "^5.0.0",
229-
"miniflare": "5.20260921.0-alpha",
230-
"vitest": "^4.1.11"
230+
"vitest": "^4.1.11",
231+
"wrangler": "^4.147.0"
231232
},
232233
"engines": {
233234
"node": ">=22.12.0"

‎pnpm-lock.yaml‎

Lines changed: 66 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/chat/server/assistant-conversation-tools.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ export class AssistantConversations {
8585
userId: this.scope.userId,
8686
conversationId: conversationId ?? current.conversationId,
8787
})
88-
const [main] = await db.execute(
89-
sql`SELECT 1 FROM chat_conversation_mains WHERE conversation_id=${identity.conversationId} AND bot_id=${identity.botId} AND user_id=${identity.userId}`,
90-
)
88+
const [main] = (
89+
await db.execute(
90+
sql`SELECT 1 FROM chat_conversation_mains WHERE conversation_id=${identity.conversationId} AND bot_id=${identity.botId} AND user_id=${identity.userId}`,
91+
)
92+
).rows
9193
if (!main)
9294
throw new BotWorkspaceError(
9395
'Thread settings are not available through this tool. No parent conversation was changed.',

‎src/chat/server/bootstrap-workspace-data.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ export async function readBootstrapWorkspaceData(
1616
userId: string,
1717
) {
1818
const policy = await readWorkspacePolicy(workspaceId, userId)
19-
const [workspace] = await db.execute<
20-
{ id: string; name: string } & Record<string, unknown>
21-
>(
22-
sql`SELECT w.id,w.name FROM chat_workspaces w JOIN chat_memberships m ON m.workspace_id=w.id WHERE w.id=${workspaceId} AND m.user_id=${userId}`,
23-
)
19+
const [workspace] = (
20+
await db.execute<{ id: string; name: string } & Record<string, unknown>>(
21+
sql`SELECT w.id,w.name FROM chat_workspaces w JOIN chat_memberships m ON m.workspace_id=w.id WHERE w.id=${workspaceId} AND m.user_id=${userId}`,
22+
)
23+
).rows
2424
if (!workspace) throw new WorkspacePolicyError()
2525
const [bots, sections, activity, recipes, workspaces] = await Promise.all([
2626
readWorkspaceBots(workspaceId, userId),
2727
readBotSections(workspaceId, userId),
2828
workspaceActivity(workspaceId, userId),
2929
new SavedActions(workspaceId, userId).list(),
30-
db.execute<{ id: string; name: string } & Record<string, unknown>>(
31-
sql`SELECT w.id,w.name FROM chat_workspaces w JOIN chat_memberships m ON m.workspace_id=w.id WHERE m.user_id=${userId} ORDER BY w.name,w.id`,
32-
),
30+
db
31+
.execute<{ id: string; name: string } & Record<string, unknown>>(
32+
sql`SELECT w.id,w.name FROM chat_workspaces w JOIN chat_memberships m ON m.workspace_id=w.id WHERE m.user_id=${userId} ORDER BY w.name,w.id`,
33+
)
34+
.then((result) => result.rows),
3335
])
3436
return {
3537
workspace,

‎src/chat/server/bootstrap.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ export async function readBootstrap(
4040
readCredentials(env, user.userId),
4141
readKodyUsername(user.userId),
4242
fundedSpendReport(user.userId),
43-
db.execute<{ turns: number } & Record<string, unknown>>(
44-
sql`SELECT turns::float8 AS turns FROM chat_daily_usage WHERE user_id=${user.userId} AND day=${new Date().toISOString().slice(0, 10)}`,
45-
),
43+
db
44+
.execute<{ turns: number } & Record<string, unknown>>(
45+
sql`SELECT turns::float8 AS turns FROM chat_daily_usage WHERE user_id=${user.userId} AND day=${new Date().toISOString().slice(0, 10)}`,
46+
)
47+
.then((result) => result.rows),
4648
hasUnlimitedUsage(user.userId, env.UNLIMITED_USAGE_EMAILS),
4749
])
4850
const assistantId = `assistant:${user.userId}`

0 commit comments

Comments
 (0)