Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/move-in-event-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@electric-sql/client': patch
---

Add move-in event support to the TypeScript client. Rename `MoveOutPattern` to `MovePattern` (with a deprecated alias for backwards compatibility), extend `EventMessage` to accept both `move-out` and `move-in` events, and add `active_conditions` field to `ChangeMessage` headers.
12 changes: 8 additions & 4 deletions packages/typescript-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ export type Operation = `insert` | `update` | `delete`
export type MoveTag = string

/**
* A move-out pattern is a position and a value. The position is the index of the column
* that is being moved out. The value is the value of the column that is being moved out.
* A move pattern is a position and a value. The position is the index of the column
* involved in the move. The value is the value of that column.
*
* Tag width and value order is fixed for a given shape, so the client can determine
* which tags match this pattern.
*/
export type MoveOutPattern = { pos: number; value: string }
export type MovePattern = { pos: number; value: string }

/** @deprecated Use {@link MovePattern} instead */
export type MoveOutPattern = MovePattern

/**
* Serialized expression types for structured subset queries.
Expand Down Expand Up @@ -125,7 +128,7 @@ export type ControlMessage = {
}

export type EventMessage = {
headers: Header & { event: `move-out`; patterns: MoveOutPattern[] }
headers: Header & { event: `move-out` | `move-in`; patterns: MovePattern[] }
}

export type ChangeMessage<T extends Row<unknown> = Row> = {
Expand All @@ -138,6 +141,7 @@ export type ChangeMessage<T extends Row<unknown> = Row> = {
/** Tags will always be present for changes if the shape has a subquery in its where clause, and are omitted otherwise.*/
tags?: MoveTag[]
removed_tags?: MoveTag[]
active_conditions?: boolean[]
}
}

Expand Down
Loading