-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release Firestore Bundles as a prototype patched feature. #4168
Changes from 6 commits
cc8dd9c
a5b8d3a
705b30f
5910464
b4050e6
f8bb4d8
aae9956
931621e
cad128f
bf49a5b
d8543e3
0f8e555
e830a23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"firebase": minor | ||
"@firebase/firestore-types": minor | ||
"@firebase/firestore": minor | ||
--- | ||
|
||
Release Firestore Bundles as a prototype patched feature. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ | |
*/ | ||
|
||
import '@firebase/firestore'; | ||
import '@firebase/firestore/bundle'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ | |
*/ | ||
|
||
import '@firebase/firestore/memory'; | ||
import '@firebase/firestore/memory-bundle'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8289,12 +8289,109 @@ declare namespace firebase.firestore { | |
*/ | ||
terminate(): Promise<void>; | ||
|
||
/** | ||
* Loads a Firestore bundle into the local cache. | ||
* | ||
* @param bundleData | ||
* An object representing the bundle to be loaded. Valid objects are `ArrayBuffer`, | ||
* `ReadableStream<Uint8Array>` or `string`. | ||
* | ||
* @return | ||
* A `LoadBundleTask` object, which notifies callers with progress updates, and completion | ||
* or error events. It can be used as a `Promise<LoadBundleTaskProgress>`. | ||
*/ | ||
loadBundle( | ||
bundleData: ArrayBuffer | ReadableStream<Uint8Array> | string | ||
): LoadBundleTask; | ||
|
||
/** | ||
* Reads a Firestore `Query` from local cache, identified by the given name. | ||
* | ||
* The named queries are packaged into bundles on the server side (along | ||
* with resulting documents), and loaded to local cache using `loadBundle`. Once in local | ||
* cache, use this method to extract a `Query` by name. | ||
*/ | ||
namedQuery(name: string): Promise<Query<DocumentData> | null>; | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
INTERNAL: { delete: () => Promise<void> }; | ||
} | ||
|
||
/** | ||
* Represents the task of loading a Firestore bundle. It provides progress of bundle | ||
* loading, as well as task completion and error events. | ||
* | ||
* The API is compatible with `Promise<LoadBundleTaskProgress>`. | ||
*/ | ||
export interface LoadBundleTask extends PromiseLike<LoadBundleTaskProgress> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to create entries in https://github.com/firebase/firebase-js-sdk/blob/master/scripts/docgen/content-sources/js/toc.yaml for 2 new interfaces, LoadBundleTask and LoadBundleTaskProgress Can just insert this alphabetically in the Firestore section:
If this is available for Node, also here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
/** | ||
* Registers functions to listen to bundle loading progress events. | ||
* @param next | ||
* Called when there is a progress update from bundle loading. Typically `next` calls occur | ||
* each time a Firestore document is loaded from the bundle. | ||
* @param error | ||
* Called when an error occurs during bundle loading. The task aborts after reporting the | ||
* error, and there should be no more updates after this. | ||
* @param complete | ||
* Called when the loading task is complete. | ||
*/ | ||
onProgress( | ||
next?: (progress: LoadBundleTaskProgress) => any, | ||
error?: (error: Error) => any, | ||
complete?: () => void | ||
): void; | ||
|
||
/** | ||
* Implements the `Promise<LoadBundleTaskProgress>.then` interface. | ||
* | ||
* @param onFulfilled | ||
* Called on the completion of the loading task with a final `LoadBundleTaskProgress` update. | ||
* The update will always have its `taskState` set to `"Success"`. | ||
* @param onRejected | ||
* Called when an error occurs during bundle loading. | ||
*/ | ||
then<T, R>( | ||
onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>, | ||
onRejected?: (a: Error) => R | PromiseLike<R> | ||
): Promise<T | R>; | ||
|
||
/** | ||
* Implements the `Promise<LoadBundleTaskProgress>.catch` interface. | ||
* | ||
* @param onRejected | ||
* Called when an error occurs during bundle loading. | ||
*/ | ||
catch<R>( | ||
onRejected: (a: Error) => R | PromiseLike<R> | ||
): Promise<R | LoadBundleTaskProgress>; | ||
} | ||
|
||
/** | ||
* Represents a progress update or a final state from loading bundles. | ||
*/ | ||
export interface LoadBundleTaskProgress { | ||
/** How many documents have been loaded. */ | ||
documentsLoaded: number; | ||
/** How many documents are in the bundle being loaded. */ | ||
totalDocuments: number; | ||
/** How many bytes have been loaded. */ | ||
bytesLoaded: number; | ||
/** How many bytes are in the bundle being loaded. */ | ||
totalBytes: number; | ||
/** Current task state. */ | ||
taskState: TaskState; | ||
} | ||
|
||
/** | ||
* Represents the state of bundle loading tasks. | ||
* | ||
* Both 'Error' and 'Success' are sinking state: task will abort or complete and there will | ||
* be no more updates after they are reported. | ||
*/ | ||
export type TaskState = 'Error' | 'Running' | 'Success'; | ||
|
||
/** | ||
* An immutable object representing a geo point in Firestore. The geo point | ||
* is represented as latitude/longitude pair. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@firebase/firestore/bundle", | ||
"description": "Firestore bundle", | ||
"main": "../dist/node-cjs/bundle.js", | ||
"main-esm2017": "../dist/node-esm2017/bundle.js", | ||
"react-native": "../dist/rn/bundle.js", | ||
"browser": "../dist/esm5/bundle.js", | ||
"module": "../dist/esm5/bundle.js", | ||
"esm2017": "../dist/esm2017/bundle.js" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 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. | ||
*/ | ||
|
||
export { Blob } from './src/api/blob'; | ||
export { | ||
CollectionReference, | ||
DocumentReference, | ||
DocumentSnapshot, | ||
Firestore, | ||
Query, | ||
QueryDocumentSnapshot, | ||
QuerySnapshot, | ||
IndexedDbPersistenceProvider, | ||
MemoryPersistenceProvider, | ||
Transaction, | ||
WriteBatch, | ||
setLogLevel, | ||
CACHE_SIZE_UNLIMITED | ||
} from './src/api/database'; | ||
export { GeoPoint } from './src/api/geo_point'; | ||
export { FieldPath } from './src/api/field_path'; | ||
export { FieldValue } from './src/compat/field_value'; | ||
export { Timestamp } from './src/api/timestamp'; | ||
export { FirebaseFirestore as ExpFirebaseFirestore } from './exp/src/api/database'; | ||
export { loadBundle, namedQuery } from './src/api/bundle'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should describe in your Release Notes what this is ("bundles" is not a term that developers will understand - at least not yet) and how they can use it (mention the additional import). The Prototype Patching is an implementation detail that doesn't need to go into the release notes. We should focus on usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.