Skip to content

New way to config Firestore SDK Cache. #7015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/brown-beers-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@firebase/firestore": minor
"firebase-repo-scripts-prune-dts": minor
---

Introduces a new way to config Firestore SDK Cache.
58 changes: 56 additions & 2 deletions common/api-review/firestore.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ export class DocumentSnapshot<T = DocumentData> {

export { EmulatorMockTokenOptions }

// @public
// @public @deprecated
export function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;

// @public
// @public @deprecated
export function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;

// @public
Expand Down Expand Up @@ -216,13 +216,17 @@ export class FirestoreError extends FirebaseError {
// @public
export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';

// @public
export type FirestoreLocalCache = MemoryLocalCache | IndexedDbLocalCache;

// @public
export interface FirestoreSettings {
cacheSizeBytes?: number;
experimentalAutoDetectLongPolling?: boolean;
experimentalForceLongPolling?: boolean;
host?: string;
ignoreUndefinedProperties?: boolean;
localCache?: FirestoreLocalCache;
ssl?: boolean;
}

Expand Down Expand Up @@ -285,6 +289,47 @@ export interface IndexConfiguration {
readonly indexes?: Index[];
}

// @public
export interface IndexedDbCacheSettings {
cacheSizeBytes?: number;
tabManager?: IndexedDbTabManager;
}

// @public
export interface IndexedDbLocalCache {
// (undocumented)
kind: 'indexeddb';
}

// @public
export function indexedDbLocalCache(settings?: IndexedDbCacheSettings): IndexedDbLocalCache;

// @public
export interface IndexedDbMultipleTabManager {
// (undocumented)
kind: 'IndexedDbMultipleTab';
}

// @public
export function indexedDbMultipleTabManager(): IndexedDbMultipleTabManager;

// @public
export interface IndexedDbSingleTabManager {
// (undocumented)
kind: 'indexedDbSingleTab';
}

// @public
export function indexedDbSingleTabManager(settings: IndexedDbSingleTabManagerSettings | undefined): IndexedDbSingleTabManager;

// @public
export interface IndexedDbSingleTabManagerSettings {
forceOwnership?: boolean;
}

// @public
export type IndexedDbTabManager = IndexedDbSingleTabManager | IndexedDbMultipleTabManager;

// @beta
export interface IndexField {
// (undocumented)
Expand Down Expand Up @@ -324,6 +369,15 @@ export interface LoadBundleTaskProgress {

export { LogLevel }

// @public
export interface MemoryLocalCache {
// (undocumented)
kind: 'memory';
}

// @public
export function memoryLocalCache(): MemoryLocalCache;

// @public
export function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;

Expand Down
15 changes: 15 additions & 0 deletions packages/firestore/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ export {
AggregateQuerySnapshot
} from './lite-api/aggregate_types';

export {
FirestoreLocalCache,
IndexedDbLocalCache,
IndexedDbMultipleTabManager,
indexedDbLocalCache,
indexedDbMultipleTabManager,
IndexedDbCacheSettings,
indexedDbSingleTabManager,
IndexedDbSingleTabManager,
IndexedDbSingleTabManagerSettings,
MemoryLocalCache,
memoryLocalCache,
IndexedDbTabManager
} from './api/cache_config';

export { FieldPath, documentId } from './api/field_path';

export {
Expand Down
Loading