Skip to content

Commit 71eb5b9

Browse files
committed
Upgrade to to the latest electric sql client and server
1 parent 75f83a2 commit 71eb5b9

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

apps/webapp/app/services/realtimeClient.server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class RealtimeClient {
7070
#constructElectricUrl(url: URL | string, whereClause: string): URL {
7171
const $url = new URL(url.toString());
7272

73-
const electricUrl = new URL(`${this.options.electricOrigin}/v1/shape/public."TaskRun"`);
73+
const electricUrl = new URL(`${this.options.electricOrigin}/v1/shape`);
7474

7575
// Copy over all the url search params to the electric url
7676
$url.searchParams.forEach((value, key) => {
@@ -86,6 +86,7 @@ export class RealtimeClient {
8686
// });
8787

8888
electricUrl.searchParams.set("where", whereClause);
89+
electricUrl.searchParams.set("table", 'public."TaskRun"');
8990

9091
return electricUrl;
9192
}
@@ -231,7 +232,7 @@ export class RealtimeClient {
231232
}
232233

233234
function extractShapeId(url: URL) {
234-
return url.searchParams.get("shape_id");
235+
return url.searchParams.get("handle");
235236
}
236237

237238
function isLiveRequestUrl(url: URL) {

apps/webapp/test/realtimeClient.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ describe("RealtimeClient", () => {
8686

8787
const headers = Object.fromEntries(response.headers.entries());
8888

89-
const shapeId = headers["electric-shape-id"];
90-
const chunkOffset = headers["electric-chunk-last-offset"];
89+
console.log(headers);
90+
91+
const shapeId = headers["electric-handle"];
92+
const chunkOffset = headers["electric-offset"];
9193

9294
expect(response.status).toBe(200);
9395
expect(response2.status).toBe(200);
@@ -96,15 +98,15 @@ describe("RealtimeClient", () => {
9698

9799
// Okay, now we will do two live requests, and the second one should fail because of the concurrency limit
98100
const liveResponsePromise = client.streamRun(
99-
`http://localhost:3000?offset=0_0&live=true&shape_id=${shapeId}`,
101+
`http://localhost:3000?offset=0_0&live=true&handle=${shapeId}`,
100102
environment,
101103
run.id
102104
);
103105

104106
const liveResponsePromise2 = new Promise<Response>((resolve) => {
105107
setTimeout(async () => {
106108
const response = await client.streamRun(
107-
`http://localhost:3000?offset=0_0&live=true&shape_id=${shapeId}`,
109+
`http://localhost:3000?offset=0_0&live=true&handle=${shapeId}`,
108110
environment,
109111
run.id
110112
);
@@ -200,8 +202,8 @@ describe("RealtimeClient", () => {
200202

201203
const headers = Object.fromEntries(response.headers.entries());
202204

203-
const shapeId = headers["electric-shape-id"];
204-
const chunkOffset = headers["electric-chunk-last-offset"];
205+
const shapeId = headers["electric-handle"];
206+
const chunkOffset = headers["electric-offset"];
205207

206208
expect(response.status).toBe(200);
207209
expect(shapeId).toBeDefined();

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ services:
6161
- 6379:6379
6262

6363
electric:
64-
image: electricsql/electric:0.7.5
64+
image: electricsql/electric:0.8.1
6565
restart: always
6666
environment:
6767
DATABASE_URL: postgresql://postgres:postgres@database:5432/postgres?sslmode=disable

internal-packages/testcontainers/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function createElectricContainer(
5555
network.getName()
5656
)}:5432/${postgresContainer.getDatabase()}?sslmode=disable`;
5757

58-
const container = await new GenericContainer("electricsql/electric:0.7.5")
58+
const container = await new GenericContainer("electricsql/electric:0.8.1")
5959
.withExposedPorts(3000)
6060
.withNetwork(network)
6161
.withEnvironment({

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
"check-exports": "attw --pack ."
183183
},
184184
"dependencies": {
185-
"@electric-sql/client": "0.6.3",
185+
"@electric-sql/client": "0.7.1",
186186
"@google-cloud/precise-date": "^4.0.0",
187187
"@jsonhero/path": "^1.0.21",
188188
"@opentelemetry/api": "1.9.0",

packages/core/src/v3/apiClient/stream.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export async function zodShapeStream<TShapeSchema extends z.ZodTypeAny>(
2323

2424
const shape = new Shape(stream);
2525

26-
const initialValue = await shape.value;
26+
const initialRows = await shape.rows;
2727

28-
for (const shapeRow of initialValue.values()) {
28+
for (const shapeRow of initialRows) {
2929
await callback(schema.parse(shapeRow));
3030
}
3131

3232
return shape.subscribe(async (newShape) => {
33-
for (const shapeRow of newShape.values()) {
33+
for (const shapeRow of newShape.rows) {
3434
await callback(schema.parse(shapeRow));
3535
}
3636
});

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)