diff --git a/packages/amplify_core/lib/amplify_core.dart b/packages/amplify_core/lib/amplify_core.dart index 9529bee8b9..d3332772e0 100644 --- a/packages/amplify_core/lib/amplify_core.dart +++ b/packages/amplify_core/lib/amplify_core.dart @@ -19,34 +19,13 @@ library amplify_core; export 'src/types/exception/amplify_already_configured_exception.dart'; export 'src/types/exception/amplify_exception.dart'; export 'src/types/exception/amplify_exception_messages.dart'; -export 'src/types/exception/codegen_exception.dart'; /// Hub export 'src/types/hub/hub_channel.dart'; export 'src/types/hub/hub_event.dart'; export 'src/types/hub/hub_event_payload.dart'; - -/// Model-based types used in datastore and API -export 'src/types/models/auth_rule.dart'; -export 'src/types/models/model.dart'; -export 'src/types/models/model_association.dart'; -export 'src/types/models/model_field.dart'; -export 'src/types/models/model_field_definition.dart'; -export 'src/types/models/model_field_type.dart'; -export 'src/types/models/model_provider.dart'; -export 'src/types/models/model_schema.dart'; -export 'src/types/models/model_schema_definition.dart'; -export 'src/types/query/query_field.dart'; -export 'src/types/temporal/datetime_parse.dart'; -export 'src/types/temporal/temporal_date.dart'; -export 'src/types/temporal/temporal_datetime.dart'; -export 'src/types/temporal/temporal_time.dart'; -export 'src/types/temporal/temporal_timestamp.dart'; +export 'src/types/plugin/amplify_plugin_interface.dart'; // Util -export 'src/util/parsers.dart'; export 'src/util/print.dart'; export 'src/util/uuid.dart'; - -// ignore: directives_ordering -export 'src/types/plugin/amplify_plugin_interface.dart'; diff --git a/packages/amplify_core/lib/src/types/exception/amplify_exception_messages.dart b/packages/amplify_core/lib/src/types/exception/amplify_exception_messages.dart index 3919c36a3e..cc6d573099 100644 --- a/packages/amplify_core/lib/src/types/exception/amplify_exception_messages.dart +++ b/packages/amplify_core/lib/src/types/exception/amplify_exception_messages.dart @@ -37,14 +37,4 @@ class AmplifyExceptionMessages { static const nullReturnedFromMethodChannel = 'The value returned from the MethodChannel is null'; - - static const codeGenRequiredFieldForceCastExceptionMessage = - // ignore: missing_whitespace_between_adjacent_strings - 'The field you are accessing is not nullable but has a null value.' - 'It was marked as required (!) in your schema.graphql but the containing model class was initialized without setting its value.'; - - static const codeGenRequiredFieldForceCastRecoverySuggestion = - // ignore: missing_whitespace_between_adjacent_strings - 'Please validate that the containing model class was initialized properly with all requried fields being initialized.' - 'This can happen when a nested model is returned but only its id field has been set'; } diff --git a/packages/amplify_core/lib/src/types/exception/codegen_exception.dart b/packages/amplify_core/lib/src/types/exception/codegen_exception.dart deleted file mode 100644 index 1b04f1774b..0000000000 --- a/packages/amplify_core/lib/src/types/exception/codegen_exception.dart +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -import 'amplify_exception.dart'; - -/// Exception thrown from codegen models -class AmplifyCodeGenModelException extends AmplifyException { - /// Named constructor - const AmplifyCodeGenModelException(String message, - {String? recoverySuggestion, String? underlyingException}) - : super(message, - recoverySuggestion: recoverySuggestion, - underlyingException: underlyingException); - - /// Constructor for down casting an AmplifyException to this exception - AmplifyCodeGenModelException._private(AmplifyException exception) - : super(exception.message, - recoverySuggestion: exception.recoverySuggestion, - underlyingException: exception.underlyingException); - - /// Instantiates and return a new `AmplifyCodeGenModelException` from the - /// serialized exception data - static AmplifyCodeGenModelException fromMap( - Map serializedException) { - return AmplifyCodeGenModelException._private( - AmplifyException.fromMap(serializedException)); - } -} diff --git a/packages/amplify_core/lib/src/util/json.dart b/packages/amplify_core/lib/src/util/json.dart new file mode 100644 index 0000000000..6b4b7eb958 --- /dev/null +++ b/packages/amplify_core/lib/src/util/json.dart @@ -0,0 +1,28 @@ +/* + * Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import 'dart:convert'; +import 'dart:io'; + +dynamic getJsonFromFile(String path) async { + path = 'resources/' + path; + String jsonString = ''; + try { + jsonString = await File(path).readAsString(); + } catch (e) { + jsonString = await File('test/' + path).readAsString(); + } + return jsonDecode(jsonString); +} diff --git a/packages/amplify_core/pubspec.yaml b/packages/amplify_core/pubspec.yaml index 0257cc56c1..0ec4552e3b 100644 --- a/packages/amplify_core/pubspec.yaml +++ b/packages/amplify_core/pubspec.yaml @@ -9,10 +9,9 @@ environment: dependencies: plugin_platform_interface: ^2.0.0 + meta: ^1.3.0 flutter: sdk: flutter - date_time_format: ^2.0.1 - meta: ^1.3.0 uuid: ^3.0.1 dev_dependencies: diff --git a/packages/amplify_datastore_plugin_interface/lib/amplify_datastore_plugin_interface.dart b/packages/amplify_datastore_plugin_interface/lib/amplify_datastore_plugin_interface.dart index d94bf90a34..bd21089028 100644 --- a/packages/amplify_datastore_plugin_interface/lib/amplify_datastore_plugin_interface.dart +++ b/packages/amplify_datastore_plugin_interface/lib/amplify_datastore_plugin_interface.dart @@ -17,13 +17,29 @@ library amplify_datastore_plugin_interface; import 'dart:async'; +import 'package:amplify_datastore_plugin_interface/src/types/models/model_provider.dart'; import 'package:amplify_core/amplify_core.dart'; import 'package:meta/meta.dart'; +import 'src/types/models/model.dart'; import 'src/types/models/observe_query_throttle_options.dart'; import 'src/types/models/query_snapshot.dart'; import 'src/types/models/subscription_event.dart'; import 'src/types/sync/DataStoreSyncExpression.dart'; +import 'src/types/query/query_field.dart'; + +export 'src/types/models/auth_rule.dart'; +export 'src/types/models/model.dart'; +export 'src/types/models/model_field.dart'; +export 'src/types/models/model_field_definition.dart'; +export 'src/types/models/model_field_type.dart'; +export 'src/types/models/model_provider.dart'; +export 'src/types/models/model_schema.dart'; +export 'src/types/models/model_schema_definition.dart'; +export 'src/types/models/uuid.dart'; +export 'src/types/query/query_field.dart'; +export 'src/types/temporal/datetime_parse.dart'; +export 'src/types/utils/parsers.dart'; export 'src/publicTypes.dart'; diff --git a/packages/amplify_datastore_plugin_interface/lib/src/publicTypes.dart b/packages/amplify_datastore_plugin_interface/lib/src/publicTypes.dart index 9a9cfc505d..642935ac86 100644 --- a/packages/amplify_datastore_plugin_interface/lib/src/publicTypes.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/publicTypes.dart @@ -1,24 +1,11 @@ -export 'package:amplify_core/src/types/models/auth_rule.dart'; -export 'package:amplify_core/src/types/models/model.dart'; -export 'package:amplify_core/src/types/models/model_field.dart'; -export 'package:amplify_core/src/types/models/model_field_definition.dart'; -export 'package:amplify_core/src/types/models/model_field_type.dart'; -export 'package:amplify_core/src/types/models/model_provider.dart'; -export 'package:amplify_core/src/types/models/model_schema.dart'; -export 'package:amplify_core/src/types/models/model_schema_definition.dart'; -export 'package:amplify_core/src/types/query/query_field.dart'; -export 'package:amplify_core/src/types/query/query_field.dart'; -export 'package:amplify_core/src/types/temporal/datetime_parse.dart'; -export 'package:amplify_core/src/types/temporal/temporal_date.dart'; -export 'package:amplify_core/src/types/temporal/temporal_datetime.dart'; -export 'package:amplify_core/src/types/temporal/temporal_time.dart'; -export 'package:amplify_core/src/types/temporal/temporal_timestamp.dart'; -export 'package:amplify_core/src/util/parsers.dart'; -export 'package:amplify_core/src/util/uuid.dart'; - export 'types/exception/DataStoreException.dart'; export 'types/exception/DataStoreExceptionMessages.dart'; -export 'types/models/observe_query_throttle_options.dart'; -export 'types/models/query_snapshot.dart'; export 'types/models/subscription_event.dart'; +export 'types/models/query_snapshot.dart'; +export 'types/models/observe_query_throttle_options.dart'; export 'types/sync/DataStoreSyncExpression.dart'; +export 'types/temporal/temporal_date.dart'; +export 'types/temporal/temporal_time.dart'; +export 'types/temporal/temporal_datetime.dart'; +export 'types/temporal/temporal_timestamp.dart'; +export 'types/query/query_field.dart'; diff --git a/packages/amplify_core/lib/src/types/models/auth_rule.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/auth_rule.dart similarity index 95% rename from packages/amplify_core/lib/src/types/models/auth_rule.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/auth_rule.dart index a510047bf9..fc4fb010f4 100644 --- a/packages/amplify_core/lib/src/types/models/auth_rule.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/auth_rule.dart @@ -67,7 +67,7 @@ class AuthRule { } Map toMap() { - final map = { + Map map = { 'authStrategy': describeEnum(authStrategy), 'ownerField': ownerField, 'identityClaim': identityClaim, @@ -77,8 +77,7 @@ class AuthRule { 'provider': provider != null ? describeEnum(provider!) : null, 'operations': operations?.map((x) => describeEnum(x)).toList(), }; - return Map.from(map) - ..removeWhere((k, dynamic v) => v == null); + return Map.from(map)..removeWhere((k, v) => v == null); } factory AuthRule.fromMap(Map map) { @@ -91,7 +90,7 @@ class AuthRule { groupsField: map['groupsField'], provider: map['provider'], operations: List.from( - map['operations']?.map((dynamic x) => ModelOperation.values[x]))); + map['operations']?.map((x) => ModelOperation.values[x]))); } String toJson() => json.encode(toMap()); diff --git a/packages/amplify_core/lib/src/types/models/model.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model.dart similarity index 100% rename from packages/amplify_core/lib/src/types/models/model.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model.dart diff --git a/packages/amplify_core/lib/src/types/models/model_association.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_association.dart similarity index 93% rename from packages/amplify_core/lib/src/types/models/model_association.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_association.dart index d8c22926ab..876f2c2df8 100644 --- a/packages/amplify_core/lib/src/types/models/model_association.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_association.dart @@ -46,14 +46,13 @@ class ModelAssociation { } Map toMap() { - final map = { + Map map = { 'associationType': describeEnum(associationType), 'targetName': targetName, 'associatedName': associatedName, 'associatedType': associatedType, }; - return Map.from(map) - ..removeWhere((k, dynamic v) => v == null); + return Map.from(map)..removeWhere((k, v) => v == null); } factory ModelAssociation.fromMap(Map map) { diff --git a/packages/amplify_core/lib/src/types/models/model_field.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field.dart similarity index 91% rename from packages/amplify_core/lib/src/types/models/model_field.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field.dart index 28dab7a510..6156ef6d79 100644 --- a/packages/amplify_core/lib/src/types/models/model_field.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field.dart @@ -72,7 +72,7 @@ class ModelField { } Map toMap() { - final map = { + Map map = { 'name': name, 'type': type.toMap(), 'isRequired': isRequired, @@ -81,8 +81,7 @@ class ModelField { 'association': association?.toMap(), 'authRules': authRules?.map((x) => x.toMap()).toList(), }; - return Map.from(map) - ..removeWhere((k, dynamic v) => v == null); + return Map.from(map)..removeWhere((k, v) => v == null); } factory ModelField.fromMap(Map map) { @@ -96,7 +95,7 @@ class ModelField { map['association'] ?? ModelAssociation.fromMap(map['association']), authRules: map['authRules'] ?? List.from( - map['authRules']?.map((dynamic x) => AuthRule.fromMap(x))), + map['authRules']?.map((x) => AuthRule.fromMap(x))), ); } diff --git a/packages/amplify_core/lib/src/types/models/model_field_definition.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field_definition.dart similarity index 98% rename from packages/amplify_core/lib/src/types/models/model_field_definition.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field_definition.dart index 464b9fe861..27cd71b3a1 100644 --- a/packages/amplify_core/lib/src/types/models/model_field_definition.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field_definition.dart @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart'; import 'auth_rule.dart'; import 'model_association.dart'; @@ -174,7 +174,7 @@ class ModelFieldDefinition { associatedType: associatedType)); } - ModelField build() { + build() { return ModelField( name: name, type: type, diff --git a/packages/amplify_core/lib/src/types/models/model_field_type.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field_type.dart similarity index 98% rename from packages/amplify_core/lib/src/types/models/model_field_type.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field_type.dart index 6dda19a85d..fba16ef996 100644 --- a/packages/amplify_core/lib/src/types/models/model_field_type.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_field_type.dart @@ -26,7 +26,7 @@ class ModelFieldType { {this.ofModelName, this.ofCustomTypeName}); Map toMap() { - return { + return { 'fieldType': describeEnum(fieldType), if (ofModelName != null) 'ofModelName': ofModelName, if (ofCustomTypeName != null) 'ofCustomTypeName': ofCustomTypeName, diff --git a/packages/amplify_core/lib/src/types/models/model_provider.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_provider.dart similarity index 92% rename from packages/amplify_core/lib/src/types/models/model_provider.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_provider.dart index 674896f043..13fe2c08a2 100644 --- a/packages/amplify_core/lib/src/types/models/model_provider.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_provider.dart @@ -12,7 +12,8 @@ * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import 'model.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/models/model.dart'; + import 'model_schema.dart'; abstract class ModelProviderInterface { diff --git a/packages/amplify_core/lib/src/types/models/model_schema.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_schema.dart similarity index 90% rename from packages/amplify_core/lib/src/types/models/model_schema.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_schema.dart index bcd10ef107..ee9d82487c 100644 --- a/packages/amplify_core/lib/src/types/models/model_schema.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_schema.dart @@ -48,14 +48,13 @@ class ModelSchema { } Map toMap() { - final map = { + Map map = { 'name': name, 'pluralName': pluralName, 'authRules': authRules?.map((x) => x.toMap()).toList(), 'fields': fields?.map((key, value) => MapEntry('$key', value.toMap())), }; - return Map.from(map) - ..removeWhere((k, dynamic v) => v == null); + return Map.from(map)..removeWhere((k, v) => v == null); } factory ModelSchema.fromMap(Map map) { @@ -63,7 +62,7 @@ class ModelSchema { name: map['name'], pluralName: map['pluralName'], authRules: List.from( - map['authRules']?.map((dynamic x) => AuthRule.fromMap(x))), + map['authRules']?.map((x) => AuthRule.fromMap(x))), fields: Map.from(map['fields']), ); } diff --git a/packages/amplify_core/lib/src/types/models/model_schema_definition.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/model_schema_definition.dart similarity index 100% rename from packages/amplify_core/lib/src/types/models/model_schema_definition.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/models/model_schema_definition.dart diff --git a/packages/amplify_datastore_plugin_interface/lib/src/types/models/query_snapshot.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/query_snapshot.dart index da626f587a..f1f7c75ce1 100644 --- a/packages/amplify_datastore_plugin_interface/lib/src/types/models/query_snapshot.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/query_snapshot.dart @@ -15,9 +15,11 @@ library model; -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/models/sorted_list.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/query/query_field.dart'; + +import 'model.dart'; -import 'sorted_list.dart'; import 'subscription_event.dart'; /// {@template query_snapshot} diff --git a/packages/amplify_datastore_plugin_interface/lib/src/types/models/subscription_event.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/subscription_event.dart index 392f7875f3..18f2d2c592 100644 --- a/packages/amplify_datastore_plugin_interface/lib/src/types/models/subscription_event.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/subscription_event.dart @@ -15,9 +15,10 @@ library model; -import 'package:amplify_core/amplify_core.dart'; import 'package:flutter/foundation.dart'; +import 'model.dart'; + /// {@template subscription_event} /// An event containing the details of mutations that have occurred on the backend /// {@endtemplate} diff --git a/packages/amplify_datastore_plugin_interface/lib/src/types/models/uuid.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/models/uuid.dart new file mode 100644 index 0000000000..c5e6123a03 --- /dev/null +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/models/uuid.dart @@ -0,0 +1,24 @@ +/* + * Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import 'package:uuid/uuid.dart'; + +class UUID { + static final _internal = Uuid(); + + static String getUUID() { + return _internal.v4(); + } +} diff --git a/packages/amplify_core/lib/src/types/query/query_field.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_field.dart similarity index 94% rename from packages/amplify_core/lib/src/types/query/query_field.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/query/query_field.dart index 348808513e..0c3bc1e7fc 100644 --- a/packages/amplify_core/lib/src/types/query/query_field.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_field.dart @@ -15,11 +15,10 @@ library query_field; -import 'package:amplify_core/amplify_core.dart'; - -import '../../util/parsers.dart'; -import '../models/model_field_type.dart'; +import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/models/model_field_type.dart'; import '../temporal/datetime_parse.dart'; +import '../utils/parsers.dart'; part 'query_field_operators.dart'; part 'query_pagination.dart'; diff --git a/packages/amplify_core/lib/src/types/query/query_field_operators.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_field_operators.dart similarity index 99% rename from packages/amplify_core/lib/src/types/query/query_field_operators.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/query/query_field_operators.dart index 02c84fb17d..645181b672 100644 --- a/packages/amplify_core/lib/src/types/query/query_field_operators.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_field_operators.dart @@ -13,8 +13,6 @@ * permissions and limitations under the License. */ -// ignore_for_file: implicit_dynamic_type - part of 'query_field.dart'; enum QueryFieldOperatorType { diff --git a/packages/amplify_core/lib/src/types/query/query_pagination.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_pagination.dart similarity index 100% rename from packages/amplify_core/lib/src/types/query/query_pagination.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/query/query_pagination.dart diff --git a/packages/amplify_core/lib/src/types/query/query_predicate.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_predicate.dart similarity index 95% rename from packages/amplify_core/lib/src/types/query/query_predicate.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/query/query_predicate.dart index 22f0855791..5c1bf7bee9 100644 --- a/packages/amplify_core/lib/src/types/query/query_predicate.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_predicate.dart @@ -55,7 +55,7 @@ class QueryPredicateOperation extends QueryPredicate { @override bool evaluate(Model model) { - dynamic value = model.toJson()[field]; + var value = model.toJson()[field]; return queryFieldOperator.evaluate(value); } diff --git a/packages/amplify_core/lib/src/types/query/query_sort.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_sort.dart similarity index 89% rename from packages/amplify_core/lib/src/types/query/query_sort.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/query/query_sort.dart index e1bd4bab56..c507e9df3f 100644 --- a/packages/amplify_core/lib/src/types/query/query_sort.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/query/query_sort.dart @@ -35,8 +35,8 @@ class QuerySortBy { const QuerySortBy({required this.order, required this.field}); int compare(T a, T b) { - dynamic valueA = a.toJson()[field]; - dynamic valueB = b.toJson()[field]; + var valueA = a.toJson()[field]; + var valueB = b.toJson()[field]; int orderMultiplier = order == QuerySortOrder.ascending ? 1 : -1; if (valueA == null || valueB == null) { return orderMultiplier * _compareNull(valueA, valueB); @@ -45,7 +45,8 @@ class QuerySortBy { } else if (valueA is Comparable && valueB is Comparable) { return orderMultiplier * valueA.compareTo(valueB); } - throw AmplifyException('A non-comparable field was used as a QuerySortBy'); + throw DataStoreException( + 'A non-comparable field was used as a QuerySortBy'); } int _compareBool(bool a, bool b) { diff --git a/packages/amplify_datastore_plugin_interface/lib/src/types/sync/DataStoreSyncExpression.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/sync/DataStoreSyncExpression.dart index eb48950587..99ede13fbf 100644 --- a/packages/amplify_datastore_plugin_interface/lib/src/types/sync/DataStoreSyncExpression.dart +++ b/packages/amplify_datastore_plugin_interface/lib/src/types/sync/DataStoreSyncExpression.dart @@ -13,8 +13,9 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/models/model.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/query/query_field.dart'; /// Sync expression to configure DataStore plugin with. These expressions /// include query predicates which specify filters for selectively persisting a diff --git a/packages/amplify_core/lib/src/types/temporal/datetime_parse.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/temporal/datetime_parse.dart similarity index 100% rename from packages/amplify_core/lib/src/types/temporal/datetime_parse.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/temporal/datetime_parse.dart diff --git a/packages/amplify_core/lib/src/types/temporal/temporal.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal.dart similarity index 100% rename from packages/amplify_core/lib/src/types/temporal/temporal.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal.dart diff --git a/packages/amplify_core/lib/src/types/temporal/temporal_date.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_date.dart similarity index 100% rename from packages/amplify_core/lib/src/types/temporal/temporal_date.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_date.dart diff --git a/packages/amplify_core/lib/src/types/temporal/temporal_datetime.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_datetime.dart similarity index 100% rename from packages/amplify_core/lib/src/types/temporal/temporal_datetime.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_datetime.dart diff --git a/packages/amplify_core/lib/src/types/temporal/temporal_time.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_time.dart similarity index 100% rename from packages/amplify_core/lib/src/types/temporal/temporal_time.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_time.dart diff --git a/packages/amplify_core/lib/src/types/temporal/temporal_timestamp.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_timestamp.dart similarity index 100% rename from packages/amplify_core/lib/src/types/temporal/temporal_timestamp.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/temporal/temporal_timestamp.dart diff --git a/packages/amplify_core/lib/src/util/parsers.dart b/packages/amplify_datastore_plugin_interface/lib/src/types/utils/parsers.dart similarity index 100% rename from packages/amplify_core/lib/src/util/parsers.dart rename to packages/amplify_datastore_plugin_interface/lib/src/types/utils/parsers.dart diff --git a/packages/amplify_datastore_plugin_interface/pubspec.yaml b/packages/amplify_datastore_plugin_interface/pubspec.yaml index ccc01148ce..796a9b121d 100644 --- a/packages/amplify_datastore_plugin_interface/pubspec.yaml +++ b/packages/amplify_datastore_plugin_interface/pubspec.yaml @@ -12,6 +12,8 @@ dependencies: sdk: flutter meta: ^1.3.0 collection: ^1.15.0 + date_time_format: ^2.0.1 + uuid: ^3.0.1 amplify_core: 0.3.0-rc.2 dev_dependencies: diff --git a/packages/amplify_datastore_plugin_interface/test/amplify_modelschema_test.dart b/packages/amplify_datastore_plugin_interface/test/amplify_modelschema_test.dart index 50112b0683..e434236150 100644 --- a/packages/amplify_datastore_plugin_interface/test/amplify_modelschema_test.dart +++ b/packages/amplify_datastore_plugin_interface/test/amplify_modelschema_test.dart @@ -19,7 +19,8 @@ CodegenModel -> ModelSchema -> Map We need to verify that each conversion step (->) is done correctly and each state retains the proper information */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/models/model_association.dart'; import 'package:flutter_test/flutter_test.dart'; import 'testData/ModelProvider.dart'; diff --git a/packages/amplify_core/test/amplify_temporal_date_test.dart b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_date_test.dart similarity index 97% rename from packages/amplify_core/test/amplify_temporal_date_test.dart rename to packages/amplify_datastore_plugin_interface/test/amplify_temporal_date_test.dart index 936e877a35..b1927ffedd 100644 --- a/packages/amplify_core/test/amplify_temporal_date_test.dart +++ b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_date_test.dart @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/temporal/temporal_date.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/amplify_core/test/amplify_temporal_datetime_test.dart b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_datetime_test.dart similarity index 98% rename from packages/amplify_core/test/amplify_temporal_datetime_test.dart rename to packages/amplify_datastore_plugin_interface/test/amplify_temporal_datetime_test.dart index c8abcd4010..9561da40a7 100644 --- a/packages/amplify_core/test/amplify_temporal_datetime_test.dart +++ b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_datetime_test.dart @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/temporal/temporal_datetime.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/amplify_core/test/amplify_temporal_time_test.dart b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_time_test.dart similarity index 98% rename from packages/amplify_core/test/amplify_temporal_time_test.dart rename to packages/amplify_datastore_plugin_interface/test/amplify_temporal_time_test.dart index edb04e3a82..9df4aa4a34 100644 --- a/packages/amplify_core/test/amplify_temporal_time_test.dart +++ b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_time_test.dart @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/temporal/temporal_time.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/amplify_core/test/amplify_temporal_timestamp_test.dart b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_timestamp_test.dart similarity index 92% rename from packages/amplify_core/test/amplify_temporal_timestamp_test.dart rename to packages/amplify_datastore_plugin_interface/test/amplify_temporal_timestamp_test.dart index 9a22f9bb3f..ac876f6f94 100644 --- a/packages/amplify_core/test/amplify_temporal_timestamp_test.dart +++ b/packages/amplify_datastore_plugin_interface/test/amplify_temporal_timestamp_test.dart @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/src/types/temporal/temporal_timestamp.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/amplify_core/test/amplify_utility_test.dart b/packages/amplify_datastore_plugin_interface/test/amplify_utility_test.dart similarity index 95% rename from packages/amplify_core/test/amplify_utility_test.dart rename to packages/amplify_datastore_plugin_interface/test/amplify_utility_test.dart index da679f2173..c5d86487e0 100644 --- a/packages/amplify_core/test/amplify_utility_test.dart +++ b/packages/amplify_datastore_plugin_interface/test/amplify_utility_test.dart @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart'; import 'package:flutter_test/flutter_test.dart'; enum TestEnum { YES, NO, MAYBE }