@@ -65,6 +65,10 @@ export type RealtimeRunsParams = {
6565 createdAt ?: string ;
6666} ;
6767
68+ export type RealtimeRequestOptions = {
69+ skipColumns ?: string [ ] ;
70+ } ;
71+
6872export class RealtimeClient {
6973 private redis : RedisClient ;
7074 private expiryTimeInSeconds : number ;
@@ -124,15 +128,17 @@ export class RealtimeClient {
124128 url : URL | string ,
125129 environment : RealtimeEnvironment ,
126130 runId : string ,
131+ requestOptions ?: RealtimeRequestOptions ,
127132 clientVersion ?: string
128133 ) {
129- return this . #streamRunsWhere( url , environment , `id='${ runId } '` , clientVersion ) ;
134+ return this . #streamRunsWhere( url , environment , `id='${ runId } '` , requestOptions , clientVersion ) ;
130135 }
131136
132137 async streamBatch (
133138 url : URL | string ,
134139 environment : RealtimeEnvironment ,
135140 batchId : string ,
141+ requestOptions ?: RealtimeRequestOptions ,
136142 clientVersion ?: string
137143 ) {
138144 const whereClauses : string [ ] = [
@@ -142,13 +148,14 @@ export class RealtimeClient {
142148
143149 const whereClause = whereClauses . join ( " AND " ) ;
144150
145- return this . #streamRunsWhere( url , environment , whereClause , clientVersion ) ;
151+ return this . #streamRunsWhere( url , environment , whereClause , requestOptions , clientVersion ) ;
146152 }
147153
148154 async streamRuns (
149155 url : URL | string ,
150156 environment : RealtimeEnvironment ,
151157 params : RealtimeRunsParams ,
158+ requestOptions ?: RealtimeRequestOptions ,
152159 clientVersion ?: string
153160 ) {
154161 const whereClauses : string [ ] = [ `"runtimeEnvironmentId"='${ environment . id } '` ] ;
@@ -165,7 +172,13 @@ export class RealtimeClient {
165172
166173 const whereClause = whereClauses . join ( " AND " ) ;
167174
168- const response = await this . #streamRunsWhere( url , environment , whereClause , clientVersion ) ;
175+ const response = await this . #streamRunsWhere(
176+ url ,
177+ environment ,
178+ whereClause ,
179+ requestOptions ,
180+ clientVersion
181+ ) ;
169182
170183 if ( createdAtFilter ) {
171184 const [ setCreatedAtFilterError ] = await tryCatch (
@@ -256,12 +269,14 @@ export class RealtimeClient {
256269 url : URL | string ,
257270 environment : RealtimeEnvironment ,
258271 whereClause : string ,
272+ requestOptions ?: RealtimeRequestOptions ,
259273 clientVersion ?: string
260274 ) {
261275 const electricUrl = this . #constructRunsElectricUrl(
262276 url ,
263277 environment ,
264278 whereClause ,
279+ requestOptions ,
265280 clientVersion
266281 ) ;
267282
@@ -272,6 +287,7 @@ export class RealtimeClient {
272287 url : URL | string ,
273288 environment : RealtimeEnvironment ,
274289 whereClause : string ,
290+ requestOptions ?: RealtimeRequestOptions ,
275291 clientVersion ?: string
276292 ) : URL {
277293 const $url = new URL ( url . toString ( ) ) ;
@@ -297,13 +313,10 @@ export class RealtimeClient {
297313 electricUrl . searchParams . set ( "handle" , electricUrl . searchParams . get ( "shape_id" ) ?? "" ) ;
298314 }
299315
300- const skipColumnsRaw = $url . searchParams . get ( "skipColumns" ) ;
316+ let skipColumns = getSkipColumns ( $url . searchParams , requestOptions ) ;
301317
302- if ( skipColumnsRaw ) {
303- const skipColumns = skipColumnsRaw
304- . split ( "," )
305- . map ( ( c ) => c . trim ( ) )
306- . filter ( ( c ) => c !== "" && ! RESERVED_COLUMNS . includes ( c ) ) ;
318+ if ( skipColumns . length > 0 ) {
319+ skipColumns = skipColumns . filter ( ( c ) => c !== "" && ! RESERVED_COLUMNS . includes ( c ) ) ;
307320
308321 electricUrl . searchParams . set (
309322 "columns" ,
@@ -543,3 +556,17 @@ declare module "ioredis" {
543556 ) : Result < number , Context > ;
544557 }
545558}
559+
560+ function getSkipColumns ( searchParams : URLSearchParams , requestOptions ?: RealtimeRequestOptions ) {
561+ if ( requestOptions ?. skipColumns ) {
562+ return requestOptions . skipColumns ;
563+ }
564+
565+ const skipColumnsRaw = searchParams . get ( "skipColumns" ) ;
566+
567+ if ( skipColumnsRaw ) {
568+ return skipColumnsRaw . split ( "," ) . map ( ( c ) => c . trim ( ) ) ;
569+ }
570+
571+ return [ ] ;
572+ }
0 commit comments