@@ -19,7 +19,12 @@ import { Timestamp } from '../api/timestamp';
1919import { BundleMetadata , NamedQuery } from '../core/bundle' ;
2020import { LimitType , Query , queryWithLimit } from '../core/query' ;
2121import { SnapshotVersion } from '../core/snapshot_version' ;
22- import { canonifyTarget , Target , targetIsDocumentTarget } from '../core/target' ;
22+ import {
23+ canonifyTarget ,
24+ Target ,
25+ targetIsDocumentTarget ,
26+ targetIsPipelineTarget
27+ } from '../core/target' ;
2328import { MutableDocument } from '../model/document' ;
2429import { DocumentKey } from '../model/document_key' ;
2530import {
@@ -36,18 +41,23 @@ import {
3641 BundleMetadata as ProtoBundleMetadata ,
3742 NamedQuery as ProtoNamedQuery
3843} from '../protos/firestore_bundle_proto' ;
39- import { DocumentsTarget as PublicDocumentsTarget } from '../protos/firestore_proto_api' ;
44+ import {
45+ DocumentsTarget as PublicDocumentsTarget ,
46+ PipelineQueryTarget as PublicPipelineQueryTarget
47+ } from '../protos/firestore_proto_api' ;
4048import {
4149 convertQueryTargetToQuery ,
4250 fromDocument ,
4351 fromDocumentsTarget ,
4452 fromMutation ,
53+ fromPipelineTarget ,
4554 fromQueryTarget ,
4655 fromVersion ,
4756 JsonProtoSerializer ,
4857 toDocument ,
4958 toDocumentsTarget ,
5059 toMutation ,
60+ toPipelineTarget ,
5161 toQueryTarget
5262} from '../remote/serializer' ;
5363import { debugAssert , fail } from '../util/assert' ;
@@ -71,6 +81,7 @@ import {
7181} from './indexeddb_schema' ;
7282import { DbDocumentOverlayKey , DbTimestampKey } from './indexeddb_sentinels' ;
7383import { TargetData , TargetPurpose } from './target_data' ;
84+ import { Pipeline } from '../pipelines/api/pipeline' ;
7485
7586/** Serializer for values stored in the LocalStore. */
7687export class LocalSerializer {
@@ -241,8 +252,10 @@ export function fromDbTarget(dbTarget: DbTarget): TargetData {
241252 ? fromDbTimestamp ( dbTarget . lastLimboFreeSnapshotVersion )
242253 : SnapshotVersion . min ( ) ;
243254
244- let target : Target ;
245- if ( isDocumentQuery ( dbTarget . query ) ) {
255+ let target : Target | Pipeline ;
256+ if ( isPipelineQueryTarget ( dbTarget . query ) ) {
257+ target = fromPipelineTarget ( dbTarget . query ) ;
258+ } else if ( isDocumentQuery ( dbTarget . query ) ) {
246259 target = fromDocumentsTarget ( dbTarget . query ) ;
247260 } else {
248261 target = fromQueryTarget ( dbTarget . query ) ;
@@ -275,7 +288,21 @@ export function toDbTarget(
275288 targetData . lastLimboFreeSnapshotVersion
276289 ) ;
277290 let queryProto : DbQuery ;
278- if ( targetIsDocumentTarget ( targetData . target ) ) {
291+ if ( targetIsPipelineTarget ( targetData . target ) ) {
292+ queryProto = toPipelineTarget (
293+ localSerializer . remoteSerializer ,
294+ targetData . target
295+ ) ;
296+ return {
297+ targetId : targetData . targetId ,
298+ canonicalId : '' ,
299+ readTime : dbTimestamp ,
300+ resumeToken : '' ,
301+ lastListenSequenceNumber : targetData . sequenceNumber ,
302+ lastLimboFreeSnapshotVersion : dbLastLimboFreeTimestamp ,
303+ query : queryProto
304+ } ;
305+ } else if ( targetIsDocumentTarget ( targetData . target ) ) {
279306 queryProto = toDocumentsTarget (
280307 localSerializer . remoteSerializer ,
281308 targetData . target
@@ -303,6 +330,12 @@ export function toDbTarget(
303330 } ;
304331}
305332
333+ function isPipelineQueryTarget (
334+ dbQuery : DbQuery
335+ ) : dbQuery is PublicPipelineQueryTarget {
336+ return ( dbQuery as PublicPipelineQueryTarget ) . pipeline !== undefined ;
337+ }
338+
306339/**
307340 * A helper function for figuring out what kind of query has been stored.
308341 */
0 commit comments