Skip to content

Commit f594840

Browse files
authored
Merge ac4bf09 into 8697166
2 parents 8697166 + ac4bf09 commit f594840

File tree

81 files changed

+4664
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4664
-259
lines changed

.changeset/lemon-steaks-draw.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
---

integration/firestore/firebase_export.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,16 @@ const Timestamp = firebase.firestore.Timestamp;
5555
const GeoPoint = firebase.firestore.GeoPoint;
5656
const FieldValue = firebase.firestore.FieldValue;
5757
const Blob = firebase.firestore.Blob;
58+
const loadBundle = firebase.firestore.loadBundle;
59+
const namedQuery = firebase.firestore.namedQuery;
5860

59-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
61+
export {
62+
Firestore,
63+
FieldValue,
64+
FieldPath,
65+
Timestamp,
66+
Blob,
67+
GeoPoint,
68+
loadBundle,
69+
namedQuery
70+
};

integration/firestore/firebase_export_memory.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,16 @@ const Timestamp = firebase.firestore.Timestamp;
5555
const GeoPoint = firebase.firestore.GeoPoint;
5656
const FieldValue = firebase.firestore.FieldValue;
5757
const Blob = firebase.firestore.Blob;
58+
const loadBundle = firebase.firestore.loadBundle;
59+
const namedQuery = firebase.firestore.namedQuery;
5860

59-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
61+
export {
62+
Firestore,
63+
FieldValue,
64+
FieldPath,
65+
Timestamp,
66+
Blob,
67+
GeoPoint,
68+
loadBundle,
69+
namedQuery
70+
};

