@firebase/firestore 4.6.4-canary.a9f844066 → 4.6.4-canary.aef54687d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/firestore/src/core/event_manager.d.ts +2 -0
  2. package/dist/firestore/src/global_index.d.ts +43 -0
  3. package/dist/firestore/src/local/globals_cache.d.ts +39 -0
  4. package/dist/firestore/src/local/indexeddb_globals_cache.d.ts +25 -0
  5. package/dist/firestore/src/local/indexeddb_persistence.d.ts +3 -0
  6. package/dist/firestore/src/local/indexeddb_schema.d.ts +10 -1
  7. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +6 -0
  8. package/dist/firestore/src/local/memory_globals_cache.d.ts +25 -0
  9. package/dist/firestore/src/local/memory_persistence.d.ts +3 -0
  10. package/dist/firestore/src/local/persistence.d.ts +5 -0
  11. package/dist/firestore/test/unit/local/globals_cache.test.d.ts +17 -0
  12. package/dist/firestore/test/unit/local/test_globals_cache.d.ts +29 -0
  13. package/dist/index.cjs.js +1567 -1479
  14. package/dist/index.cjs.js.map +1 -1
  15. package/dist/index.esm2017.js +1567 -1479
  16. package/dist/index.esm2017.js.map +1 -1
  17. package/dist/index.esm5.js +3512 -3449
  18. package/dist/index.esm5.js.map +1 -1
  19. package/dist/index.node.cjs.js +116 -6
  20. package/dist/index.node.cjs.js.map +1 -1
  21. package/dist/index.node.mjs +116 -6
  22. package/dist/index.node.mjs.map +1 -1
  23. package/dist/index.rn.js +1585 -1497
  24. package/dist/index.rn.js.map +1 -1
  25. package/dist/internal.d.ts +26 -0
  26. package/dist/lite/firestore/src/core/event_manager.d.ts +2 -0
  27. package/dist/lite/firestore/src/local/globals_cache.d.ts +39 -0
  28. package/dist/lite/firestore/src/local/indexeddb_globals_cache.d.ts +25 -0
  29. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +3 -0
  30. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +10 -1
  31. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +6 -0
  32. package/dist/lite/firestore/src/local/memory_globals_cache.d.ts +25 -0
  33. package/dist/lite/firestore/src/local/memory_persistence.d.ts +3 -0
  34. package/dist/lite/firestore/src/local/persistence.d.ts +5 -0
  35. package/dist/lite/firestore/test/unit/local/globals_cache.test.d.ts +17 -0
  36. package/dist/lite/firestore/test/unit/local/test_globals_cache.d.ts +29 -0
  37. package/dist/lite/index.browser.esm2017.js +2 -2
  38. package/dist/lite/index.browser.esm5.js +2 -2
  39. package/dist/lite/index.cjs.js +2 -2
  40. package/dist/lite/index.node.cjs.js +2 -2
  41. package/dist/lite/index.node.mjs +2 -2
  42. package/dist/lite/index.rn.esm2017.js +2 -2
  43. package/dist/lite/internal.d.ts +26 -0
  44. package/dist/lite/packages/firestore/src/core/event_manager.d.ts +2 -0
  45. package/dist/lite/packages/firestore/src/local/globals_cache.d.ts +39 -0
  46. package/dist/lite/packages/firestore/src/local/indexeddb_globals_cache.d.ts +25 -0
  47. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +3 -0
  48. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +10 -1
  49. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +6 -0
  50. package/dist/lite/packages/firestore/src/local/memory_globals_cache.d.ts +25 -0
  51. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +3 -0
  52. package/dist/lite/packages/firestore/src/local/persistence.d.ts +5 -0
  53. package/dist/lite/packages/firestore/test/unit/local/globals_cache.test.d.ts +17 -0
  54. package/dist/lite/packages/firestore/test/unit/local/test_globals_cache.d.ts +29 -0
  55. package/dist/lite/private.d.ts +26 -0
  56. package/dist/packages/firestore/dist/index.esm2017.d.ts +303 -258
  57. package/dist/packages/firestore/src/core/event_manager.d.ts +2 -0
  58. package/dist/packages/firestore/src/local/globals_cache.d.ts +39 -0
  59. package/dist/packages/firestore/src/local/indexeddb_globals_cache.d.ts +25 -0
  60. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +3 -0
  61. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +10 -1
  62. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +6 -0
  63. package/dist/packages/firestore/src/local/memory_globals_cache.d.ts +25 -0
  64. package/dist/packages/firestore/src/local/memory_persistence.d.ts +3 -0
  65. package/dist/packages/firestore/src/local/persistence.d.ts +5 -0
  66. package/dist/packages/firestore/test/unit/local/globals_cache.test.d.ts +17 -0
  67. package/dist/packages/firestore/test/unit/local/test_globals_cache.d.ts +29 -0
  68. package/dist/private.d.ts +26 -0
  69. package/package.json +9 -9
