From 2f4b47cf0af2d5dc4387d9b016181ddf43cec9da Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Wed, 21 May 2025 23:39:08 -0700 Subject: [PATCH] chore: update examples for new client --- docs/examples/chat.mdx | 5 +---- examples/chat-room/scripts/cli.ts | 2 +- examples/chat-room/scripts/connect.ts | 2 +- examples/chat-room/tests/chat-room.test.ts | 2 +- examples/counter/tests/counter.test.ts | 2 +- examples/linear-coding-agent/src/server/index.ts | 2 +- examples/resend-streaks/tests/user.test.ts | 2 +- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/examples/chat.mdx b/docs/examples/chat.mdx index 82dae9cdb..fa1d67683 100644 --- a/docs/examples/chat.mdx +++ b/docs/examples/chat.mdx @@ -319,10 +319,7 @@ Add the form submit handler to your init function: async function init() { // Connect to chat room with channel tag - const chatRoom = await client.get({ - name: 'chat-room', - channel, // Use channel as a tag to separate different chat rooms - }); + const chatRoom = await client.chatRoom.getOrCreate(channel); // Store reference for use in event handlers // In a production app, you'd use a more encapsulated approach diff --git a/examples/chat-room/scripts/cli.ts b/examples/chat-room/scripts/cli.ts index 3d5f1278d..bf2479f6b 100644 --- a/examples/chat-room/scripts/cli.ts +++ b/examples/chat-room/scripts/cli.ts @@ -10,7 +10,7 @@ async function main() { // connect to chat room - now accessed via property // can still pass parameters like room - const chatRoom = client.chatRoom.get(room, { + const chatRoom = client.chatRoom.getOrCreate(room, { params: { room }, }).connect(); diff --git a/examples/chat-room/scripts/connect.ts b/examples/chat-room/scripts/connect.ts index 967ff84e2..c6808a219 100644 --- a/examples/chat-room/scripts/connect.ts +++ b/examples/chat-room/scripts/connect.ts @@ -7,7 +7,7 @@ async function main() { const client = createClient(process.env.ENDPOINT ?? "http://localhost:6420"); // connect to chat room - now accessed via property - const chatRoom = client.chatRoom.get().connect(); + const chatRoom = client.chatRoom.getOrCreate().connect(); // call action to get existing messages const messages = await chatRoom.getHistory(); diff --git a/examples/chat-room/tests/chat-room.test.ts b/examples/chat-room/tests/chat-room.test.ts index 791ceffbb..11788eb68 100644 --- a/examples/chat-room/tests/chat-room.test.ts +++ b/examples/chat-room/tests/chat-room.test.ts @@ -6,7 +6,7 @@ test("chat room should handle messages", async (test) => { const { client } = await setupTest(test, app); // Connect to chat room - const chatRoom = client.chatRoom.get().connect(); + const chatRoom = client.chatRoom.getOrCreate().connect(); // Initial history should be empty const initialMessages = await chatRoom.getHistory(); diff --git a/examples/counter/tests/counter.test.ts b/examples/counter/tests/counter.test.ts index b0ee8c2f1..5a58d57b4 100644 --- a/examples/counter/tests/counter.test.ts +++ b/examples/counter/tests/counter.test.ts @@ -4,7 +4,7 @@ import { app } from "../actors/app"; test("it should count", async (test) => { const { client } = await setupTest(test, app); - const counter = client.counter.get().connect(); + const counter = client.counter.getOrCreate().connect(); // Test initial count expect(await counter.getCount()).toBe(0); diff --git a/examples/linear-coding-agent/src/server/index.ts b/examples/linear-coding-agent/src/server/index.ts index f3dcd45bf..86b73ec4a 100644 --- a/examples/linear-coding-agent/src/server/index.ts +++ b/examples/linear-coding-agent/src/server/index.ts @@ -95,7 +95,7 @@ server.post("/api/webhook/linear", async (c) => { // Create or get a coding agent instance with the issue ID as a key // This ensures each issue gets its own actor instance console.log(`[SERVER] Getting actor for issue: ${issueId}`); - const actorClient = client.codingAgent.get(issueId).connect(); + const actorClient = client.codingAgent.getOrCreate(issueId).connect(); // Initialize the agent if needed console.log(`[SERVER] Initializing actor for issue: ${issueId}`); diff --git a/examples/resend-streaks/tests/user.test.ts b/examples/resend-streaks/tests/user.test.ts index ce9cc2f84..2736133bb 100644 --- a/examples/resend-streaks/tests/user.test.ts +++ b/examples/resend-streaks/tests/user.test.ts @@ -26,7 +26,7 @@ beforeEach(() => { test("streak tracking with time zone signups", async (t) => { const { client } = await setupTest(t, app); - const actor = client.user.get().connect(); + const actor = client.user.getOrCreate().connect(); // Sign up with specific time zone const signupResult = await actor.completeSignUp(