Skip to content

Commit 0863a38

Browse files
Merge 3a21e11 into 4512bc9
2 parents 4512bc9 + 3a21e11 commit 0863a38

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

packages/firestore/src/core/bundle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class BundleLoadResult {
5353
/**
5454
* Represents a Firestore bundle saved by the SDK in its local storage.
5555
*/
56-
export interface Bundle {
56+
export interface BundleMetadata {
5757
/**
5858
* Id of the bundle. It is used together with `createTime` to determine if a
5959
* bundle has been loaded by the SDK.

packages/firestore/src/local/bundle_cache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Bundle, NamedQuery } from '../core/bundle';
18+
import { BundleMetadata, NamedQuery } from '../core/bundle';
1919
import {
2020
NamedQuery as ProtoNamedQuery,
2121
BundleMetadata as ProtoBundleMetadata
@@ -29,13 +29,13 @@ import { PersistenceTransaction } from './persistence_transaction';
2929
*/
3030
export interface BundleCache {
3131
/**
32-
* Gets a saved `Bundle` for a given `bundleId`, returns undefined if
33-
* no bundles are found under the given id.
32+
* Gets the saved `BundleMetadata` for a given `bundleId`, returns undefined
33+
* if no bundle metadata is found under the given id.
3434
*/
3535
getBundleMetadata(
3636
transaction: PersistenceTransaction,
3737
bundleId: string
38-
): PersistencePromise<Bundle | undefined>;
38+
): PersistencePromise<BundleMetadata | undefined>;
3939

4040
/**
4141
* Saves a `BundleMetadata` from a bundle into local storage, using its id as

packages/firestore/src/local/indexeddb_bundle_cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Bundle, NamedQuery } from '../core/bundle';
18+
import { BundleMetadata, NamedQuery } from '../core/bundle';
1919
import {
2020
BundleMetadata as ProtoBundleMetadata,
2121
NamedQuery as ProtoNamedQuery
@@ -43,7 +43,7 @@ export class IndexedDbBundleCache implements BundleCache {
4343
getBundleMetadata(
4444
transaction: PersistenceTransaction,
4545
bundleId: string
46-
): PersistencePromise<Bundle | undefined> {
46+
): PersistencePromise<BundleMetadata | undefined> {
4747
return bundlesStore(transaction)
4848
.get(bundleId)
4949
.next(bundle => {

packages/firestore/src/local/local_serializer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { Timestamp } from '../api/timestamp';
19-
import { Bundle, NamedQuery } from '../core/bundle';
19+
import { BundleMetadata, NamedQuery } from '../core/bundle';
2020
import { LimitType, Query, queryWithLimit } from '../core/query';
2121
import { SnapshotVersion } from '../core/snapshot_version';
2222
import { canonifyTarget, isDocumentTarget, Target } from '../core/target';
@@ -306,8 +306,8 @@ function isDocumentQuery(dbQuery: DbQuery): dbQuery is PublicDocumentsTarget {
306306
return (dbQuery as PublicDocumentsTarget).documents !== undefined;
307307
}
308308

309-
/** Encodes a DbBundle to a Bundle. */
310-
export function fromDbBundle(dbBundle: DbBundle): Bundle {
309+
/** Encodes a DbBundle to a BundleMetadata object. */
310+
export function fromDbBundle(dbBundle: DbBundle): BundleMetadata {
311311
return {
312312
id: dbBundle.bundleId,
313313
createTime: fromDbTimestamp(dbBundle.createTime),
@@ -372,8 +372,10 @@ export function fromProtoNamedQuery(namedQuery: ProtoNamedQuery): NamedQuery {
372372
};
373373
}
374374

375-
/** Encodes a BundleMetadata proto object to a Bundle model object. */
376-
export function fromBundleMetadata(metadata: ProtoBundleMetadata): Bundle {
375+
/** Decodes a BundleMetadata proto into a BundleMetadata object. */
376+
export function fromBundleMetadata(
377+
metadata: ProtoBundleMetadata
378+
): BundleMetadata {
377379
return {
378380
id: metadata.id!,
379381
version: metadata.version!,

packages/firestore/src/local/memory_bundle_cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Bundle, NamedQuery } from '../core/bundle';
18+
import { BundleMetadata, NamedQuery } from '../core/bundle';
1919
import {
2020
NamedQuery as ProtoNamedQuery,
2121
BundleMetadata as ProtoBundleMetadata
@@ -31,15 +31,15 @@ import { PersistencePromise } from './persistence_promise';
3131
import { PersistenceTransaction } from './persistence_transaction';
3232

3333
export class MemoryBundleCache implements BundleCache {
34-
private bundles = new Map<string, Bundle>();
34+
private bundles = new Map<string, BundleMetadata>();
3535
private namedQueries = new Map<string, NamedQuery>();
3636

3737
constructor(private serializer: LocalSerializer) {}
3838

3939
getBundleMetadata(
4040
transaction: PersistenceTransaction,
4141
bundleId: string
42-
): PersistencePromise<Bundle | undefined> {
42+
): PersistencePromise<BundleMetadata | undefined> {
4343
return PersistencePromise.resolve(this.bundles.get(bundleId));
4444
}
4545

packages/firestore/test/unit/local/bundle_cache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function genericBundleCacheTests(cacheFn: () => TestBundleCache): void {
102102
}
103103

104104
it('returns undefined when bundle id is not found', async () => {
105-
expect(await cache.getBundle('bundle-1')).to.be.undefined;
105+
expect(await cache.getBundleMetadata('bundle-1')).to.be.undefined;
106106
});
107107

108108
it('returns saved bundle', async () => {
@@ -111,7 +111,7 @@ function genericBundleCacheTests(cacheFn: () => TestBundleCache): void {
111111
version: 1,
112112
createTime: { seconds: 1, nanos: 9999 }
113113
});
114-
expect(await cache.getBundle('bundle-1')).to.deep.equal({
114+
expect(await cache.getBundleMetadata('bundle-1')).to.deep.equal({
115115
id: 'bundle-1',
116116
version: 1,
117117
createTime: SnapshotVersion.fromTimestamp(new Timestamp(1, 9999))
@@ -123,7 +123,7 @@ function genericBundleCacheTests(cacheFn: () => TestBundleCache): void {
123123
version: 2,
124124
createTime: { seconds: 2, nanos: 1111 }
125125
});
126-
expect(await cache.getBundle('bundle-1')).to.deep.equal({
126+
expect(await cache.getBundleMetadata('bundle-1')).to.deep.equal({
127127
id: 'bundle-1',
128128
version: 2,
129129
createTime: SnapshotVersion.fromTimestamp(new Timestamp(2, 1111))

packages/firestore/test/unit/local/test_bundle_cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Bundle, NamedQuery } from '../../../src/core/bundle';
18+
import { BundleMetadata, NamedQuery } from '../../../src/core/bundle';
1919
import { BundleCache } from '../../../src/local/bundle_cache';
2020
import { Persistence } from '../../../src/local/persistence';
2121
import {
@@ -34,9 +34,9 @@ export class TestBundleCache {
3434
this.cache = persistence.getBundleCache();
3535
}
3636

37-
getBundle(bundleId: string): Promise<Bundle | undefined> {
37+
getBundleMetadata(bundleId: string): Promise<BundleMetadata | undefined> {
3838
return this.persistence.runTransaction(
39-
'getBundle',
39+
'getBundleMetadata',
4040
'readonly',
4141
transaction => {
4242
return this.cache.getBundleMetadata(transaction, bundleId);

0 commit comments

Comments
 (0)