@@ -50,6 +50,7 @@ export interface EventManager {
50
50
  onUnlisten?: (query: Query, disableRemoteListen: boolean) => Promise<void>;
51
51
  onFirstRemoteStoreListen?: (query: Query) => Promise<void>;
52
52
  onLastRemoteStoreUnlisten?: (query: Query) => Promise<void>;
53
+ terminate(): void;
53
54
  }
54
55
  export declare function newEventManager(): EventManager;
55
56
  export declare class EventManagerImpl implements EventManager {
@@ -70,6 +71,7 @@ export declare class EventManagerImpl implements EventManager {
70
71
  * still listening to the cache.
71
72
  */
72
73
  onLastRemoteStoreUnlisten?: (query: Query) => Promise<void>;
74
+ terminate(): void;
73
75
  }
74
76
  export declare function eventManagerListen(eventManager: EventManager, listener: QueryListener): Promise<void>;
75
77
  export declare function eventManagerUnlisten(eventManager: EventManager, listener: QueryListener): Promise<void>;
@@ -4217,6 +4217,44 @@ interface BundleCache {
4217
4217
  saveNamedQuery(transaction: PersistenceTransaction, query: NamedQuery$1): PersistencePromise<void>;
4218
4218
  }
4219
4219
 
4220
+ /**
4221
+ * @license
4222
+ * Copyright 2024 Google LLC
4223
+ *
4224
+ * Licensed under the Apache License, Version 2.0 (the "License");
4225
+ * you may not use this file except in compliance with the License.
4226
+ * You may obtain a copy of the License at
4227
+ *
4228
+ * http://www.apache.org/licenses/LICENSE-2.0
4229
+ *
4230
+ * Unless required by applicable law or agreed to in writing, software
4231
+ * distributed under the License is distributed on an "AS IS" BASIS,
4232
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4233
+ * See the License for the specific language governing permissions and
4234
+ * limitations under the License.
4235
+ */
4236
+
4237
+ /**
4238
+ * General purpose cache for global values.
4239
+ *
4240
+ * Global state that cuts across components should be saved here. Following are contained herein:
4241
+ *
4242
+ * `sessionToken` tracks server interaction across Listen and Write streams. This facilitates cache
4243
+ * synchronization and invalidation.
4244
+ */
4245
+ interface GlobalsCache {
4246
+ /**
4247
+ * Gets session token.
4248
+ */
4249
+ getSessionToken(transaction: PersistenceTransaction): PersistencePromise<ByteString>;
4250
+ /**
4251
+ * Sets session token.
4252
+ *
4253
+ * @param sessionToken - The new session token.
4254
+ */
4255
+ setSessionToken(transaction: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>;
4256
+ }
4257
+
4220
4258
  /**
4221
4259
  * @license
4222
4260
  * Copyright 2017 Google LLC
@@ -4762,6 +4800,10 @@ interface Persistence {
4762
4800
  * PORTING NOTE: This is only used for Web multi-tab.
4763
4801
  */
4764
4802
  setNetworkEnabled(networkEnabled: boolean): void;
4803
+ /**
4804
+ * Returns GlobalCache representing a general purpose cache for global values.
4805
+ */
4806
+ getGlobalsCache(): GlobalsCache;
4765
4807
  /**
4766
4808
  * Returns a MutationQueue representing the persisted mutations for the
4767
4809
  * given user.
@@ -5384,6 +5426,7 @@ interface EventManager {
5384
5426
  onUnlisten?: (query: Query$1, disableRemoteListen: boolean) => Promise<void>;
5385
5427
  onFirstRemoteStoreListen?: (query: Query$1) => Promise<void>;
5386
5428
  onLastRemoteStoreUnlisten?: (query: Query$1) => Promise<void>;
5429
+ terminate(): void;
5387
5430
  }
5388
5431
 
5389
5432
  /**
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ByteString } from '../util/byte_string';
18
+ import { PersistencePromise } from './persistence_promise';
19
+ import { PersistenceTransaction } from './persistence_transaction';
20
+ /**
21
+ * General purpose cache for global values.
22
+ *
23
+ * Global state that cuts across components should be saved here. Following are contained herein:
24
+ *
25
+ * `sessionToken` tracks server interaction across Listen and Write streams. This facilitates cache
26
+ * synchronization and invalidation.
27
+ */
28
+ export interface GlobalsCache {
29
+ /**
30
+ * Gets session token.
31
+ */
32
+ getSessionToken(transaction: PersistenceTransaction): PersistencePromise<ByteString>;
33
+ /**
34
+ * Sets session token.
35
+ *
36
+ * @param sessionToken - The new session token.
37
+ */
38
+ setSessionToken(transaction: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>;
39
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ByteString } from '../util/byte_string';
18
+ import { GlobalsCache } from './globals_cache';
19
+ import { PersistencePromise } from './persistence_promise';
20
+ import { PersistenceTransaction } from './persistence_transaction';
21
+ export declare class IndexedDbGlobalsCache implements GlobalsCache {
22
+ private globalsStore;
23
+ getSessionToken(txn: PersistenceTransaction): PersistencePromise<ByteString>;
24
+ setSessionToken(txn: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>;
25
+ }
@@ -22,6 +22,7 @@ import { AsyncQueue } from '../util/async_queue';
22
22
  import { DocumentLike, WindowLike } from '../util/types';
23
23
  import { BundleCache } from './bundle_cache';
24
24
  import { DocumentOverlayCache } from './document_overlay_cache';
25
+ import { GlobalsCache } from './globals_cache';
25
26
  import { IndexManager } from './index_manager';
26
27
  import { IndexedDbLruDelegateImpl } from './indexeddb_lru_delegate_impl';
27
28
  import { IndexedDbMutationQueue } from './indexeddb_mutation_queue';
@@ -119,6 +120,7 @@ export declare class IndexedDbPersistence implements Persistence {
119
120
  private lastGarbageCollectionTime;
120
121
  /** A listener to notify on primary state changes. */
121
122
  private primaryStateListener;
123
+ private readonly globalsCache;
122
124
  private readonly targetCache;
123
125
  private readonly remoteDocumentCache;
124
126
  private readonly bundleCache;
@@ -208,6 +210,7 @@ export declare class IndexedDbPersistence implements Persistence {
208
210
  */
209
211
  getActiveClients(): Promise<ClientId[]>;
210
212
  get started(): boolean;
213
+ getGlobalsCache(): GlobalsCache;
211
214
  getMutationQueue(user: User, indexManager: IndexManager): IndexedDbMutationQueue;
212
215
  getTargetCache(): IndexedDbTargetCache;
213
216
  getRemoteDocumentCache(): IndexedDbRemoteDocumentCache;
@@ -45,7 +45,7 @@ import { DbTimestampKey } from './indexeddb_sentinels';
45
45
  * 15. Add indexing support.
46
46
  * 16. Parse timestamp strings before creating index entries.
47
47
  */
48
- export declare const SCHEMA_VERSION = 16;
48
+ export declare const SCHEMA_VERSION = 17;
49
49
  /**
50
50
  * Wrapper class to store timestamps (seconds and nanos) in IndexedDb objects.
51
51
  */
@@ -496,3 +496,12 @@ export interface DbDocumentOverlay {
496
496
  /** The overlay mutation. */
497
497
  overlayMutation: ProtoWrite;
498
498
  }
499
+ /**
500
+ * An object containing global name/value pair.
501
+ */
502
+ export interface DbGlobals {
503
+ /** Name is a globally unique identifier for a value. */
504
+ name: string;
505
+ /** Value is a general purpose storage for global data. */
506
+ value: Uint8Array;
507
+ }
@@ -231,6 +231,11 @@ export declare const DbDocumentOverlayCollectionPathOverlayIndex = "collectionPa
231
231
  export declare const DbDocumentOverlayCollectionPathOverlayIndexPath: string[];
232
232
  export declare const DbDocumentOverlayCollectionGroupOverlayIndex = "collectionGroupOverlayIndex";
233
233
  export declare const DbDocumentOverlayCollectionGroupOverlayIndexPath: string[];
234
+ /** Name of the IndexedDb object store. */
235
+ export declare const DbGlobalsStore = "globals";
236
+ export declare const DbGlobalsKeyPath = "name";
237
+ /** Names of global values */
238
+ export declare type DbGlobalsKey = 'sessionToken';
234
239
  export declare const V1_STORES: string[];
235
240
  export declare const V3_STORES: string[];
236
241
  export declare const V4_STORES: string[];
@@ -242,6 +247,7 @@ export declare const V13_STORES: string[];
242
247
  export declare const V14_STORES: string[];
243
248
  export declare const V15_STORES: string[];
244
249
  export declare const V16_STORES: string[];
250
+ export declare const V17_STORES: string[];
245
251
  /**
246
252
  * The list of all default IndexedDB stores used throughout the SDK. This is
247
253
  * used when creating transactions so that access across all stores is done
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ByteString } from '../util/byte_string';
18
+ import { GlobalsCache } from './globals_cache';
19
+ import { PersistencePromise } from './persistence_promise';
20
+ import { PersistenceTransaction } from './persistence_transaction';
21
+ export declare class MemoryGlobalsCache implements GlobalsCache {
22
+ private sessionToken;
23
+ getSessionToken(transaction: PersistenceTransaction): PersistencePromise<ByteString>;
24
+ setSessionToken(transaction: PersistenceTransaction, sessionToken: ByteString): PersistencePromise<void>;
25
+ }
@@ -20,6 +20,7 @@ import { Document } from '../model/document';
20
20
  import { DocumentKey } from '../model/document_key';
21
21
  import { JsonProtoSerializer } from '../remote/serializer';
22
22
  import { DocumentOverlayCache } from './document_overlay_cache';
23
+ import { GlobalsCache } from './globals_cache';
23
24
  import { IndexManager } from './index_manager';
24
25
  import { ActiveTargets, LruDelegate, LruGarbageCollector, LruParams } from './lru_garbage_collector';
25
26
  import { MemoryBundleCache } from './memory_bundle_cache';
@@ -44,6 +45,7 @@ export declare class MemoryPersistence implements Persistence {
44
45
  * persisting values.
45
46
  */
46
47
  private readonly indexManager;
48
+ private readonly globalsCache;
47
49
  private mutationQueues;
48
50
  private overlays;
49
51
  private readonly remoteDocumentCache;
@@ -68,6 +70,7 @@ export declare class MemoryPersistence implements Persistence {
68
70
  getIndexManager(user: User): MemoryIndexManager;
69
71
  getDocumentOverlayCache(user: User): DocumentOverlayCache;
70
72
  getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
73
+ getGlobalsCache(): GlobalsCache;
71
74
  getTargetCache(): MemoryTargetCache;
72
75
  getRemoteDocumentCache(): MemoryRemoteDocumentCache;
73
76
  getBundleCache(): MemoryBundleCache;
@@ -19,6 +19,7 @@ import { TargetId } from '../core/types';
19
19
  import { DocumentKey } from '../model/document_key';
20
20
  import { BundleCache } from './bundle_cache';
21
21
  import { DocumentOverlayCache } from './document_overlay_cache';
22
+ import { GlobalsCache } from './globals_cache';
22
23
  import { IndexManager } from './index_manager';
23
24
  import { MutationQueue } from './mutation_queue';
24
25
  import { PersistencePromise } from './persistence_promise';
@@ -130,6 +131,10 @@ export interface Persistence {
130
131
  * PORTING NOTE: This is only used for Web multi-tab.
131
132
  */
132
133
  setNetworkEnabled(networkEnabled: boolean): void;
134
+ /**
135
+ * Returns GlobalCache representing a general purpose cache for global values.
136
+ */
137
+ getGlobalsCache(): GlobalsCache;
133
138
  /**
134
139
  * Returns a MutationQueue representing the persisted mutations for the
135
140
  * given user.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Persistence } from '../../../src/local/persistence';
18
+ import { ByteString } from '../../../src/util/byte_string';
19
+ /**
20
+ * A wrapper around a GlobalsCache that automatically creates a
21
+ * transaction around every operation to reduce test boilerplate.
22
+ */
23
+ export declare class TestGlobalsCache {
24
+ private readonly persistence;
25
+ private readonly cache;
26
+ constructor(persistence: Persistence);
27
+ getSessionToken(): Promise<ByteString>;
28
+ setSessionToken(sessionToken: ByteString): Promise<void>;
29
+ }