diff --git a/clients/typescript/src/client/model/index.ts b/clients/typescript/src/client/model/index.ts index b66db68ec1..b8063587a0 100644 --- a/clients/typescript/src/client/model/index.ts +++ b/clients/typescript/src/client/model/index.ts @@ -3,5 +3,4 @@ export type { ClientTables } from './client' export type { TableSchema } from './schema' export { DbSchema, Relation } from './schema' export { Table } from './table' -export type { HKT } from '../util/hkt' -export { ShapeManager } from './shapes' \ No newline at end of file +export type { HKT } from '../util/hkt' \ No newline at end of file diff --git a/clients/typescript/src/satellite/index.ts b/clients/typescript/src/satellite/index.ts index ae31c80ea9..3fcf0794c5 100644 --- a/clients/typescript/src/satellite/index.ts +++ b/clients/typescript/src/satellite/index.ts @@ -73,7 +73,6 @@ export interface Satellite { shapeDefinitions: ClientShapeDefinition[] ): Promise unsubscribe(shapeUuid: string): Promise - mutexSnapshot(): Promise } export interface Client { diff --git a/clients/typescript/src/satellite/mock.ts b/clients/typescript/src/satellite/mock.ts index d96e5a29f2..127ec833da 100644 --- a/clients/typescript/src/satellite/mock.ts +++ b/clients/typescript/src/satellite/mock.ts @@ -101,10 +101,6 @@ export class MockSatelliteProcess implements Satellite { async stop(): Promise { await sleepAsync(50) } - - async mutexSnapshot(): Promise { - return new Date() - } } export class MockRegistry extends BaseRegistry { diff --git a/clients/typescript/src/satellite/process.ts b/clients/typescript/src/satellite/process.ts index ca0da901ad..79bc2b9c5a 100644 --- a/clients/typescript/src/satellite/process.ts +++ b/clients/typescript/src/satellite/process.ts @@ -194,7 +194,7 @@ export class SatelliteProcess implements Satellite { /** * Perform a snapshot while taking out a mutex to avoid concurrent calls. */ - async mutexSnapshot(): Promise { + private async mutexSnapshot() { const release = await this.snapshotMutex.acquire() try { return await this._performSnapshot() diff --git a/examples/node-sidecar/sidecar/package.json b/examples/node-sidecar/sidecar/package.json index 73fc4ff2ed..c0e0f838cf 100644 --- a/examples/node-sidecar/sidecar/package.json +++ b/examples/node-sidecar/sidecar/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "better-sqlite3": "^9.2.2", - "electric-sql": "^0.8.3" + "electric-sql": "^0.8.2" }, "devDependencies": { "@electric-sql/prisma-generator": "^1.1.2", diff --git a/examples/node-sidecar/sidecar/src/sidecar.ts b/examples/node-sidecar/sidecar/src/sidecar.ts index 68d5d93140..1650622535 100644 --- a/examples/node-sidecar/sidecar/src/sidecar.ts +++ b/examples/node-sidecar/sidecar/src/sidecar.ts @@ -7,7 +7,6 @@ import { HydratedConfig, Shape } from './util/config.js' export class SideCar { private electric?: ElectricClient - private shapeManager?: ShapeManager constructor(private config: HydratedConfig, private ipc: Server) {} @@ -23,9 +22,6 @@ export class SideCar { const schema = new DbSchema({}, []) // empty DB schema, we won't use the client anyway this.electric = await electrify(conn, schema, config) - const shapeManager = new ShapeManager(this.electric.satellite) - this.shapeManager = shapeManager - // Sync shapes await this.syncShapes() @@ -34,7 +30,7 @@ export class SideCar { // Perform snapshot on potential data change await this.ipc.onPotentialDataChange( - this.performSnapshot.bind(this) + this.potentiallyChanged.bind(this) ) // Notify clients of actual data changes @@ -52,20 +48,23 @@ export class SideCar { ) } - async performSnapshot(): Promise { - await this.electric?.satellite.mutexSnapshot() + private async potentiallyChanged(): Promise { + await this.electric?.notifier.potentiallyChanged() } - async syncShapes(): Promise { - if (!this.shapeManager) { - throw new Error("Shape manager not initialized") - } - + private async syncShapes(): Promise { + // Convert the shape to the format expected by the Satellite process const { sync: tables } = this.config + const shapeDef = { + selects: tables.map((tbl) => ({ tablename: tbl })), + } + const joinedNames = tables.join(', ') console.log(`Syncing tables ${joinedNames}...`) - const { synced } = await this.shapeManager.sync({ tables }) + + const { synced } = await this.electric!.satellite.subscribe([shapeDef]) await synced + console.log(`Synced tables ${joinedNames}`) } } \ No newline at end of file