packages-exp/auth-exp/index.webworker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ registerAuth(ClientPlatform.WORKER);
3737
export function getAuth(app = getApp()): Auth {
3838
// Unlike the other environments, we need to explicitly check if indexedDb is
3939
// available. That means doing the whole rigamarole
40-
const auth = _getProvider(app, _ComponentName.AUTH).getImmediate() as AuthImpl;
40+
const auth = _getProvider(
41+
app,
42+
_ComponentName.AUTH
43+
).getImmediate() as AuthImpl;
4144

4245
// This promise is intended to float; auth initialization happens in the
4346
// background, meanwhile the auth object may be used by the app.

packages/database/src/api/Database.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,17 @@ export class Database implements FirebaseService {
157157
validateUrl(apiName, 1, parsedURL);
158158

159159
const repoInfo = parsedURL.repoInfo;
160-
if (!repoInfo.isCustomHost() && repoInfo.host !== this.repo_.repoInfo_.host) {
160+
if (
161+
!repoInfo.isCustomHost() &&
162+
repoInfo.host !== this.repo_.repoInfo_.host
163+
) {
161164
fatal(
162165
apiName +
163166
': Host name does not match the current database: ' +
164167
'(found ' +
165168
repoInfo.host +
166169
' but expected ' +
167-
this.repo_.repoInfo_.host+
170+
this.repo_.repoInfo_.host +
168171
')'
169172
);
170173
}

packages/firebase/index.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8285,6 +8285,43 @@ declare namespace firebase.firestore {
82858285
INTERNAL: { delete: () => Promise<void> };
82868286
}
82878287

8288+
export function loadBundle(
8289+
db: Firestore,
8290+
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
8291+
): LoadBundleTask;
8292+
8293+
export function namedQuery(
8294+
db: Firestore,
8295+
name: string
8296+
): Promise<Query<DocumentData> | null>;
8297+
8298+
export interface LoadBundleTask {
8299+
onProgress(
8300+
next?: (progress: LoadBundleTaskProgress) => any,
8301+
error?: (error: Error) => any,
8302+
complete?: () => void
8303+
): void;
8304+
8305+
then<T, R>(
8306+
onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>,
8307+
onRejected?: (a: Error) => R | PromiseLike<R>
8308+
): Promise<T | R>;
8309+
8310+
catch<R>(
8311+
onRejected: (a: Error) => R | PromiseLike<R>
8312+
): Promise<R | LoadBundleTaskProgress>;
8313+
}
8314+
8315+
export interface LoadBundleTaskProgress {
8316+
documentsLoaded: number;
8317+
totalDocuments: number;
8318+
bytesLoaded: number;
8319+
totalBytes: number;
8320+
taskState: TaskState;
8321+
}
8322+
8323+
export type TaskState = 'Error' | 'Running' | 'Success';
8324+
82888325
/**
82898326
* An immutable object representing a geo point in Firestore. The geo point
82908327
* is represented as latitude/longitude pair.

packages/firestore-types/index.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,43 @@ export class FirebaseFirestore {
9999
INTERNAL: { delete: () => Promise<void> };
100100
}
101101

102+
export function loadBundle(
103+
db: FirebaseFirestore,
104+
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
105+
): LoadBundleTask;
106+
107+
export function namedQuery(
108+
db: FirebaseFirestore,
109+
name: string
110+
): Promise<Query<DocumentData> | null>;
111+
112+
export interface LoadBundleTask {
113+
onProgress(
114+
next?: (progress: LoadBundleTaskProgress) => any,
115+
error?: (error: Error) => any,
116+
complete?: () => void
117+
): void;
118+
119+
then<T, R>(
120+
onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>,
121+
onRejected?: (a: Error) => R | PromiseLike<R>
122+
): Promise<T | R>;
123+
124+
catch<R>(
125+
onRejected: (a: Error) => R | PromiseLike<R>
126+
): Promise<R | LoadBundleTaskProgress>;
127+
}
128+
129+
export interface LoadBundleTaskProgress {
130+
documentsLoaded: number;
131+
totalDocuments: number;
132+
bytesLoaded: number;
133+
totalBytes: number;
134+
taskState: TaskState;
135+
}
136+
137+
export type TaskState = 'Error' | 'Running' | 'Success';
138+
102139
export class GeoPoint {
103140
constructor(latitude: number, longitude: number);
104141

packages/firestore/exp-types/index.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,43 @@ export function snapshotEqual<T>(
516516
right: DocumentSnapshot<T> | QuerySnapshot<T>
517517
): boolean;
518518

519+
export interface LoadBundleTask {
520+
onProgress(
521+
next?: (progress: LoadBundleTaskProgress) => any,
522+
error?: (error: Error) => any,
523+
complete?: () => void
524+
): void;
525+
526+
then<T, R>(
527+
onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>,
528+
onRejected?: (a: Error) => R | PromiseLike<R>
529+
): Promise<T | R>;
530+
531+
catch<R>(
532+
onRejected: (a: Error) => R | PromiseLike<R>
533+
): Promise<R | LoadBundleTaskProgress>;
534+
}
535+
536+
export interface LoadBundleTaskProgress {
537+
documentsLoaded: number;
538+
totalDocuments: number;
539+
bytesLoaded: number;
540+
totalBytes: number;
541+
taskState: TaskState;
542+
}
543+
544+
export type TaskState = 'Error' | 'Running' | 'Success';
545+
546+
export function loadBundle(
547+
firestore: FirebaseFirestore,
548+
bundleData: ArrayBuffer | ReadableStream<Uint8Array> | string
549+
): LoadBundleTask;
550+
551+
export function namedQuery(
552+
firestore: FirebaseFirestore,
553+
name: string
554+
): Promise<Query<DocumentData> | null>;
555+
519556
export type FirestoreErrorCode =
520557
| 'cancelled'
521558
| 'unknown'

packages/firestore/exp/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ export {
3131
waitForPendingWrites,
3232
disableNetwork,
3333
enableNetwork,
34-
terminate,
35-
Settings
34+
namedQuery,
35+
loadBundle,
36+
terminate
3637
} from './src/api/database';
3738

3839
export {

packages/firestore/exp/src/api/database.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424
FirestoreClient,
2525
firestoreClientDisableNetwork,
2626
firestoreClientEnableNetwork,
27+
firestoreClientGetNamedQuery,
28+
firestoreClientLoadBundle,
2729
firestoreClientWaitForPendingWrites,
2830
setOfflineComponentProvider,
2931
setOnlineComponentProvider
@@ -53,6 +55,8 @@ import {
5355
indexedDbStoragePrefix
5456
} from '../../../src/local/indexeddb_persistence';
5557
import { PersistenceSettings } from '../../../exp-types';
58+
import { Query } from '../../../lite/src/api/reference';
59+
import { LoadBundleTask } from '../../../src/api/bundle';
5660

5761
/** DOMException error code constants. */
5862
const DOM_EXCEPTION_INVALID_STATE = 11;
@@ -430,3 +434,29 @@ function verifyNotInitialized(firestore: FirestoreCompat): void {
430434
);
431435
}
432436
}
437+
438+
export function loadBundle(
439+
firestore: FirebaseFirestore,
440+
bundleData: ArrayBuffer | ReadableStream<Uint8Array> | string
441+
): LoadBundleTask {
442+
const client = ensureFirestoreConfigured(firestore);
443+
const resultTask = new LoadBundleTask();
444+
445+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
446+
firestoreClientLoadBundle(client, bundleData, resultTask);
447+
return resultTask;
448+
}
449+
450+
export function namedQuery(
451+
firestore: FirebaseFirestore,
452+
name: string
453+
): Promise<Query | null> {
454+
const client = ensureFirestoreConfigured(firestore);
455+
return firestoreClientGetNamedQuery(client, name).then(namedQuery => {
456+
if (!namedQuery) {
457+
return null;
458+
}
459+
460+
return new Query(firestore, null, namedQuery.query);
461+
});
462+
}

packages/firestore/exp/test/shim.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import {
4141
getDocsFromCache,
4242
getDocsFromServer,
4343
initializeFirestore,
44+
loadBundle,
45+
namedQuery,
4446
onSnapshot,
4547
onSnapshotsInSync,
4648
query,
@@ -73,6 +75,7 @@ import { Compat } from '../../src/compat/compat';
7375

7476
export { GeoPoint, Timestamp } from '../index';
7577
export { FieldValue } from '../../src/compat/field_value';
78+
export { loadBundle, namedQuery };
7679

7780
/* eslint-disable @typescript-eslint/no-explicit-any */
7881

packages/firestore/externs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"packages/webchannel-wrapper/src/index.d.ts",
2929
"packages/util/dist/src/crypt.d.ts",
3030
"packages/util/dist/src/environment.d.ts",
31+
"packages/firestore/src/protos/firestore_bundle_proto.ts",
3132
"packages/firestore/src/protos/firestore_proto_api.d.ts",
3233
"packages/firestore/src/util/error.ts",
3334
"packages/firestore/src/local/indexeddb_schema.ts",

packages/firestore/register-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ declare module '@firebase/app-types' {
3636
Transaction: typeof types.Transaction;
3737
WriteBatch: typeof types.WriteBatch;
3838
setLogLevel: typeof types.setLogLevel;
39+
loadBundle: typeof types.loadBundle;
40+
namedQuery: typeof types.namedQuery;
3941
};
4042
}
4143
interface FirebaseApp {

packages/firestore/rollup.shared.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ const manglePrivatePropertiesOptions = {
129129
},
130130
mangle: {
131131
properties: {
132-
regex: /^__PRIVATE_/
132+
regex: /^__PRIVATE_/,
133+
reserved: ['do']
133134
}
134135
}
135136
};

0 commit comments

Comments
 (0)