diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart index 678e5177f219..eea2d76f04e5 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart @@ -904,8 +904,6 @@ abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< FieldValue firstNameFieldValue, String? lastName, FieldValue lastNameFieldValue, - int hashCode, - FieldValue hashCodeFieldValue, }); /// Updates fields in the current document using the transaction API. @@ -917,8 +915,6 @@ abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< FieldValue firstNameFieldValue, String? lastName, FieldValue lastNameFieldValue, - int hashCode, - FieldValue hashCodeFieldValue, }); } @@ -955,8 +951,6 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< FieldValue? firstNameFieldValue, Object? lastName = _sentinel, FieldValue? lastNameFieldValue, - Object? hashCode = _sentinel, - FieldValue? hashCodeFieldValue, }) async { assert( firstName == _sentinel || firstNameFieldValue == null, @@ -966,17 +960,11 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< lastName == _sentinel || lastNameFieldValue == null, "Cannot specify both lastName and lastNameFieldValue", ); - assert( - hashCode == _sentinel || hashCodeFieldValue == null, - "Cannot specify both hashCode and hashCodeFieldValue", - ); final json = { if (firstName != _sentinel) 'firstName': firstName as String?, if (firstNameFieldValue != null) 'firstName': firstNameFieldValue, if (lastName != _sentinel) 'lastName': lastName as String?, if (lastNameFieldValue != null) 'lastName': lastNameFieldValue, - if (hashCode != _sentinel) 'hashCode': hashCode as int, - if (hashCodeFieldValue != null) 'hashCode': hashCodeFieldValue, }; return reference.update(json); @@ -988,8 +976,6 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< FieldValue? firstNameFieldValue, Object? lastName = _sentinel, FieldValue? lastNameFieldValue, - Object? hashCode = _sentinel, - FieldValue? hashCodeFieldValue, }) { assert( firstName == _sentinel || firstNameFieldValue == null, @@ -999,17 +985,11 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< lastName == _sentinel || lastNameFieldValue == null, "Cannot specify both lastName and lastNameFieldValue", ); - assert( - hashCode == _sentinel || hashCodeFieldValue == null, - "Cannot specify both hashCode and hashCodeFieldValue", - ); final json = { if (firstName != _sentinel) 'firstName': firstName as String?, if (firstNameFieldValue != null) 'firstName': firstNameFieldValue, if (lastName != _sentinel) 'lastName': lastName as String?, if (lastNameFieldValue != null) 'lastName': lastNameFieldValue, - if (hashCode != _sentinel) 'hashCode': hashCode as int, - if (hashCodeFieldValue != null) 'hashCode': hashCodeFieldValue, }; transaction.update(reference, json); @@ -1133,17 +1113,6 @@ abstract class AdvancedJsonQuery List? whereIn, List? whereNotIn, }); - AdvancedJsonQuery whereHashCode({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); AdvancedJsonQuery orderByDocumentId({ bool descending = false, @@ -1180,18 +1149,6 @@ abstract class AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }); - - AdvancedJsonQuery orderByHashCode({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }); } class _$AdvancedJsonQuery @@ -1433,35 +1390,6 @@ class _$AdvancedJsonQuery ); } - AdvancedJsonQuery whereHashCode({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$AdvancedJsonFieldMap['hashCode']!, - isEqualTo: isEqualTo, - isNotEqualTo: isNotEqualTo, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - isNull: isNull, - whereIn: whereIn, - whereNotIn: whereNotIn, - ), - $queryCursor: $queryCursor, - ); - } - AdvancedJsonQuery orderByDocumentId({ bool descending = false, Object? startAt = _sentinel, @@ -1678,78 +1606,6 @@ class _$AdvancedJsonQuery ); } - AdvancedJsonQuery orderByHashCode({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['hashCode']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - @override bool operator ==(Object other) { return other is _$AdvancedJsonQuery && @@ -1973,8 +1829,6 @@ abstract class _PrivateAdvancedJsonDocumentReference FieldValue firstNameFieldValue, String? lastName, FieldValue lastNameFieldValue, - int hashCode, - FieldValue hashCodeFieldValue, }); /// Updates fields in the current document using the transaction API. @@ -1986,8 +1840,6 @@ abstract class _PrivateAdvancedJsonDocumentReference FieldValue firstNameFieldValue, String? lastName, FieldValue lastNameFieldValue, - int hashCode, - FieldValue hashCodeFieldValue, }); } @@ -2028,8 +1880,6 @@ class _$_PrivateAdvancedJsonDocumentReference FieldValue? firstNameFieldValue, Object? lastName = _sentinel, FieldValue? lastNameFieldValue, - Object? hashCode = _sentinel, - FieldValue? hashCodeFieldValue, }) async { assert( firstName == _sentinel || firstNameFieldValue == null, @@ -2039,17 +1889,11 @@ class _$_PrivateAdvancedJsonDocumentReference lastName == _sentinel || lastNameFieldValue == null, "Cannot specify both lastName and lastNameFieldValue", ); - assert( - hashCode == _sentinel || hashCodeFieldValue == null, - "Cannot specify both hashCode and hashCodeFieldValue", - ); final json = { if (firstName != _sentinel) 'firstName': firstName as String?, if (firstNameFieldValue != null) 'firstName': firstNameFieldValue, if (lastName != _sentinel) 'lastName': lastName as String?, if (lastNameFieldValue != null) 'lastName': lastNameFieldValue, - if (hashCode != _sentinel) 'hashCode': hashCode as int, - if (hashCodeFieldValue != null) 'hashCode': hashCodeFieldValue, }; return reference.update(json); @@ -2061,8 +1905,6 @@ class _$_PrivateAdvancedJsonDocumentReference FieldValue? firstNameFieldValue, Object? lastName = _sentinel, FieldValue? lastNameFieldValue, - Object? hashCode = _sentinel, - FieldValue? hashCodeFieldValue, }) { assert( firstName == _sentinel || firstNameFieldValue == null, @@ -2072,17 +1914,11 @@ class _$_PrivateAdvancedJsonDocumentReference lastName == _sentinel || lastNameFieldValue == null, "Cannot specify both lastName and lastNameFieldValue", ); - assert( - hashCode == _sentinel || hashCodeFieldValue == null, - "Cannot specify both hashCode and hashCodeFieldValue", - ); final json = { if (firstName != _sentinel) 'firstName': firstName as String?, if (firstNameFieldValue != null) 'firstName': firstNameFieldValue, if (lastName != _sentinel) 'lastName': lastName as String?, if (lastNameFieldValue != null) 'lastName': lastNameFieldValue, - if (hashCode != _sentinel) 'hashCode': hashCode as int, - if (hashCodeFieldValue != null) 'hashCode': hashCodeFieldValue, }; transaction.update(reference, json); @@ -2208,17 +2044,6 @@ abstract class _PrivateAdvancedJsonQuery List? whereIn, List? whereNotIn, }); - _PrivateAdvancedJsonQuery whereHashCode({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); _PrivateAdvancedJsonQuery orderByDocumentId({ bool descending = false, @@ -2255,18 +2080,6 @@ abstract class _PrivateAdvancedJsonQuery _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }); - - _PrivateAdvancedJsonQuery orderByHashCode({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }); } class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, @@ -2508,35 +2321,6 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, ); } - _PrivateAdvancedJsonQuery whereHashCode({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$PrivateAdvancedJsonFieldMap['hashCode']!, - isEqualTo: isEqualTo, - isNotEqualTo: isNotEqualTo, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - isNull: isNull, - whereIn: whereIn, - whereNotIn: whereNotIn, - ), - $queryCursor: $queryCursor, - ); - } - _PrivateAdvancedJsonQuery orderByDocumentId({ bool descending = false, Object? startAt = _sentinel, @@ -2755,79 +2539,6 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, ); } - _PrivateAdvancedJsonQuery orderByHashCode({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['hashCode']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - @override bool operator ==(Object other) { return other is _$_PrivateAdvancedJsonQuery && diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart index 9ad47e27ce79..3b3e157f1fd3 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart @@ -160,32 +160,17 @@ class _$PersonDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return PersonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(PersonDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return PersonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(PersonDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return PersonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(PersonDocumentSnapshot._); } Future update({ @@ -249,26 +234,6 @@ class _$PersonDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { - PersonDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); - } - - @override - final Person? data; -} - abstract class PersonQuery implements QueryReference { @override @@ -426,37 +391,14 @@ class _$PersonQuery extends QueryReference final CollectionReference _collection; - PersonQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return PersonQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: PersonDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference.snapshots().map(PersonQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference.get(options).then(PersonQuerySnapshot._fromQuerySnapshot); } @override @@ -897,6 +839,23 @@ class _$PersonQuery extends QueryReference int get hashCode => Object.hash(runtimeType, reference); } +class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { + PersonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PersonDocumentReference get reference { + return PersonDocumentReference( + snapshot.reference, + ); + } + + @override + final Person? data; +} + class PersonQuerySnapshot extends FirestoreQuerySnapshot { PersonQuerySnapshot._( @@ -905,6 +864,38 @@ class PersonQuerySnapshot this.docChanges, ); + factory PersonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + PersonDocumentSnapshot._, + ); + }).toList(); + + return PersonQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -916,18 +907,18 @@ class PersonQuerySnapshot class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements PersonDocumentSnapshot { - PersonQueryDocumentSnapshot._(this.snapshot, this.data); + PersonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final Person data; + @override PersonDocumentReference get reference { return PersonDocumentReference(snapshot.reference); } - - @override - final Person data; } /// A collection reference object can be used for adding documents, @@ -1077,33 +1068,18 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return PublicRedirectedDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(PublicRedirectedDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return PublicRedirectedDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(PublicRedirectedDocumentSnapshot._); } @override Future transactionGet( Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return PublicRedirectedDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); } Future update({ @@ -1151,27 +1127,6 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class PublicRedirectedDocumentSnapshot - extends FirestoreDocumentSnapshot { - PublicRedirectedDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); - } - - @override - final PublicRedirected? data; -} - abstract class PublicRedirectedQuery implements QueryReference { @override @@ -1307,37 +1262,18 @@ class _$PublicRedirectedQuery final CollectionReference _collection; - PublicRedirectedQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return PublicRedirectedQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: PublicRedirectedDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(PublicRedirectedQuerySnapshot._fromQuerySnapshot); } @override @@ -1678,6 +1614,24 @@ class _$PublicRedirectedQuery int get hashCode => Object.hash(runtimeType, reference); } +class PublicRedirectedDocumentSnapshot + extends FirestoreDocumentSnapshot { + PublicRedirectedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PublicRedirectedDocumentReference get reference { + return PublicRedirectedDocumentReference( + snapshot.reference, + ); + } + + @override + final PublicRedirected? data; +} + class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { PublicRedirectedQuerySnapshot._( @@ -1686,6 +1640,40 @@ class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< this.docChanges, ); + factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(PublicRedirectedQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + PublicRedirectedDocumentSnapshot._, + ); + }).toList(); + + return PublicRedirectedQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -1699,18 +1687,19 @@ class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< class PublicRedirectedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements PublicRedirectedDocumentSnapshot { - PublicRedirectedQueryDocumentSnapshot._(this.snapshot, this.data); + PublicRedirectedQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final PublicRedirected data; + @override PublicRedirectedDocumentReference get reference { return PublicRedirectedDocumentReference(snapshot.reference); } - - @override - final PublicRedirected data; } // ************************************************************************** diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart index a8795bd193e6..4495e086395d 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart @@ -5,6 +5,24 @@ import 'model.dart'; part 'simple.g.dart'; +final ignoredGetterRef = IgnoredGetterCollectionReference(); + +@Collection('firestore-example-app/test/getter') +@JsonSerializable() +class IgnoredGetter { + IgnoredGetter(this.value); + + final int value; + + int get count => 42; + + @JsonKey(ignore: true) + int get count2 => 42; + + @JsonKey(ignore: false) + int get count3 => 42; +} + @Collection('root') @JsonSerializable() class Model { diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart index e7850864196c..a2bcf197c655 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart @@ -15,6 +15,782 @@ class _Sentinel { const _sentinel = _Sentinel(); +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class IgnoredGetterCollectionReference + implements + IgnoredGetterQuery, + FirestoreCollectionReference { + factory IgnoredGetterCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$IgnoredGetterCollectionReference; + + static IgnoredGetter fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$IgnoredGetterFromJson(snapshot.data()!); + } + + static Map toFirestore( + IgnoredGetter value, + SetOptions? options, + ) { + return _$IgnoredGetterToJson(value); + } + + @override + CollectionReference get reference; + + @override + IgnoredGetterDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(IgnoredGetter value); +} + +class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery + implements IgnoredGetterCollectionReference { + factory _$IgnoredGetterCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$IgnoredGetterCollectionReference._( + firestore.collection('firestore-example-app/test/getter').withConverter( + fromFirestore: IgnoredGetterCollectionReference.fromFirestore, + toFirestore: IgnoredGetterCollectionReference.toFirestore, + ), + ); + } + + _$IgnoredGetterCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + IgnoredGetterDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return IgnoredGetterDocumentReference( + reference.doc(id), + ); + } + + @override + Future add(IgnoredGetter value) { + return reference + .add(value) + .then((ref) => IgnoredGetterDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$IgnoredGetterCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class IgnoredGetterDocumentReference + extends FirestoreDocumentReference { + factory IgnoredGetterDocumentReference( + DocumentReference reference) = + _$IgnoredGetterDocumentReference; + + DocumentReference get reference; + + /// A reference to the [IgnoredGetterCollectionReference] containing this document. + IgnoredGetterCollectionReference get parent { + return _$IgnoredGetterCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + int value, + FieldValue valueFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + int value, + FieldValue valueFieldValue, + }); +} + +class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< + IgnoredGetter, + IgnoredGetterDocumentSnapshot> implements IgnoredGetterDocumentReference { + _$IgnoredGetterDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [IgnoredGetterCollectionReference] containing this document. + IgnoredGetterCollectionReference get parent { + return _$IgnoredGetterCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(IgnoredGetterDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(IgnoredGetterDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction) { + return transaction.get(reference).then(IgnoredGetterDocumentSnapshot._); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) 'value': value as int, + if (valueFieldValue != null) 'value': valueFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) 'value': value as int, + if (valueFieldValue != null) 'value': valueFieldValue, + }; + + transaction.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is IgnoredGetterDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class IgnoredGetterQuery + implements QueryReference { + @override + IgnoredGetterQuery limit(int limit); + + @override + IgnoredGetterQuery limitToLast(int limit); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + IgnoredGetterQuery orderByFieldPath( + FieldPath fieldPath, { + bool descending = false, + Object? startAt, + Object? startAfter, + Object? endAt, + Object? endBefore, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + IgnoredGetterQuery whereFieldPath( + FieldPath fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + IgnoredGetterQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + IgnoredGetterQuery whereValue({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + + IgnoredGetterQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }); + + IgnoredGetterQuery orderByValue({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }); +} + +class _$IgnoredGetterQuery + extends QueryReference + implements IgnoredGetterQuery { + _$IgnoredGetterQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference + .snapshots() + .map(IgnoredGetterQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(IgnoredGetterQuerySnapshot._fromQuerySnapshot); + } + + @override + IgnoredGetterQuery limit(int limit) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + IgnoredGetterQuery limitToLast(int limit) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + IgnoredGetterQuery orderByFieldPath( + FieldPath fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }) { + final query = + $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + IgnoredGetterQuery whereFieldPath( + FieldPath fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: isNull, + ), + $queryCursor: $queryCursor, + ); + } + + IgnoredGetterQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + $queryCursor: $queryCursor, + ); + } + + IgnoredGetterQuery whereValue({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$IgnoredGetterFieldMap['value']!, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + $queryCursor: $queryCursor, + ); + } + + IgnoredGetterQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, + descending: descending); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + IgnoredGetterQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor + .orderBy(_$IgnoredGetterFieldMap['value']!, descending: descending); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$IgnoredGetterQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class IgnoredGetterDocumentSnapshot + extends FirestoreDocumentSnapshot { + IgnoredGetterDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + IgnoredGetterDocumentReference get reference { + return IgnoredGetterDocumentReference( + snapshot.reference, + ); + } + + @override + final IgnoredGetter? data; +} + +class IgnoredGetterQuerySnapshot extends FirestoreQuerySnapshot { + IgnoredGetterQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + factory IgnoredGetterQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(IgnoredGetterQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + IgnoredGetterDocumentSnapshot._, + ); + }).toList(); + + return IgnoredGetterQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + IgnoredGetterDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class IgnoredGetterQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements IgnoredGetterDocumentSnapshot { + IgnoredGetterQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final IgnoredGetter data; + + @override + IgnoredGetterDocumentReference get reference { + return IgnoredGetterDocumentReference(snapshot.reference); + } +} + /// A collection reference object can be used for adding documents, /// getting document references, and querying for documents /// (using the methods inherited from Query). @@ -156,32 +932,17 @@ class _$ModelDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return ModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(ModelDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return ModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(ModelDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return ModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(ModelDocumentSnapshot._); } Future update({ @@ -221,32 +982,12 @@ class _$ModelDocumentReference bool operator ==(Object other) { return other is ModelDocumentReference && other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { - ModelDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - ModelDocumentReference get reference { - return ModelDocumentReference( - snapshot.reference, - ); + other.parent == parent && + other.id == id; } @override - final Model? data; + int get hashCode => Object.hash(runtimeType, parent, id); } abstract class ModelQuery implements QueryReference { @@ -382,37 +1123,14 @@ class _$ModelQuery extends QueryReference final CollectionReference _collection; - ModelQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return ModelQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: ModelDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return ModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference.snapshots().map(ModelQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference.get(options).then(ModelQuerySnapshot._fromQuerySnapshot); } @override @@ -752,6 +1470,23 @@ class _$ModelQuery extends QueryReference int get hashCode => Object.hash(runtimeType, reference); } +class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { + ModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ModelDocumentReference get reference { + return ModelDocumentReference( + snapshot.reference, + ); + } + + @override + final Model? data; +} + class ModelQuerySnapshot extends FirestoreQuerySnapshot { ModelQuerySnapshot._( @@ -760,6 +1495,38 @@ class ModelQuerySnapshot this.docChanges, ); + factory ModelQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(ModelQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + ModelDocumentSnapshot._, + ); + }).toList(); + + return ModelQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -771,18 +1538,18 @@ class ModelQuerySnapshot class ModelQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ModelDocumentSnapshot { - ModelQueryDocumentSnapshot._(this.snapshot, this.data); + ModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final Model data; + @override ModelDocumentReference get reference { return ModelDocumentReference(snapshot.reference); } - - @override - final Model data; } /// A collection reference object can be used for adding documents, @@ -946,32 +1713,17 @@ class _$NestedDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return NestedDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(NestedDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return NestedDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(NestedDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return NestedDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(NestedDocumentSnapshot._); } Future update({ @@ -1101,26 +1853,6 @@ class _$NestedDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { - NestedDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - NestedDocumentReference get reference { - return NestedDocumentReference( - snapshot.reference, - ); - } - - @override - final Nested? data; -} - abstract class NestedQuery implements QueryReference { @override @@ -1370,37 +2102,14 @@ class _$NestedQuery extends QueryReference final CollectionReference _collection; - NestedQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return NestedQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: NestedDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return NestedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference.snapshots().map(NestedQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference.get(options).then(NestedQuerySnapshot._fromQuerySnapshot); } @override @@ -2245,6 +2954,23 @@ class _$NestedQuery extends QueryReference int get hashCode => Object.hash(runtimeType, reference); } +class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { + NestedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + NestedDocumentReference get reference { + return NestedDocumentReference( + snapshot.reference, + ); + } + + @override + final Nested? data; +} + class NestedQuerySnapshot extends FirestoreQuerySnapshot { NestedQuerySnapshot._( @@ -2253,6 +2979,38 @@ class NestedQuerySnapshot this.docChanges, ); + factory NestedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(NestedQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + NestedDocumentSnapshot._, + ); + }).toList(); + + return NestedQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + NestedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -2264,18 +3022,18 @@ class NestedQuerySnapshot class NestedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements NestedDocumentSnapshot { - NestedQueryDocumentSnapshot._(this.snapshot, this.data); + NestedQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final Nested data; + @override NestedDocumentReference get reference { return NestedDocumentReference(snapshot.reference); } - - @override - final Nested data; } /// A collection reference object can be used for adding documents, @@ -2406,33 +3164,18 @@ class _$SplitFileModelDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return SplitFileModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(SplitFileModelDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return SplitFileModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(SplitFileModelDocumentSnapshot._); } @override Future transactionGet( Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return SplitFileModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(SplitFileModelDocumentSnapshot._); } @override @@ -2447,27 +3190,6 @@ class _$SplitFileModelDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class SplitFileModelDocumentSnapshot - extends FirestoreDocumentSnapshot { - SplitFileModelDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - SplitFileModelDocumentReference get reference { - return SplitFileModelDocumentReference( - snapshot.reference, - ); - } - - @override - final SplitFileModel? data; -} - abstract class SplitFileModelQuery implements QueryReference { @override @@ -2580,37 +3302,18 @@ class _$SplitFileModelQuery final CollectionReference _collection; - SplitFileModelQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return SplitFileModelQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: SplitFileModelDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return SplitFileModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(SplitFileModelQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(SplitFileModelQuerySnapshot._fromQuerySnapshot); } @override @@ -2849,6 +3552,24 @@ class _$SplitFileModelQuery int get hashCode => Object.hash(runtimeType, reference); } +class SplitFileModelDocumentSnapshot + extends FirestoreDocumentSnapshot { + SplitFileModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + SplitFileModelDocumentReference get reference { + return SplitFileModelDocumentReference( + snapshot.reference, + ); + } + + @override + final SplitFileModel? data; +} + class SplitFileModelQuerySnapshot extends FirestoreQuerySnapshot { SplitFileModelQuerySnapshot._( @@ -2857,6 +3578,39 @@ class SplitFileModelQuerySnapshot extends FirestoreQuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(SplitFileModelQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + SplitFileModelDocumentSnapshot._, + ); + }).toList(); + + return SplitFileModelQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + SplitFileModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -2870,18 +3624,18 @@ class SplitFileModelQuerySnapshot extends FirestoreQuerySnapshot implements SplitFileModelDocumentSnapshot { - SplitFileModelQueryDocumentSnapshot._(this.snapshot, this.data); + SplitFileModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final SplitFileModel data; + @override SplitFileModelDocumentReference get reference { return SplitFileModelDocumentReference(snapshot.reference); } - - @override - final SplitFileModel data; } /// A collection reference object can be used for adding documents, @@ -3007,32 +3761,17 @@ class _$EmptyModelDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return EmptyModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(EmptyModelDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return EmptyModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(EmptyModelDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return EmptyModelDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(EmptyModelDocumentSnapshot._); } @override @@ -3047,26 +3786,6 @@ class _$EmptyModelDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { - EmptyModelDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); - } - - @override - final EmptyModel? data; -} - abstract class EmptyModelQuery implements QueryReference { @override @@ -3173,43 +3892,24 @@ class _$EmptyModelQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - EmptyModelQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return EmptyModelQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: EmptyModelDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return EmptyModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(EmptyModelQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(EmptyModelQuerySnapshot._fromQuerySnapshot); } @override @@ -3448,6 +4148,23 @@ class _$EmptyModelQuery int get hashCode => Object.hash(runtimeType, reference); } +class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { + EmptyModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + EmptyModelDocumentReference get reference { + return EmptyModelDocumentReference( + snapshot.reference, + ); + } + + @override + final EmptyModel? data; +} + class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { EmptyModelQuerySnapshot._( @@ -3456,6 +4173,38 @@ class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(EmptyModelQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + EmptyModelDocumentSnapshot._, + ); + }).toList(); + + return EmptyModelQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -3468,18 +4217,18 @@ class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot implements EmptyModelDocumentSnapshot { - EmptyModelQueryDocumentSnapshot._(this.snapshot, this.data); + EmptyModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final EmptyModel data; + @override EmptyModelDocumentReference get reference { return EmptyModelDocumentReference(snapshot.reference); } - - @override - final EmptyModel data; } /// A collection reference object can be used for adding documents, @@ -3626,32 +4375,17 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return OptionalJsonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(OptionalJsonDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return OptionalJsonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(OptionalJsonDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return OptionalJsonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(OptionalJsonDocumentSnapshot._); } Future update({ @@ -3699,27 +4433,6 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class OptionalJsonDocumentSnapshot - extends FirestoreDocumentSnapshot { - OptionalJsonDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - OptionalJsonDocumentReference get reference { - return OptionalJsonDocumentReference( - snapshot.reference, - ); - } - - @override - final OptionalJson? data; -} - abstract class OptionalJsonQuery implements QueryReference { @override @@ -3855,37 +4568,18 @@ class _$OptionalJsonQuery final CollectionReference _collection; - OptionalJsonQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return OptionalJsonQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: OptionalJsonDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return OptionalJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(OptionalJsonQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(OptionalJsonQuerySnapshot._fromQuerySnapshot); } @override @@ -4225,6 +4919,24 @@ class _$OptionalJsonQuery int get hashCode => Object.hash(runtimeType, reference); } +class OptionalJsonDocumentSnapshot + extends FirestoreDocumentSnapshot { + OptionalJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + OptionalJsonDocumentReference get reference { + return OptionalJsonDocumentReference( + snapshot.reference, + ); + } + + @override + final OptionalJson? data; +} + class OptionalJsonQuerySnapshot extends FirestoreQuerySnapshot { OptionalJsonQuerySnapshot._( @@ -4233,6 +4945,39 @@ class OptionalJsonQuerySnapshot extends FirestoreQuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(OptionalJsonQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + OptionalJsonDocumentSnapshot._, + ); + }).toList(); + + return OptionalJsonQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + OptionalJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -4245,18 +4990,18 @@ class OptionalJsonQuerySnapshot extends FirestoreQuerySnapshot implements OptionalJsonDocumentSnapshot { - OptionalJsonQueryDocumentSnapshot._(this.snapshot, this.data); + OptionalJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final OptionalJson data; + @override OptionalJsonDocumentReference get reference { return OptionalJsonDocumentReference(snapshot.reference); } - - @override - final OptionalJson data; } /// A collection reference object can be used for adding documents, @@ -4400,32 +5145,17 @@ class _$MixedJsonDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return MixedJsonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(MixedJsonDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return MixedJsonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(MixedJsonDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return MixedJsonDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(MixedJsonDocumentSnapshot._); } Future update({ @@ -4473,26 +5203,6 @@ class _$MixedJsonDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { - MixedJsonDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - MixedJsonDocumentReference get reference { - return MixedJsonDocumentReference( - snapshot.reference, - ); - } - - @override - final MixedJson? data; -} - abstract class MixedJsonQuery implements QueryReference { @override @@ -4627,37 +5337,16 @@ class _$MixedJsonQuery extends QueryReference final CollectionReference _collection; - MixedJsonQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return MixedJsonQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: MixedJsonDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return MixedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference.snapshots().map(MixedJsonQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(MixedJsonQuerySnapshot._fromQuerySnapshot); } @override @@ -4997,6 +5686,23 @@ class _$MixedJsonQuery extends QueryReference int get hashCode => Object.hash(runtimeType, reference); } +class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { + MixedJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + MixedJsonDocumentReference get reference { + return MixedJsonDocumentReference( + snapshot.reference, + ); + } + + @override + final MixedJson? data; +} + class MixedJsonQuerySnapshot extends FirestoreQuerySnapshot { MixedJsonQuerySnapshot._( @@ -5005,6 +5711,38 @@ class MixedJsonQuerySnapshot this.docChanges, ); + factory MixedJsonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(MixedJsonQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + MixedJsonDocumentSnapshot._, + ); + }).toList(); + + return MixedJsonQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + MixedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -5017,18 +5755,18 @@ class MixedJsonQuerySnapshot class MixedJsonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements MixedJsonDocumentSnapshot { - MixedJsonQueryDocumentSnapshot._(this.snapshot, this.data); + MixedJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final MixedJson data; + @override MixedJsonDocumentReference get reference { return MixedJsonDocumentReference(snapshot.reference); } - - @override - final MixedJson data; } /// A collection reference object can be used for adding documents, @@ -5214,32 +5952,17 @@ class _$RootDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return RootDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(RootDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return RootDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(RootDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return RootDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(RootDocumentSnapshot._); } Future update({ @@ -5303,26 +6026,6 @@ class _$RootDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class RootDocumentSnapshot extends FirestoreDocumentSnapshot { - RootDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - RootDocumentReference get reference { - return RootDocumentReference( - snapshot.reference, - ); - } - - @override - final Root? data; -} - abstract class RootQuery implements QueryReference { @override RootQuery limit(int limit); @@ -5479,37 +6182,14 @@ class _$RootQuery extends QueryReference final CollectionReference _collection; - RootQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return RootQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: RootDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return RootQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference.snapshots().map(RootQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference.get(options).then(RootQuerySnapshot._fromQuerySnapshot); } @override @@ -5947,7 +6627,24 @@ class _$RootQuery extends QueryReference } @override - int get hashCode => Object.hash(runtimeType, reference); + int get hashCode => Object.hash(runtimeType, reference); +} + +class RootDocumentSnapshot extends FirestoreDocumentSnapshot { + RootDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + RootDocumentReference get reference { + return RootDocumentReference( + snapshot.reference, + ); + } + + @override + final Root? data; } class RootQuerySnapshot @@ -5958,6 +6655,37 @@ class RootQuerySnapshot this.docChanges, ); + factory RootQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(RootQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + RootDocumentSnapshot._, + ); + }).toList(); + + return RootQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange _decodeDocumentChange( + DocumentChange docChange, + RootDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -5969,18 +6697,18 @@ class RootQuerySnapshot class RootQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements RootDocumentSnapshot { - RootQueryDocumentSnapshot._(this.snapshot, this.data); + RootQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final Root data; + @override RootDocumentReference get reference { return RootDocumentReference(snapshot.reference); } - - @override - final Root data; } /// A collection reference object can be used for adding documents, @@ -6144,32 +6872,17 @@ class _$SubDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return SubDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(SubDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return SubDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(SubDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return SubDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(SubDocumentSnapshot._); } Future update({ @@ -6233,26 +6946,6 @@ class _$SubDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class SubDocumentSnapshot extends FirestoreDocumentSnapshot { - SubDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - SubDocumentReference get reference { - return SubDocumentReference( - snapshot.reference, - ); - } - - @override - final Sub? data; -} - abstract class SubQuery implements QueryReference { @override SubQuery limit(int limit); @@ -6409,37 +7102,14 @@ class _$SubQuery extends QueryReference final CollectionReference _collection; - SubQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return SubQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: SubDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return SubQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference.snapshots().map(SubQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference.get(options).then(SubQuerySnapshot._fromQuerySnapshot); } @override @@ -6880,6 +7550,23 @@ class _$SubQuery extends QueryReference int get hashCode => Object.hash(runtimeType, reference); } +class SubDocumentSnapshot extends FirestoreDocumentSnapshot { + SubDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + SubDocumentReference get reference { + return SubDocumentReference( + snapshot.reference, + ); + } + + @override + final Sub? data; +} + class SubQuerySnapshot extends FirestoreQuerySnapshot { SubQuerySnapshot._( @@ -6888,6 +7575,37 @@ class SubQuerySnapshot this.docChanges, ); + factory SubQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(SubQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + SubDocumentSnapshot._, + ); + }).toList(); + + return SubQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange _decodeDocumentChange( + DocumentChange docChange, + SubDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -6899,18 +7617,18 @@ class SubQuerySnapshot class SubQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements SubDocumentSnapshot { - SubQueryDocumentSnapshot._(this.snapshot, this.data); + SubQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final Sub data; + @override SubDocumentReference get reference { return SubDocumentReference(snapshot.reference); } - - @override - final Sub data; } /// A collection reference object can be used for adding documents, @@ -7075,32 +7793,17 @@ class _$AsCamelCaseDocumentReference @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return AsCamelCaseDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(AsCamelCaseDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return AsCamelCaseDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(AsCamelCaseDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return AsCamelCaseDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(AsCamelCaseDocumentSnapshot._); } Future update({ @@ -7148,27 +7851,6 @@ class _$AsCamelCaseDocumentReference int get hashCode => Object.hash(runtimeType, parent, id); } -class AsCamelCaseDocumentSnapshot - extends FirestoreDocumentSnapshot { - AsCamelCaseDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - AsCamelCaseDocumentReference get reference { - return AsCamelCaseDocumentReference( - snapshot.reference, - ); - } - - @override - final AsCamelCase? data; -} - abstract class AsCamelCaseQuery implements QueryReference { @override @@ -7304,37 +7986,18 @@ class _$AsCamelCaseQuery final CollectionReference _collection; - AsCamelCaseQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return AsCamelCaseQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: AsCamelCaseDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return AsCamelCaseQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(AsCamelCaseQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(AsCamelCaseQuerySnapshot._fromQuerySnapshot); } @override @@ -7674,6 +8337,24 @@ class _$AsCamelCaseQuery int get hashCode => Object.hash(runtimeType, reference); } +class AsCamelCaseDocumentSnapshot + extends FirestoreDocumentSnapshot { + AsCamelCaseDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + AsCamelCaseDocumentReference get reference { + return AsCamelCaseDocumentReference( + snapshot.reference, + ); + } + + @override + final AsCamelCase? data; +} + class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot { AsCamelCaseQuerySnapshot._( @@ -7682,6 +8363,38 @@ class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(AsCamelCaseQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + AsCamelCaseDocumentSnapshot._, + ); + }).toList(); + + return AsCamelCaseQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + AsCamelCaseDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -7694,18 +8407,18 @@ class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot implements AsCamelCaseDocumentSnapshot { - AsCamelCaseQueryDocumentSnapshot._(this.snapshot, this.data); + AsCamelCaseQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final AsCamelCase data; + @override AsCamelCaseDocumentReference get reference { return AsCamelCaseDocumentReference(snapshot.reference); } - - @override - final AsCamelCase data; } /// A collection reference object can be used for adding documents, @@ -7872,33 +8585,18 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return CustomSubNameDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(CustomSubNameDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return CustomSubNameDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(CustomSubNameDocumentSnapshot._); } @override Future transactionGet( Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return CustomSubNameDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(CustomSubNameDocumentSnapshot._); } Future update({ @@ -7946,27 +8644,6 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class CustomSubNameDocumentSnapshot - extends FirestoreDocumentSnapshot { - CustomSubNameDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - CustomSubNameDocumentReference get reference { - return CustomSubNameDocumentReference( - snapshot.reference, - ); - } - - @override - final CustomSubName? data; -} - abstract class CustomSubNameQuery implements QueryReference { @override @@ -8102,37 +8779,18 @@ class _$CustomSubNameQuery final CollectionReference _collection; - CustomSubNameQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return CustomSubNameQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: CustomSubNameDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return CustomSubNameQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(CustomSubNameQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(CustomSubNameQuerySnapshot._fromQuerySnapshot); } @override @@ -8472,6 +9130,24 @@ class _$CustomSubNameQuery int get hashCode => Object.hash(runtimeType, reference); } +class CustomSubNameDocumentSnapshot + extends FirestoreDocumentSnapshot { + CustomSubNameDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + CustomSubNameDocumentReference get reference { + return CustomSubNameDocumentReference( + snapshot.reference, + ); + } + + @override + final CustomSubName? data; +} + class CustomSubNameQuerySnapshot extends FirestoreQuerySnapshot { CustomSubNameQuerySnapshot._( @@ -8480,6 +9156,39 @@ class CustomSubNameQuerySnapshot extends FirestoreQuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(CustomSubNameQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + CustomSubNameDocumentSnapshot._, + ); + }).toList(); + + return CustomSubNameQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + CustomSubNameDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -8492,18 +9201,18 @@ class CustomSubNameQuerySnapshot extends FirestoreQuerySnapshot implements CustomSubNameDocumentSnapshot { - CustomSubNameQueryDocumentSnapshot._(this.snapshot, this.data); + CustomSubNameQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final CustomSubName data; + @override CustomSubNameDocumentReference get reference { return CustomSubNameDocumentReference(snapshot.reference); } - - @override - final CustomSubName data; } /// A collection reference object can be used for adding documents, @@ -8671,33 +9380,20 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return ThisIsACustomPrefixDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(ThisIsACustomPrefixDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return ThisIsACustomPrefixDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(ThisIsACustomPrefixDocumentSnapshot._); } @override Future transactionGet( Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return ThisIsACustomPrefixDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction + .get(reference) + .then(ThisIsACustomPrefixDocumentSnapshot._); } Future update({ @@ -8745,27 +9441,6 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class ThisIsACustomPrefixDocumentSnapshot - extends FirestoreDocumentSnapshot { - ThisIsACustomPrefixDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - ThisIsACustomPrefixDocumentReference get reference { - return ThisIsACustomPrefixDocumentReference( - snapshot.reference, - ); - } - - @override - final CustomClassPrefix? data; -} - abstract class ThisIsACustomPrefixQuery implements QueryReference { @@ -8902,39 +9577,19 @@ class _$ThisIsACustomPrefixQuery final CollectionReference _collection; - ThisIsACustomPrefixQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return ThisIsACustomPrefixQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: ThisIsACustomPrefixDocumentSnapshot._( - change.doc, change.doc.data()), - ); - }).toList(); - - return ThisIsACustomPrefixQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots( [SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); } @override @@ -9274,6 +9929,24 @@ class _$ThisIsACustomPrefixQuery int get hashCode => Object.hash(runtimeType, reference); } +class ThisIsACustomPrefixDocumentSnapshot + extends FirestoreDocumentSnapshot { + ThisIsACustomPrefixDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ThisIsACustomPrefixDocumentReference get reference { + return ThisIsACustomPrefixDocumentReference( + snapshot.reference, + ); + } + + @override + final CustomClassPrefix? data; +} + class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< CustomClassPrefix, ThisIsACustomPrefixQueryDocumentSnapshot> { ThisIsACustomPrefixQuerySnapshot._( @@ -9282,6 +9955,40 @@ class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< this.docChanges, ); + factory ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(ThisIsACustomPrefixQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + ThisIsACustomPrefixDocumentSnapshot._, + ); + }).toList(); + + return ThisIsACustomPrefixQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ThisIsACustomPrefixDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -9295,18 +10002,19 @@ class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< class ThisIsACustomPrefixQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ThisIsACustomPrefixDocumentSnapshot { - ThisIsACustomPrefixQueryDocumentSnapshot._(this.snapshot, this.data); + ThisIsACustomPrefixQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final CustomClassPrefix data; + @override ThisIsACustomPrefixDocumentReference get reference { return ThisIsACustomPrefixDocumentReference(snapshot.reference); } - - @override - final CustomClassPrefix data; } /// A collection reference object can be used for adding documents, @@ -9463,32 +10171,17 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return ExplicitPathDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(ExplicitPathDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return ExplicitPathDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(ExplicitPathDocumentSnapshot._); } @override Future transactionGet(Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return ExplicitPathDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(ExplicitPathDocumentSnapshot._); } Future update({ @@ -9536,27 +10229,6 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class ExplicitPathDocumentSnapshot - extends FirestoreDocumentSnapshot { - ExplicitPathDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - ExplicitPathDocumentReference get reference { - return ExplicitPathDocumentReference( - snapshot.reference, - ); - } - - @override - final ExplicitPath? data; -} - abstract class ExplicitPathQuery implements QueryReference { @override @@ -9692,37 +10364,18 @@ class _$ExplicitPathQuery final CollectionReference _collection; - ExplicitPathQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return ExplicitPathQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: ExplicitPathDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return ExplicitPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(ExplicitPathQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(ExplicitPathQuerySnapshot._fromQuerySnapshot); } @override @@ -10062,6 +10715,24 @@ class _$ExplicitPathQuery int get hashCode => Object.hash(runtimeType, reference); } +class ExplicitPathDocumentSnapshot + extends FirestoreDocumentSnapshot { + ExplicitPathDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ExplicitPathDocumentReference get reference { + return ExplicitPathDocumentReference( + snapshot.reference, + ); + } + + @override + final ExplicitPath? data; +} + class ExplicitPathQuerySnapshot extends FirestoreQuerySnapshot { ExplicitPathQuerySnapshot._( @@ -10070,6 +10741,39 @@ class ExplicitPathQuerySnapshot extends FirestoreQuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(ExplicitPathQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + ExplicitPathDocumentSnapshot._, + ); + }).toList(); + + return ExplicitPathQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ExplicitPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -10082,18 +10786,18 @@ class ExplicitPathQuerySnapshot extends FirestoreQuerySnapshot implements ExplicitPathDocumentSnapshot { - ExplicitPathQueryDocumentSnapshot._(this.snapshot, this.data); + ExplicitPathQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final ExplicitPath data; + @override ExplicitPathDocumentReference get reference { return ExplicitPathDocumentReference(snapshot.reference); } - - @override - final ExplicitPath data; } /// A collection reference object can be used for adding documents, @@ -10260,33 +10964,18 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< @override Stream snapshots() { - return reference.snapshots().map((snapshot) { - return ExplicitSubPathDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.snapshots().map(ExplicitSubPathDocumentSnapshot._); } @override Future get([GetOptions? options]) { - return reference.get(options).then((snapshot) { - return ExplicitSubPathDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return reference.get(options).then(ExplicitSubPathDocumentSnapshot._); } @override Future transactionGet( Transaction transaction) { - return transaction.get(reference).then((snapshot) { - return ExplicitSubPathDocumentSnapshot._( - snapshot, - snapshot.data(), - ); - }); + return transaction.get(reference).then(ExplicitSubPathDocumentSnapshot._); } Future update({ @@ -10334,27 +11023,6 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< int get hashCode => Object.hash(runtimeType, parent, id); } -class ExplicitSubPathDocumentSnapshot - extends FirestoreDocumentSnapshot { - ExplicitSubPathDocumentSnapshot._( - this.snapshot, - this.data, - ); - - @override - final DocumentSnapshot snapshot; - - @override - ExplicitSubPathDocumentReference get reference { - return ExplicitSubPathDocumentReference( - snapshot.reference, - ); - } - - @override - final ExplicitSubPath? data; -} - abstract class ExplicitSubPathQuery implements QueryReference { @override @@ -10490,37 +11158,18 @@ class _$ExplicitSubPathQuery final CollectionReference _collection; - ExplicitSubPathQuerySnapshot _decodeSnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map((e) { - return ExplicitSubPathQueryDocumentSnapshot._(e, e.data()); - }).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return FirestoreDocumentChange( - type: change.type, - oldIndex: change.oldIndex, - newIndex: change.newIndex, - doc: ExplicitSubPathDocumentSnapshot._(change.doc, change.doc.data()), - ); - }).toList(); - - return ExplicitSubPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - @override Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(_decodeSnapshot); + return reference + .snapshots() + .map(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); } @override Future get([GetOptions? options]) { - return reference.get(options).then(_decodeSnapshot); + return reference + .get(options) + .then(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); } @override @@ -10860,6 +11509,24 @@ class _$ExplicitSubPathQuery int get hashCode => Object.hash(runtimeType, reference); } +class ExplicitSubPathDocumentSnapshot + extends FirestoreDocumentSnapshot { + ExplicitSubPathDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ExplicitSubPathDocumentReference get reference { + return ExplicitSubPathDocumentReference( + snapshot.reference, + ); + } + + @override + final ExplicitSubPath? data; +} + class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< ExplicitSubPath, ExplicitSubPathQueryDocumentSnapshot> { ExplicitSubPathQuerySnapshot._( @@ -10868,6 +11535,39 @@ class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< this.docChanges, ); + factory ExplicitSubPathQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = + snapshot.docs.map(ExplicitSubPathQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + ExplicitSubPathDocumentSnapshot._, + ); + }).toList(); + + return ExplicitSubPathQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ExplicitSubPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + final QuerySnapshot snapshot; @override @@ -10881,18 +11581,19 @@ class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< class ExplicitSubPathQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ExplicitSubPathDocumentSnapshot { - ExplicitSubPathQueryDocumentSnapshot._(this.snapshot, this.data); + ExplicitSubPathQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; + @override + final ExplicitSubPath data; + @override ExplicitSubPathDocumentReference get reference { return ExplicitSubPathDocumentReference(snapshot.reference); } - - @override - final ExplicitSubPath data; } // ************************************************************************** @@ -10910,6 +11611,20 @@ void _$assertMinValidation(MinValidation instance) { // JsonSerializableGenerator // ************************************************************************** +IgnoredGetter _$IgnoredGetterFromJson(Map json) => + IgnoredGetter( + json['value'] as int, + ); + +const _$IgnoredGetterFieldMap = { + 'value': 'value', +}; + +Map _$IgnoredGetterToJson(IgnoredGetter instance) => + { + 'value': instance.value, + }; + Model _$ModelFromJson(Map json) => Model( json['value'] as String, ); diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart index 0208fdc1de5f..13125767926e 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -385,6 +385,9 @@ extension on ClassElement { final uniqueFields = {}; for (final field in fields) { + if (field.getter != null && !field.getter!.isSynthetic) { + continue; + } uniqueFields[field.name] ??= field; } @@ -392,6 +395,9 @@ extension on ClassElement { if (supertype.isDartCoreObject) continue; for (final field in supertype.element2.fields) { + if (field.getter != null && !field.getter!.isSynthetic) { + continue; + } uniqueFields[field.name] ??= field; } } diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/test/query_reference_test.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/test/query_reference_test.dart index 28faf5698573..49fd3b03702a 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/test/query_reference_test.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/test/query_reference_test.dart @@ -9,6 +9,29 @@ Future main() async { ); group('query', () { + test('does not generate utilities for getters', () { + expect( + library.withCode( + ''' +import 'simple.dart'; + +void main() { + ignoredGetterRef.whereValue(); + // expect-error: UNDEFINED_METHOD + ignoredGetterRef.whereCount(); + // expect-error: UNDEFINED_METHOD + ignoredGetterRef.whereCount2(); + // expect-error: UNDEFINED_METHOD + ignoredGetterRef.whereCount3(); + // expect-error: UNDEFINED_METHOD + ignoredGetterRef.whereHashCode(); +} +''', + ), + compiles, + ); + }); + test('property type offset queries from value', () { expect( library.withCode(