File tree Expand file tree Collapse file tree
packages/typescript-client/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @electric-sql/client ' : minor
3+ ---
4+
5+ feat: denote end of injected subset snapshot with an additional message
Original file line number Diff line number Diff line change 77 GetExtensions ,
88 ChangeMessage ,
99 SnapshotMetadata ,
10+ SubsetParams ,
1011} from './types'
1112import { MessageParser , Parser , TransformFunction } from './parser'
1213import { ColumnMapper , encodeWhereClause } from './column-mapper'
@@ -128,14 +129,6 @@ export type ExternalParamsRecord<T extends Row<unknown> = Row> = {
128129 [ K in string ] : ParamValue | undefined
129130} & Partial < PostgresParams < T > > & { [ K in ReservedParamKeys ] ?: never }
130131
131- export type SubsetParams = {
132- where ?: string
133- params ?: Record < string , string >
134- limit ?: number
135- offset ?: number
136- orderBy ?: string
137- }
138-
139132type ReservedParamKeys =
140133 | typeof LIVE_CACHE_BUSTER_QUERY_PARAM
141134 | typeof SHAPE_HANDLE_QUERY_PARAM
@@ -1457,6 +1450,7 @@ export class ShapeStream<T extends Row<unknown> = Row>
14571450
14581451 const dataWithEndBoundary = ( data as Array < Message < T > > ) . concat ( [
14591452 { headers : { control : `snapshot-end` , ...metadata } } ,
1453+ { headers : { control : `subset-end` , ...opts } } ,
14601454 ] )
14611455
14621456 this . #snapshotTracker. addSnapshot (
Original file line number Diff line number Diff line change @@ -66,11 +66,9 @@ export function isUpToDateMessage<T extends Row<unknown> = Row>(
6666 * If we are not in SSE mode this function will return undefined.
6767 */
6868export function getOffset ( message : ControlMessage ) : Offset | undefined {
69+ if ( message . headers . control != 'up-to-date' ) return
6970 const lsn = message . headers . global_last_seen_lsn
70- if ( ! lsn ) {
71- return
72- }
73- return `${ lsn } _0` as Offset
71+ return lsn ? ( `${ lsn } _0` as Offset ) : undefined
7472}
7573
7674/**
Original file line number Diff line number Diff line change @@ -68,13 +68,22 @@ export type MoveTag = string
6868 */
6969export type MoveOutPattern = { pos : number ; value : string }
7070
71+ export type SubsetParams = {
72+ where ?: string
73+ params ?: Record < string , string >
74+ limit ?: number
75+ offset ?: number
76+ orderBy ?: string
77+ }
78+
7179export type ControlMessage = {
7280 headers :
7381 | ( Header & {
7482 control : `up-to-date` | `must-refetch`
7583 global_last_seen_lsn ?: string
7684 } )
7785 | ( Header & { control : `snapshot-end` } & PostgresSnapshot )
86+ | ( { control : `subset-end` } & SubsetParams )
7887}
7988
8089export type EventMessage = {
You can’t perform that action at this time.
0 commit comments