-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add api/pipelinesource and setup basic listen test
- Loading branch information
Showing
13 changed files
with
458 additions
and
60 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
...es/firestore/.idea/runConfigurations/Integration_Tests__Emulator_w__Mock_Persistence_.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { DocumentKey } from '../model/document_key'; | ||
|
||
import { Firestore } from './database'; | ||
import { Pipeline } from './pipeline'; | ||
import { DocumentReference } from './reference'; | ||
import { | ||
CollectionGroupSource, | ||
CollectionSource, | ||
DatabaseSource, | ||
DocumentsSource | ||
} from '../lite-api/stage'; | ||
import {PipelineSource as LitePipelineSource} from '../lite-api/pipeline-source'; | ||
import { UserDataReader } from '../lite-api/user_data_reader'; | ||
import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; | ||
|
||
/** | ||
* Represents the source of a Firestore {@link Pipeline}. | ||
* @beta | ||
*/ | ||
export class PipelineSource extends LitePipelineSource{ | ||
/** | ||
* @internal | ||
* @private | ||
* @param db | ||
* @param userDataReader | ||
* @param userDataWriter | ||
* @param documentReferenceFactory | ||
*/ | ||
constructor( | ||
db: Firestore, | ||
userDataReader: UserDataReader, | ||
userDataWriter: AbstractUserDataWriter, | ||
documentReferenceFactory: (id: DocumentKey) => DocumentReference | ||
) { | ||
super(db, userDataReader, userDataWriter, documentReferenceFactory); | ||
} | ||
|
||
collection(collectionPath: string): Pipeline { | ||
return new Pipeline( | ||
this.db as Firestore, | ||
this.userDataReader, | ||
this.userDataWriter, | ||
this.documentReferenceFactory, | ||
[new CollectionSource(collectionPath)] | ||
); | ||
} | ||
|
||
collectionGroup(collectionId: string): Pipeline { | ||
return new Pipeline( | ||
this.db as Firestore, | ||
this.userDataReader, | ||
this.userDataWriter, | ||
this.documentReferenceFactory, | ||
[new CollectionGroupSource(collectionId)] | ||
); | ||
} | ||
|
||
database(): Pipeline { | ||
return new Pipeline( | ||
this.db as Firestore, | ||
this.userDataReader, | ||
this.userDataWriter, | ||
this.documentReferenceFactory, | ||
[new DatabaseSource()] | ||
); | ||
} | ||
|
||
documents(docs: DocumentReference[]): Pipeline { | ||
return new Pipeline( | ||
this.db as Firestore, | ||
this.userDataReader, | ||
this.userDataWriter, | ||
this.documentReferenceFactory, | ||
[DocumentsSource.of(docs)] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.