@@ -8291,10 +8291,26 @@ declare namespace firebase.firestore {
8291
8291
*/
8292
8292
terminate ( ) : Promise < void > ;
8293
8293
8294
+ /**
8295
+ * Loads a Firestore bundle into the local cache.
8296
+ *
8297
+ * @param bundleData An object representing the bundle to be load, could be a `ArrayBuffer`,
8298
+ * a `ReadableStream<Uint8Array>` or a `string`.
8299
+ *
8300
+ * @return A `LoadBundleTask` object, which notifies callers with progress update, completion
8301
+ * or error event. It can be used as a `Promise<LoadBundleTaskProgress>`.
8302
+ */
8294
8303
loadBundle (
8295
- bundleData : ArrayBuffer | ReadableStream < ArrayBuffer > | string
8304
+ bundleData : ArrayBuffer | ReadableStream < Uint8Array > | string
8296
8305
) : LoadBundleTask ;
8297
8306
8307
+ /**
8308
+ * Reads a Firestore query from local cache that is associated to a given name.
8309
+ *
8310
+ * The named queries are from bundles, and saved as a result of `loadBundle`. `namedQuery`
8311
+ * retrieves the queries used to built the bundles, saving the need to manually construct
8312
+ * those queries.
8313
+ */
8298
8314
namedQuery ( name : string ) : Promise < Query < DocumentData > | null > ;
8299
8315
8300
8316
/**
@@ -8303,31 +8319,71 @@ declare namespace firebase.firestore {
8303
8319
INTERNAL : { delete : ( ) => Promise < void > } ;
8304
8320
}
8305
8321
8322
+ /**
8323
+ * Represents the task of loading a Firestore bundle. It provides progress of the bundle
8324
+ * loading, task completion and error events should they be any.
8325
+ *
8326
+ * It can be used as a `Promise<LoadBundleTaskProgress>`.
8327
+ */
8306
8328
export interface LoadBundleTask {
8329
+ /**
8330
+ * Registers functions to listen to bundle loading progresses.
8331
+ * @param next Called there is a progress update from bundle loading, typically whenever
8332
+ * a Firestore document is loaded it will generate a progress update.
8333
+ * @param error Called when there is an error occurred from loading the bundle. The task
8334
+ * aborts after reporting the error, and there should be no more updates after this.
8335
+ * @param complete Called when the loading task is complete.
8336
+ */
8307
8337
onProgress (
8308
8338
next ?: ( progress : LoadBundleTaskProgress ) => any ,
8309
8339
error ?: ( error : Error ) => any ,
8310
8340
complete ?: ( ) => void
8311
8341
) : void ;
8312
8342
8343
+ /**
8344
+ * Implements a `Promise<LoadBundleTaskProgress>` interface.
8345
+ *
8346
+ * @param onFulfilled It is called with the compeltion `LoadBundleTaskProgress` when the
8347
+ * loading task completes.
8348
+ * @param onRejected It is called when there is an error occurred from loading the bundle.
8349
+ */
8313
8350
then < T , R > (
8314
8351
onFulfilled ?: ( a : LoadBundleTaskProgress ) => T | PromiseLike < T > ,
8315
8352
onRejected ?: ( a : Error ) => R | PromiseLike < R >
8316
8353
) : Promise < T | R > ;
8317
8354
8355
+ /**
8356
+ * Implements a `Promise<LoadBundleTaskProgress>` interface.
8357
+ *
8358
+ * @param onRejected It is called when there is an error occurred from loading the bundle.
8359
+ */
8318
8360
catch < R > (
8319
8361
onRejected : ( a : Error ) => R | PromiseLike < R >
8320
8362
) : Promise < R | LoadBundleTaskProgress > ;
8321
8363
}
8322
8364
8365
+ /**
8366
+ * Represents a progress update or a final state from loading bundles.
8367
+ */
8323
8368
export interface LoadBundleTaskProgress {
8369
+ /** How many documents have been loaded. */
8324
8370
documentsLoaded : number ;
8371
+ /** How many documents are in the bundle being loaded. */
8325
8372
totalDocuments : number ;
8373
+ /** How many bytes have been loaded. */
8326
8374
bytesLoaded : number ;
8375
+ /** How many bytes are in the bundle being loaded. */
8327
8376
totalBytes : number ;
8377
+ /** Current task state. */
8328
8378
taskState : TaskState ;
8329
8379
}
8330
8380
8381
+ /**
8382
+ * Represents the state of bundle loading tasks.
8383
+ *
8384
+ * Both 'Error' and 'Success' are sinking state: task will abort or complete and there will
8385
+ * be no more updates after they are reported.
8386
+ */
8331
8387
export type TaskState = 'Error' | 'Running' | 'Success' ;
8332
8388
8333
8389
/**
0 commit comments