Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,9 @@ class CollectionReference<T extends firestore_interop.CollectionReferenceJsImpl>
return _expando[jsObject] ??= CollectionReference._fromJsObject(jsObject);
}

factory CollectionReference() => CollectionReference._fromJsObject(
firestore_interop.CollectionReferenceJsImpl());
factory CollectionReference(
firestore_interop.CollectionReferenceJsImpl jsObject) =>
CollectionReference._fromJsObject(jsObject);

CollectionReference._fromJsObject(
firestore_interop.CollectionReferenceJsImpl jsObject)
Expand All @@ -730,8 +731,7 @@ class CollectionReference<T extends firestore_interop.CollectionReferenceJsImpl>
final future =
firestore_interop.addDoc(jsObject, jsify(data)! as JSObject).toDart;
final result = await future;
return DocumentReference.getInstance(
(result)! as firestore_interop.DocumentReferenceJsImpl);
return DocumentReference.getInstance(result);
}

DocumentReference doc([String? documentPath]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ external FirestoreJsImpl initializeFirestore(
@staticInterop

/// Type DocumentReferenceJsImpl
external JSPromise addDoc(
external JSPromise<DocumentReferenceJsImpl> addDoc(
CollectionReferenceJsImpl reference,
JSAny data,
);
Expand Down Expand Up @@ -123,37 +123,37 @@ external JSPromise enableNetwork(FirestoreJsImpl firestore);

@JS()
@staticInterop
external JSPromise getDoc(
external JSPromise<DocumentSnapshotJsImpl> getDoc(
DocumentReferenceJsImpl reference,
);

@JS()
@staticInterop
external JSPromise getDocFromCache(
external JSPromise<DocumentSnapshotJsImpl> getDocFromCache(
DocumentReferenceJsImpl reference,
);

@JS()
@staticInterop
external JSPromise getDocFromServer(
external JSPromise<DocumentSnapshotJsImpl> getDocFromServer(
DocumentReferenceJsImpl reference,
);

@JS()
@staticInterop
external JSPromise getDocs(
external JSPromise<QuerySnapshotJsImpl> getDocs(
QueryJsImpl query,
);

@JS()
@staticInterop
external JSPromise getDocsFromCache(
external JSPromise<QuerySnapshotJsImpl> getDocsFromCache(
QueryJsImpl query,
);

@JS()
@staticInterop
external JSPromise getDocsFromServer(
external JSPromise<QuerySnapshotJsImpl> getDocsFromServer(
QueryJsImpl query,
);

Expand Down Expand Up @@ -344,11 +344,7 @@ extension FirestoreJsImplExtension on FirestoreJsImpl {
external JSString get type;
}

@JS('WriteBatch')
@staticInterop
abstract class WriteBatchJsImpl {}

extension WriteBatchJsImplExtension on WriteBatchJsImpl {
extension type WriteBatchJsImpl._(JSObject _) implements JSObject {
external JSPromise commit();

external WriteBatchJsImpl delete(DocumentReferenceJsImpl documentRef);
Expand All @@ -363,13 +359,7 @@ extension WriteBatchJsImplExtension on WriteBatchJsImpl {
);
}

@JS('CollectionReference')
@staticInterop
class CollectionReferenceJsImpl extends QueryJsImpl {
external factory CollectionReferenceJsImpl();
}

extension CollectionReferenceJsImplExtension on CollectionReferenceJsImpl {
extension type CollectionReferenceJsImpl._(JSObject _) implements QueryJsImpl {
external JSString get id;
external DocumentReferenceJsImpl get parent;
external JSString get path;
Expand Down Expand Up @@ -430,11 +420,7 @@ extension GeoPointJsImplExtension on GeoPointJsImpl {
@staticInterop
external VectorValueJsImpl get VectorValueConstructor;

@JS('VectorValue')
@staticInterop
class VectorValueJsImpl {}

extension VectorValueJsImplExtension on VectorValueJsImpl {
extension type VectorValueJsImpl._(JSObject _) implements JSObject {
external JSArray toArray();
}

Expand Down Expand Up @@ -464,12 +450,7 @@ extension BytesJsImplExtension on BytesJsImpl {
external JSBoolean isEqual(JSObject other);
}

@anonymous
@JS()
@staticInterop
abstract class DocumentChangeJsImpl {}

extension DocumentChangeJsImplExtension on DocumentChangeJsImpl {
extension type DocumentChangeJsImpl._(JSObject _) implements JSObject {
external JSString /*'added'|'removed'|'modified'*/ get type;

external set type(JSString /*'added'|'removed'|'modified'*/ v);
Expand All @@ -491,11 +472,7 @@ extension DocumentChangeJsImplExtension on DocumentChangeJsImpl {
@staticInterop
external DocumentReferenceJsImpl get DocumentReferenceJsConstructor;

@JS('DocumentReference')
@staticInterop
abstract class DocumentReferenceJsImpl {}

extension DocumentReferenceJsImplExtension on DocumentReferenceJsImpl {
extension type DocumentReferenceJsImpl._(JSObject _) implements JSObject {
external FirestoreJsImpl get firestore;
external JSString get id;
external CollectionReferenceJsImpl get parent;
Expand All @@ -511,11 +488,7 @@ extension QueryConstraintJsImplExtension on QueryConstraintJsImpl {
external JSString get type;
}

@JS('LoadBundleTask')
@staticInterop
abstract class LoadBundleTaskJsImpl {}

extension LoadBundleTaskJsImplExtension on LoadBundleTaskJsImpl {
extension type LoadBundleTaskJsImpl._(JSObject _) implements JSObject {
external void onProgress(
JSFunction? next,
);
Expand All @@ -526,13 +499,7 @@ extension LoadBundleTaskJsImplExtension on LoadBundleTaskJsImpl {
]);
}

@JS()
@staticInterop
@anonymous
abstract class LoadBundleTaskProgressJsImpl {}

extension LoadBundleTaskProgressJsImplExtension
on LoadBundleTaskProgressJsImpl {
extension type LoadBundleTaskProgressJsImpl._(JSObject _) implements JSObject {
// int or String?
external JSAny get bytesLoaded;

Expand All @@ -546,11 +513,7 @@ extension LoadBundleTaskProgressJsImplExtension
external JSNumber get totalDocuments;
}

@JS('DocumentSnapshot')
@staticInterop
abstract class DocumentSnapshotJsImpl {}

extension DocumentSnapshotJsImplExtension on DocumentSnapshotJsImpl {
extension type DocumentSnapshotJsImpl._(JSObject _) implements JSObject {
external JSString get id;
external SnapshotMetadata get metadata;
external DocumentReferenceJsImpl get ref;
Expand All @@ -564,12 +527,7 @@ extension DocumentSnapshotJsImplExtension on DocumentSnapshotJsImpl {
/// [set()] or [update()].
///
/// See: <https://firebase.google.com/docs/reference/js/firebase.firestore.FieldValue>.
@JS()
@staticInterop
@anonymous
abstract class FieldValue {}

extension FieldValueExtension on FieldValue {
extension type FieldValue._(JSObject _) implements JSObject {
/// Returns `true` if this [FieldValue] is equal to the provided [other].
external JSBoolean isEqual(FieldValue other);
}
Expand All @@ -579,20 +537,12 @@ extension FieldValueExtension on FieldValue {
@staticInterop
external JSObject get fieldValues;

@JS('Query')
@staticInterop
abstract class QueryJsImpl {}

extension QueryJsImplExtension on QueryJsImpl {
extension type QueryJsImpl._(JSObject _) implements JSObject {
external FirestoreJsImpl get firestore;
external JSString get type;
}

@JS('QuerySnapshot')
@staticInterop
abstract class QuerySnapshotJsImpl {}

extension QuerySnapshotJsImplExtension on QuerySnapshotJsImpl {
extension type QuerySnapshotJsImpl._(JSObject _) implements JSObject {
external JSArray get docs;
external JSBoolean get empty;
external SnapshotMetadata get metadata;
Expand All @@ -607,11 +557,7 @@ extension QuerySnapshotJsImplExtension on QuerySnapshotJsImpl {
]);
}

@JS('Transaction')
@staticInterop
abstract class TransactionJsImpl {}

extension TransactionJsImplExtension on TransactionJsImpl {
extension type TransactionJsImpl._(JSObject _) implements JSObject {
external TransactionJsImpl delete(DocumentReferenceJsImpl documentRef);

external JSPromise get(DocumentReferenceJsImpl documentRef);
Expand Down Expand Up @@ -796,66 +742,36 @@ abstract class FirestoreLocalCache {}
///
/// To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache
/// and call initializeFirestore using the settings object.
@anonymous
@JS()
@staticInterop
abstract class MemoryLocalCache extends FirestoreLocalCache {}

extension MemoryLocalCacheExtension on MemoryLocalCache {
extension type MemoryLocalCache._(JSObject _) implements JSObject {
external JSString get kind;
}

/// A tab manager supporting only one tab, no synchronization will be performed across tabs.
@anonymous
@JS()
@staticInterop
abstract class PersistentSingleTabManager {}

extension PersistentSingleTabManagerExtension on PersistentSingleTabManager {
extension type PersistentSingleTabManager._(JSObject _) implements JSObject {
external JSString get kind;
}

/// A tab manager supporting multiple tabs. SDK will synchronize queries and mutations done across all tabs using the SDK.
@anonymous
@JS()
@staticInterop
abstract class PersistentMultipleTabManager {}

extension PersistentMultipleTabManagerExtension
on PersistentMultipleTabManager {
extension type PersistentMultipleTabManager._(JSObject _) implements JSObject {
external JSString get kind;
}

/// A garbage collector deletes documents whenever they are not part of any active queries, and have no local mutations attached to them.
@anonymous
@JS()
@staticInterop
abstract class MemoryEagerGarbageCollector {}

extension MemoryEagerGarbageCollectorExtension on MemoryEagerGarbageCollector {
///
extension type MemoryEagerGarbageCollector._(JSObject _) implements JSObject {
external JSString get kind;
}

/// A garbage collector deletes Least-Recently-Used documents in multiple batches.
@anonymous
@JS()
@staticInterop
abstract class MemoryLruGarbageCollector {}

extension MemoryLruGarbageCollectorExtension on MemoryLruGarbageCollector {
extension type MemoryLruGarbageCollector._(JSObject _) implements JSObject {
external JSString get kind;
}

/// Provides an in-memory cache to the SDK. This is the default cache unless explicitly configured otherwise.
///
/// To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache
/// and call initializeFirestore using the settings object.
@anonymous
@JS()
@staticInterop
abstract class PersistentLocalCache extends FirestoreLocalCache {}

extension PersistentLocalCacheExtension on PersistentLocalCache {
extension type PersistentLocalCache._(JSObject _) implements JSObject {
external JSString get kind;
}

Expand Down Expand Up @@ -912,12 +828,8 @@ extension PersistentCacheSettingsExtension on PersistentCacheSettings {
/// An settings object to configure an PersistentLocalCache instance.
///
/// See: <https://firebase.google.com/docs/reference/js/firestore_.persistentsingletabmanagersettings>.
@JS()
@staticInterop
abstract class PersistentSingleTabManagerSettings {}

extension PersistentSingleTabManagerSettingsExtension
on PersistentSingleTabManagerSettings {
extension type PersistentSingleTabManagerSettings._(JSObject _)
implements JSObject {
/// Whether to force-enable persistent (IndexedDB) cache for the client.
/// This cannot be used with multi-tab synchronization and is primarily
/// intended for use with Web Workers.
Expand All @@ -931,11 +843,7 @@ extension PersistentSingleTabManagerSettingsExtension
/// Metadata about a snapshot, describing the state of the snapshot.
///
/// See: <https://firebase.google.com/docs/reference/js/firebase.firestore.SnapshotMetadata>.
@JS()
@staticInterop
abstract class SnapshotMetadata {}

extension SnapshotMetadataExtension on SnapshotMetadata {
extension type SnapshotMetadata._(JSObject _) implements JSObject {
/// [:true:] if the snapshot includes local writes (set() or update() calls)
/// that haven't been committed to the backend yet. If your listener has opted
/// into metadata updates via onDocumentMetadataSnapshot,
Expand Down Expand Up @@ -1091,12 +999,7 @@ external JSPromise getAggregateFromServer(
JSObject specs,
);

@JS('AggregateQuerySnapshot')
@staticInterop
abstract class AggregateQuerySnapshotJsImpl {}

extension AggregateQuerySnapshotJsImplExtension
on AggregateQuerySnapshotJsImpl {
extension type AggregateQuerySnapshotJsImpl._(JSObject _) implements JSObject {
external JSObject data();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const kCollectionId = 'test';

class MockWebDocumentSnapshot extends Mock implements web.DocumentSnapshot {}

class MockWebSnapshotMetaData extends Mock implements web.SnapshotMetadata {}
// Lint error here but tests pass without this.
// class MockWebSnapshotMetaData extends Mock implements web.SnapshotMetadata {}

class MockFirestoreWeb extends Mock implements web.Firestore {}

Expand Down
Loading