File tree Expand file tree Collapse file tree 7 files changed +19
-17
lines changed Expand file tree Collapse file tree 7 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ export class BundleLoadResult {
53
53
/**
54
54
* Represents a Firestore bundle saved by the SDK in its local storage.
55
55
*/
56
- export interface Bundle {
56
+ export interface BundleMetadata {
57
57
/**
58
58
* Id of the bundle. It is used together with `createTime` to determine if a
59
59
* bundle has been loaded by the SDK.
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { Bundle , NamedQuery } from '../core/bundle' ;
18
+ import { BundleMetadata , NamedQuery } from '../core/bundle' ;
19
19
import {
20
20
NamedQuery as ProtoNamedQuery ,
21
21
BundleMetadata as ProtoBundleMetadata
@@ -35,7 +35,7 @@ export interface BundleCache {
35
35
getBundleMetadata (
36
36
transaction : PersistenceTransaction ,
37
37
bundleId : string
38
- ) : PersistencePromise < Bundle | undefined > ;
38
+ ) : PersistencePromise < BundleMetadata | undefined > ;
39
39
40
40
/**
41
41
* Saves a `BundleMetadata` from a bundle into local storage, using its id as
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { Bundle , NamedQuery } from '../core/bundle' ;
18
+ import { BundleMetadata , NamedQuery } from '../core/bundle' ;
19
19
import {
20
20
BundleMetadata as ProtoBundleMetadata ,
21
21
NamedQuery as ProtoNamedQuery
@@ -43,7 +43,7 @@ export class IndexedDbBundleCache implements BundleCache {
43
43
getBundleMetadata (
44
44
transaction : PersistenceTransaction ,
45
45
bundleId : string
46
- ) : PersistencePromise < Bundle | undefined > {
46
+ ) : PersistencePromise < BundleMetadata | undefined > {
47
47
return bundlesStore ( transaction )
48
48
. get ( bundleId )
49
49
. next ( bundle => {
Original file line number Diff line number Diff line change 16
16
*/
17
17
18
18
import { Timestamp } from '../api/timestamp' ;
19
- import { Bundle , NamedQuery } from '../core/bundle' ;
19
+ import { BundleMetadata , NamedQuery } from '../core/bundle' ;
20
20
import { LimitType , Query , queryWithLimit } from '../core/query' ;
21
21
import { SnapshotVersion } from '../core/snapshot_version' ;
22
22
import { canonifyTarget , isDocumentTarget , Target } from '../core/target' ;
@@ -307,7 +307,7 @@ function isDocumentQuery(dbQuery: DbQuery): dbQuery is PublicDocumentsTarget {
307
307
}
308
308
309
309
/** Encodes a DbBundle to a Bundle. */
310
- export function fromDbBundle ( dbBundle : DbBundle ) : Bundle {
310
+ export function fromDbBundle ( dbBundle : DbBundle ) : BundleMetadata {
311
311
return {
312
312
id : dbBundle . bundleId ,
313
313
createTime : fromDbTimestamp ( dbBundle . createTime ) ,
@@ -373,7 +373,9 @@ export function fromProtoNamedQuery(namedQuery: ProtoNamedQuery): NamedQuery {
373
373
}
374
374
375
375
/** Encodes a BundleMetadata proto object to a Bundle model object. */
376
- export function fromBundleMetadata ( metadata : ProtoBundleMetadata ) : Bundle {
376
+ export function fromBundleMetadata (
377
+ metadata : ProtoBundleMetadata
378
+ ) : BundleMetadata {
377
379
return {
378
380
id : metadata . id ! ,
379
381
version : metadata . version ! ,
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { Bundle , NamedQuery } from '../core/bundle' ;
18
+ import { BundleMetadata , NamedQuery } from '../core/bundle' ;
19
19
import {
20
20
NamedQuery as ProtoNamedQuery ,
21
21
BundleMetadata as ProtoBundleMetadata
@@ -31,15 +31,15 @@ import { PersistencePromise } from './persistence_promise';
31
31
import { PersistenceTransaction } from './persistence_transaction' ;
32
32
33
33
export class MemoryBundleCache implements BundleCache {
34
- private bundles = new Map < string , Bundle > ( ) ;
34
+ private bundles = new Map < string , BundleMetadata > ( ) ;
35
35
private namedQueries = new Map < string , NamedQuery > ( ) ;
36
36
37
37
constructor ( private serializer : LocalSerializer ) { }
38
38
39
39
getBundleMetadata (
40
40
transaction : PersistenceTransaction ,
41
41
bundleId : string
42
- ) : PersistencePromise < Bundle | undefined > {
42
+ ) : PersistencePromise < BundleMetadata | undefined > {
43
43
return PersistencePromise . resolve ( this . bundles . get ( bundleId ) ) ;
44
44
}
45
45
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ function genericBundleCacheTests(cacheFn: () => TestBundleCache): void {
102
102
}
103
103
104
104
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 ;
106
106
} ) ;
107
107
108
108
it ( 'returns saved bundle' , async ( ) => {
@@ -111,7 +111,7 @@ function genericBundleCacheTests(cacheFn: () => TestBundleCache): void {
111
111
version : 1 ,
112
112
createTime : { seconds : 1 , nanos : 9999 }
113
113
} ) ;
114
- expect ( await cache . getBundle ( 'bundle-1' ) ) . to . deep . equal ( {
114
+ expect ( await cache . getBundleMetadata ( 'bundle-1' ) ) . to . deep . equal ( {
115
115
id : 'bundle-1' ,
116
116
version : 1 ,
117
117
createTime : SnapshotVersion . fromTimestamp ( new Timestamp ( 1 , 9999 ) )
@@ -123,7 +123,7 @@ function genericBundleCacheTests(cacheFn: () => TestBundleCache): void {
123
123
version : 2 ,
124
124
createTime : { seconds : 2 , nanos : 1111 }
125
125
} ) ;
126
- expect ( await cache . getBundle ( 'bundle-1' ) ) . to . deep . equal ( {
126
+ expect ( await cache . getBundleMetadata ( 'bundle-1' ) ) . to . deep . equal ( {
127
127
id : 'bundle-1' ,
128
128
version : 2 ,
129
129
createTime : SnapshotVersion . fromTimestamp ( new Timestamp ( 2 , 1111 ) )
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { Bundle , NamedQuery } from '../../../src/core/bundle' ;
18
+ import { BundleMetadata , NamedQuery } from '../../../src/core/bundle' ;
19
19
import { BundleCache } from '../../../src/local/bundle_cache' ;
20
20
import { Persistence } from '../../../src/local/persistence' ;
21
21
import {
@@ -34,9 +34,9 @@ export class TestBundleCache {
34
34
this . cache = persistence . getBundleCache ( ) ;
35
35
}
36
36
37
- getBundle ( bundleId : string ) : Promise < Bundle | undefined > {
37
+ getBundleMetadata ( bundleId : string ) : Promise < BundleMetadata | undefined > {
38
38
return this . persistence . runTransaction (
39
- 'getBundle ' ,
39
+ 'getBundleMetadata ' ,
40
40
'readonly' ,
41
41
transaction => {
42
42
return this . cache . getBundleMetadata ( transaction , bundleId ) ;
You can’t perform that action at this time.
0 commit comments