@@ -43,10 +43,28 @@ export type NormalizedPgSnapshot = {
4343}
4444
4545interface Header {
46- [ key : Exclude < string , `operation` | `control`> ] : Value
46+ [ key : Exclude < string , `operation` | `control` | `event` > ] : Value
4747}
4848
4949export type Operation = `insert` | `update` | `delete`
50+ /**
51+ * A tag is a list of string identifying a reason for this row to be part of the shape.
52+ *
53+ * Tags can be composite, which is why they are a list. Within one shape, tag width is fixed and
54+ * is dependent on the where clause, so it's functionally always a tuple.
55+ *
56+ * Actual values within the tuple must be considered opaque and should only be used for direct comparisons
57+ * with move-out patterns. Tag value can never be a literal `"*"`.
58+ */
59+ export type MoveTag = string [ ]
60+
61+ /**
62+ * A move-out pattern is a list of strings with at least one non-wildcard element specifying which
63+ * rows will no longer be part of the shape.
64+ *
65+ * Actual values within the tuple must be considered opaque if they are not a literal `"*"`.
66+ */
67+ export type MoveOutPattern = ( string | `*`) [ ]
5068
5169export type ControlMessage = {
5270 headers :
@@ -57,16 +75,26 @@ export type ControlMessage = {
5775 | ( Header & { control : `snapshot-end` } & PostgresSnapshot )
5876}
5977
78+ export type EventMessage = {
79+ headers : Header & { event : `move-out`; patterns : MoveOutPattern [ ] }
80+ }
81+
6082export type ChangeMessage < T extends Row < unknown > = Row > = {
6183 key : string
6284 value : T
6385 old_value ?: Partial < T > // Only provided for updates if `replica` is `full`
64- headers : Header & { operation : Operation ; txids ?: number [ ] }
86+ headers : Header & {
87+ operation : Operation
88+ txids ?: number [ ]
89+ tags ?: MoveTag [ ]
90+ removed_tags ?: MoveTag [ ]
91+ }
6592}
6693
6794// Define the type for a record
6895export type Message < T extends Row < unknown > = Row > =
6996 | ControlMessage
97+ | EventMessage
7098 | ChangeMessage < T >
7199
72100/**
0 commit comments