Skip to content

Commit

Permalink
refactor(plugin_platform_interface): add verify to QueryPlatform
Browse files Browse the repository at this point in the history
…and change internal `verifyToken` API to `verify` (#9711)

* fix: change verifyToken to verify

* fix: remove condition for verify

* fix: fix verify

* fix: fix verify

* fix: bump plugin_platform_inteface version
  • Loading branch information
Lyokone committed Oct 24, 2022
1 parent 9ad97c8 commit c99a842
Show file tree
Hide file tree
Showing 105 changed files with 171 additions and 158 deletions.
Expand Up @@ -32,7 +32,7 @@ abstract class DocumentChange<T extends Object?> {

class _JsonDocumentChange implements DocumentChange<Map<String, dynamic>> {
_JsonDocumentChange(this._firestore, this._delegate) {
DocumentChangePlatform.verifyExtends(_delegate);
DocumentChangePlatform.verify(_delegate);
}

final DocumentChangePlatform _delegate;
Expand Down
Expand Up @@ -94,7 +94,7 @@ abstract class DocumentReference<T extends Object?> {
class _JsonDocumentReference
implements DocumentReference<Map<String, dynamic>> {
_JsonDocumentReference(this.firestore, this._delegate) {
DocumentReferencePlatform.verifyExtends(_delegate);
DocumentReferencePlatform.verify(_delegate);
}

@override
Expand Down
Expand Up @@ -59,7 +59,7 @@ abstract class DocumentSnapshot<T extends Object?> {

class _JsonDocumentSnapshot implements DocumentSnapshot<Map<String, dynamic>> {
_JsonDocumentSnapshot(this._firestore, this._delegate) {
DocumentSnapshotPlatform.verifyExtends(_delegate);
DocumentSnapshotPlatform.verify(_delegate);
}

final FirebaseFirestore _firestore;
Expand Down
Expand Up @@ -6,7 +6,7 @@ part of cloud_firestore;

class LoadBundleTask {
LoadBundleTask._(this._delegate) {
LoadBundleTaskPlatform.verifyExtends(_delegate);
LoadBundleTaskPlatform.verify(_delegate);
}

final LoadBundleTaskPlatform _delegate;
Expand Down
Expand Up @@ -7,7 +7,7 @@ part of cloud_firestore;
/// A [LoadBundleTaskSnapshot] is returned as the result or on-going process of a [LoadBundleTask].
class LoadBundleTaskSnapshot {
LoadBundleTaskSnapshot._(this._delegate) {
LoadBundleTaskSnapshotPlatform.verifyExtends(_delegate);
LoadBundleTaskSnapshotPlatform.verify(_delegate);
}
LoadBundleTaskSnapshotPlatform _delegate;

Expand Down
Expand Up @@ -198,7 +198,7 @@ class _JsonQuery implements Query<Map<String, dynamic>> {
this.firestore,
this._delegate,
) {
QueryPlatform.verifyExtends(_delegate);
QueryPlatform.verify(_delegate);
}

@override
Expand Down
Expand Up @@ -25,7 +25,7 @@ abstract class QuerySnapshot<T extends Object?> {
/// It can contain zero or more [DocumentSnapshot] objects.
class _JsonQuerySnapshot implements QuerySnapshot<Map<String, dynamic>> {
_JsonQuerySnapshot(this._firestore, this._delegate) {
QuerySnapshotPlatform.verifyExtends(_delegate);
QuerySnapshotPlatform.verify(_delegate);
}

final FirebaseFirestore _firestore;
Expand Down
Expand Up @@ -14,7 +14,7 @@ class Transaction {
final TransactionPlatform _delegate;

Transaction._(this._firestore, this._delegate) {
TransactionPlatform.verifyExtends(_delegate);
TransactionPlatform.verify(_delegate);
}

/// Reads the document referenced by the provided [DocumentReference].
Expand Down
Expand Up @@ -12,7 +12,7 @@ part of cloud_firestore;
/// nor can it be committed again.
class WriteBatch {
WriteBatch._(this._firestore, this._delegate) {
WriteBatchPlatform.verifyExtends(_delegate);
WriteBatchPlatform.verify(_delegate);
}

final FirebaseFirestore _firestore;
Expand Down
Expand Up @@ -3,9 +3,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

/// An enumeration of document change types.
enum DocumentChangeType {
Expand Down Expand Up @@ -42,8 +41,8 @@ class DocumentChangePlatform extends PlatformInterface {
/// This is used by the app-facing [DocumentChange] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(DocumentChangePlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(DocumentChangePlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// The type of change that occurred (added, modified, or removed).
Expand Down
Expand Up @@ -31,8 +31,8 @@ abstract class DocumentReferencePlatform extends PlatformInterface {
/// This is used by the app-facing [DocumentReference] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(DocumentReferencePlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(DocumentReferencePlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// The Firestore instance associated with this document reference
Expand Down
Expand Up @@ -26,8 +26,8 @@ class DocumentSnapshotPlatform extends PlatformInterface {
/// This is used by the app-facing [DocumentSnapshot] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(DocumentSnapshotPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(DocumentSnapshotPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// The [FirebaseFirestorePlatform] used to produce this [DocumentSnapshotPlatform].
Expand Down
Expand Up @@ -3,10 +3,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_field_value_factory.dart';
import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_field_value_factory.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

/// An interface for a factory that is used to build a [FieldValuePlatform] according to
/// Platform (web or mobile)
Expand All @@ -24,7 +23,7 @@ abstract class FieldValueFactoryPlatform extends PlatformInterface {
/// Sets the default instance of [FieldValueFactoryPlatform] which is used to build
/// [FieldValuePlatform] items
static set instance(FieldValueFactoryPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
PlatformInterface.verify(instance, _token);
_instance = instance;
}

Expand All @@ -36,8 +35,8 @@ abstract class FieldValueFactoryPlatform extends PlatformInterface {
/// This is used by the app-facing [FieldValueFactory] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(FieldValueFactoryPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(FieldValueFactoryPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// Returns a special value that tells the server to union the given elements
Expand Down
Expand Up @@ -57,7 +57,7 @@ abstract class FirebaseFirestorePlatform extends PlatformInterface {

/// Sets the [FirebaseFirestorePlatform.instance]
static set instance(FirebaseFirestorePlatform instance) {
PlatformInterface.verifyToken(instance, _token);
PlatformInterface.verify(instance, _token);
_instance = instance;
}

Expand Down
Expand Up @@ -18,8 +18,8 @@ abstract class LoadBundleTaskPlatform<T> extends PlatformInterface {
/// This is used by the app-facing [LoadBundleTask] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(LoadBundleTaskPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(LoadBundleTaskPlatform instance) {
PlatformInterface.verify(instance, _token);
}

Stream<T> get stream;
Expand Down
Expand Up @@ -4,6 +4,7 @@
// found in the LICENSE file.

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import '../../cloud_firestore_platform_interface.dart';

/// The interface a load bundle task snapshot must extend.
Expand All @@ -24,8 +25,8 @@ class LoadBundleTaskSnapshotPlatform extends PlatformInterface {
/// This is used by the app-facing [LoadBundleTaskSnapshot] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(LoadBundleTaskSnapshotPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(LoadBundleTaskSnapshotPlatform instance) {
PlatformInterface.verify(instance, _token);
}

final LoadBundleTaskState taskState;
Expand Down
Expand Up @@ -5,9 +5,9 @@

import 'dart:async';

import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:meta/meta.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';

Map<String, dynamic> _initialParameters = Map<String, dynamic>.unmodifiable({
'where': List<List<dynamic>>.unmodifiable([]),
Expand Down Expand Up @@ -36,10 +36,8 @@ abstract class QueryPlatform extends PlatformInterface {
/// This is used by the app-facing [Query] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(QueryPlatform instance) {
if (instance is! CollectionReferencePlatform) {
PlatformInterface.verifyToken(instance, _token);
}
static void verify(QueryPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// The [FirebaseFirestorePlatform] interface for this current query.
Expand Down
Expand Up @@ -3,9 +3,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

/// A interface that contains zero or more [DocumentSnapshotPlatform] objects
/// representing the results of a query.
Expand All @@ -28,8 +27,8 @@ class QuerySnapshotPlatform extends PlatformInterface {
/// This is used by the app-facing [QuerySnapshot] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(QuerySnapshotPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(QuerySnapshotPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// Gets a list of all the documents included in this [QuerySnapshotPlatform]
Expand Down
Expand Up @@ -26,8 +26,8 @@ abstract class TransactionPlatform extends PlatformInterface {
/// This is used by the app-facing [Transaction] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(TransactionPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(TransactionPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// Returns all transaction commands for the current instance.
Expand Down
Expand Up @@ -27,8 +27,8 @@ abstract class WriteBatchPlatform extends PlatformInterface {
/// This is used by the app-facing [WriteBatch] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(WriteBatchPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(WriteBatchPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// Commits all of the writes in this write batch as a single atomic unit.
Expand Down
Expand Up @@ -15,7 +15,7 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.3.0
plugin_platform_interface: ^2.0.0
plugin_platform_interface: ^2.1.3


dev_dependencies:
Expand Down
Expand Up @@ -44,9 +44,9 @@ void main() {
expect(query, isInstanceOf<QueryPlatform>());
});

test('verifyExtends()', () {
test('verify()', () {
final query = TestQuery._();
QueryPlatform.verifyExtends(query);
QueryPlatform.verify(query);
expect(query, isInstanceOf<QueryPlatform>());
});

Expand Down
Expand Up @@ -34,9 +34,9 @@ void main() {
expect(transaction, isInstanceOf<TransactionPlatform>());
});

test('verifyExtends()', () {
test('verify()', () {
final transaction = TestTransaction._();
TransactionPlatform.verifyExtends(transaction);
TransactionPlatform.verify(transaction);
expect(transaction, isInstanceOf<TransactionPlatform>());
});

Expand Down
Expand Up @@ -34,9 +34,9 @@ void main() {
expect(batch, isInstanceOf<WriteBatchPlatform>());
});

test('verifyExtends()', () {
test('verify()', () {
final batch = TestWriteBatch._();
WriteBatchPlatform.verifyExtends(batch);
WriteBatchPlatform.verify(batch);
expect(batch, isInstanceOf<WriteBatchPlatform>());
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_functions/cloud_functions/pubspec.yaml
Expand Up @@ -24,7 +24,7 @@ dev_dependencies:
sdk: flutter
flutter_test:
sdk: flutter
plugin_platform_interface: ^2.0.0
plugin_platform_interface: ^2.1.3
test: any

flutter:
Expand Down
Expand Up @@ -49,7 +49,7 @@ abstract class FirebaseFunctionsPlatform extends PlatformInterface {

/// Sets the [FirebaseFunctionsPlatform.instance]
static set instance(FirebaseFunctionsPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
PlatformInterface.verify(instance, _token);
_instance = instance;
}

Expand Down
Expand Up @@ -6,6 +6,7 @@
import 'dart:async';

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import '../../cloud_functions_platform_interface.dart';

/// Interface for [HttpsCallable] implementations.
Expand All @@ -24,8 +25,8 @@ abstract class HttpsCallablePlatform extends PlatformInterface {
/// This is used by the app-facing [HttpsCallable] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verifyExtends(HttpsCallablePlatform instance) {
PlatformInterface.verifyToken(instance, _token);
static void verify(HttpsCallablePlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// The [FirebaseFunctionsPlatform] instance.
Expand Down
Expand Up @@ -16,7 +16,7 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.3.0
plugin_platform_interface: ^2.0.0
plugin_platform_interface: ^2.1.3

dev_dependencies:
firebase_core_platform_interface: ^4.5.1
Expand Down
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

import 'dart:async';

import 'package:firebase_core/firebase_core.dart';
import 'package:meta/meta.dart' show protected;
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
Expand Down Expand Up @@ -53,7 +54,7 @@ abstract class FirebaseAnalyticsPlatform extends PlatformInterface {

/// Sets the [FirebaseAnalyticsPlatform.instance]
static set instance(FirebaseAnalyticsPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
PlatformInterface.verify(instance, _token);
_instance = instance;
}

Expand Down
Expand Up @@ -14,7 +14,7 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.3.0
plugin_platform_interface: ^2.0.0
plugin_platform_interface: ^2.1.3

dev_dependencies:
firebase_core_platform_interface: ^4.5.1
Expand Down
Expand Up @@ -24,7 +24,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.0
plugin_platform_interface: ^2.0.0
plugin_platform_interface: ^2.1.3
test: any

flutter:
Expand Down
Expand Up @@ -49,7 +49,7 @@ abstract class FirebaseAppCheckPlatform extends PlatformInterface {

/// Sets the [FirebaseAppCheckPlatform.instance]
static set instance(FirebaseAppCheckPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
PlatformInterface.verify(instance, _token);
_instance = instance;
}

Expand Down

0 comments on commit c99a842

Please sign in to comment.