feat: Step 6 - Write-through cache API
Implement the core write-through cache pattern for node creation. This is the architectural foundation of the application. Changes: - Add @google/generative-ai dependency for embeddings - Create lib/db.ts: SurrealDB connection helper with JWT auth - Create lib/ai.ts: AI embedding generation using text-embedding-004 - Create app/api/nodes/route.ts: POST endpoint implementing write-through cache Write-through cache flow: 1. Authenticate user via SurrealDB JWT 2. Publish node to ATproto PDS (source of truth) 3. Generate 768-dimensional embedding via Google AI 4. Cache node + embedding + links in SurrealDB Updated schema to use 768-dimensional embeddings (text-embedding-004) instead of 1536 dimensions. Security: - Row-level permissions enforced via SurrealDB JWT - All secrets server-side only - ATproto OAuth tokens from secure cookies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -32,3 +32,23 @@ test('[Happy Path] User initiates OAuth flow', async (agent) => {
|
||||
// Note: Using http://localhost/ as client_id (per ATproto OAuth spec) allows local development.
|
||||
// See: https://atproto.com/specs/oauth#localhost-client-development
|
||||
});
|
||||
|
||||
test('[Happy Path] User completes full login flow and sees their handle', async (agent) => {
|
||||
await agent.act('Navigate to /login');
|
||||
await agent.act(`Type "${TEST_HANDLE}" into the "Your Handle" input field`);
|
||||
await agent.act('Click the "Log in with Bluesky" button');
|
||||
|
||||
// Wait to be redirected to Bluesky OAuth page
|
||||
await agent.check('The page URL contains "bsky.social"');
|
||||
|
||||
// Log in to Bluesky (this will depend on the actual OAuth flow)
|
||||
// The agent should handle the login form on Bluesky's side
|
||||
await agent.act(`Type "${TEST_HANDLE}" into the username/identifier field`);
|
||||
await agent.act(`Type "${TEST_PASSWORD}" into the password field`);
|
||||
await agent.act('Click the submit/authorize button');
|
||||
|
||||
// After successful OAuth, we should be redirected back to /chat
|
||||
// and see our Bluesky handle displayed on the page
|
||||
await agent.check(`The text "${TEST_HANDLE}" is visible on the screen`);
|
||||
await agent.check('The page URL contains "/chat"');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user