From f98ee66f4a8468bed6c285393db159774072fae3 Mon Sep 17 00:00:00 2001 From: Burak Karahan Date: Tue, 6 Feb 2024 23:35:33 +0300 Subject: [PATCH 01/10] feat(api): add attributeExists to GraphQL Query Predicate Operation --- .../lib/src/types/query/query_field.dart | 21 ++++++++++++ .../types/query/query_field_operators.dart | 27 +++++++++++++++- .../integration_test/graphql/iam_test.dart | 32 +++++++++++++++++++ .../factories/graphql_request_factory.dart | 1 + 4 files changed, 80 insertions(+), 1 deletion(-) diff --git a/packages/amplify_core/lib/src/types/query/query_field.dart b/packages/amplify_core/lib/src/types/query/query_field.dart index 03f067cc68..f86a78a5b6 100644 --- a/packages/amplify_core/lib/src/types/query/query_field.dart +++ b/packages/amplify_core/lib/src/types/query/query_field.dart @@ -256,6 +256,27 @@ class QueryField { QueryPredicateOperation beginsWith(String value) => QueryPredicateOperation(fieldName, BeginsWithQueryOperator(value)); + /// An **attribute exists** operation. + /// + /// Matches models whether the given field exists or not. + /// + /// ### Example: + /// The example returns Blog where the title attribute is not exists. + /// + /// ```dart + /// ModelQueries.list( + /// Post.classType, + /// where: Post.BLOG.attributeExists(value: true), + /// ); + /// ``` + QueryPredicateOperation attributeExists({bool? value}) => + QueryPredicateOperation( + fieldName, + AttributeExistsQueryOperator( + value ?? false, + ), + ); + /// Sorts models by the given field in ascending order /// /// ### Example: diff --git a/packages/amplify_core/lib/src/types/query/query_field_operators.dart b/packages/amplify_core/lib/src/types/query/query_field_operators.dart index 3fd94f20ec..981e9b1a5b 100644 --- a/packages/amplify_core/lib/src/types/query/query_field_operators.dart +++ b/packages/amplify_core/lib/src/types/query/query_field_operators.dart @@ -14,7 +14,8 @@ enum QueryFieldOperatorType { greater_than, contains, between, - begins_with + begins_with, + attribute_exists, } extension QueryFieldOperatorTypeExtension on QueryFieldOperatorType { @@ -380,3 +381,27 @@ class BeginsWithQueryOperator extends QueryFieldOperatorSingleValue { @override bool evaluateSerialized(String? other) => evaluate(other); } + +class AttributeExistsQueryOperator extends QueryFieldOperatorSingleValue { + const AttributeExistsQueryOperator(bool value) + : super(value, QueryFieldOperatorType.attribute_exists); + + @override + bool evaluate(bool? other) { + if (other == null) { + return false; + } + return other == value; + } + + @override + bool evaluateSerialized(bool? other) => evaluate(other); + + @override + Map serializeAsMap() { + return { + 'operatorName': QueryFieldOperatorType.attribute_exists.toShortString(), + 'value': serializeDynamicValue(value), + }; + } +} diff --git a/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart b/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart index 39f2a1d17e..7221982632 100644 --- a/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart +++ b/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart @@ -62,6 +62,38 @@ void main({bool useExistingTestUser = false}) { expect(data[listBlogs][items], hasLength(greaterThanOrEqualTo(0))); }); + testWidgets('should attributeExists request', + (WidgetTester tester) async { + final title = 'Lorem Ipsum Test Post: ${uuid()}'; + const rating = 0; + final createdPost = await addPostAndBlog(title, rating); + final blogId = createdPost.blog?.id; + + // Original request with mock id + final req = ModelQueries.list( + Post.classType, + where: Post.BLOG.attributeExists(value: true), + limit: _limit, + ); + + // Copy request with actual blog id + final copiedRequest = req.copyWith( + variables: { + ...req.variables, + 'filter': { + 'blogID': {'attributeExists': true}, + }, + }, + ); + final res = await Amplify.API.query(request: copiedRequest).response; + final postFromResponse = res.data?.items[0]; + + expect(res, hasNoGraphQLErrors); + expect(postFromResponse?.blog?.id, isNotNull); + expect(postFromResponse?.blog?.id, blogId); + expect(postFromResponse?.title, title); + }); + testWidgets('should fetch when document string contains tabs', (WidgetTester tester) async { const listBlogs = 'listBlogs'; diff --git a/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart b/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart index fbb99f7e38..6f21a6eaf3 100644 --- a/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart +++ b/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart @@ -471,6 +471,7 @@ String _getGraphQLFilterExpression(QueryFieldOperatorType operatorType) { QueryFieldOperatorType.between: 'between', QueryFieldOperatorType.contains: 'contains', QueryFieldOperatorType.begins_with: 'beginsWith', + QueryFieldOperatorType.attribute_exists: 'attributeExists', }; final result = dictionary[operatorType]; if (result == null) { From 71de357e11971d67c6553128ab7aebd094f80e20 Mon Sep 17 00:00:00 2001 From: Burak Karahan Date: Tue, 6 Feb 2024 23:54:20 +0300 Subject: [PATCH 02/10] chore(api): fix typo --- packages/amplify_core/lib/src/types/query/query_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify_core/lib/src/types/query/query_field.dart b/packages/amplify_core/lib/src/types/query/query_field.dart index f86a78a5b6..51522e1322 100644 --- a/packages/amplify_core/lib/src/types/query/query_field.dart +++ b/packages/amplify_core/lib/src/types/query/query_field.dart @@ -261,7 +261,7 @@ class QueryField { /// Matches models whether the given field exists or not. /// /// ### Example: - /// The example returns Blog where the title attribute is not exists. + /// The example returns Post where the Blog attribute is not exists. /// /// ```dart /// ModelQueries.list( From 996fbe65958c6140bfd165dcbebf0f63e5805a6f Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 12 Apr 2024 11:56:08 -0500 Subject: [PATCH 03/10] chore: clean up & refactor test --- .../lib/src/types/query/query_field.dart | 10 +- .../types/query/query_field_operators.dart | 4 +- .../api/apiintegmultiauth/schema.graphql | 99 +++-- .../integration_test/graphql/iam_test.dart | 80 ++-- .../example/integration_test/util.dart | 42 ++ .../example/lib/models/ModelProvider.dart | 7 +- .../example/lib/models/Sample.dart | 365 ++++++++++++++++++ 7 files changed, 533 insertions(+), 74 deletions(-) create mode 100644 packages/api/amplify_api/example/lib/models/Sample.dart diff --git a/packages/amplify_core/lib/src/types/query/query_field.dart b/packages/amplify_core/lib/src/types/query/query_field.dart index 51522e1322..5530ca16d1 100644 --- a/packages/amplify_core/lib/src/types/query/query_field.dart +++ b/packages/amplify_core/lib/src/types/query/query_field.dart @@ -261,19 +261,19 @@ class QueryField { /// Matches models whether the given field exists or not. /// /// ### Example: - /// The example returns Post where the Blog attribute is not exists. + /// The example returns Blog where the optional Author attribute exists. /// /// ```dart /// ModelQueries.list( - /// Post.classType, - /// where: Post.BLOG.attributeExists(value: true), + /// Blog.classType, + /// where: Blog.AUTHOR.attributeExists(), /// ); /// ``` - QueryPredicateOperation attributeExists({bool? value}) => + QueryPredicateOperation attributeExists({bool exists = true}) => QueryPredicateOperation( fieldName, AttributeExistsQueryOperator( - value ?? false, + exists: exists, ), ); diff --git a/packages/amplify_core/lib/src/types/query/query_field_operators.dart b/packages/amplify_core/lib/src/types/query/query_field_operators.dart index 981e9b1a5b..b2b98867c3 100644 --- a/packages/amplify_core/lib/src/types/query/query_field_operators.dart +++ b/packages/amplify_core/lib/src/types/query/query_field_operators.dart @@ -383,8 +383,8 @@ class BeginsWithQueryOperator extends QueryFieldOperatorSingleValue { } class AttributeExistsQueryOperator extends QueryFieldOperatorSingleValue { - const AttributeExistsQueryOperator(bool value) - : super(value, QueryFieldOperatorType.attribute_exists); + const AttributeExistsQueryOperator({bool exists = true}) + : super(exists, QueryFieldOperatorType.attribute_exists); @override bool evaluate(bool? other) { diff --git a/packages/api/amplify_api/example/amplify/backend/api/apiintegmultiauth/schema.graphql b/packages/api/amplify_api/example/amplify/backend/api/apiintegmultiauth/schema.graphql index d6da35c282..08c9b23e36 100644 --- a/packages/api/amplify_api/example/amplify/backend/api/apiintegmultiauth/schema.graphql +++ b/packages/api/amplify_api/example/amplify/backend/api/apiintegmultiauth/schema.graphql @@ -1,21 +1,29 @@ -type Blog @model @auth(rules: [ - { allow: public, operations: [read], provider: apiKey}, - { allow: public, operations: [read], provider: iam}, - { allow: private, operations: [read], provider: iam}, - { allow: private, operations: [read], provider: userPools}, - { allow: owner, operations: [create, read, update, delete] } -]) { +type Blog + @model + @auth( + rules: [ + { allow: public, operations: [read], provider: apiKey } + { allow: public, operations: [read], provider: iam } + { allow: private, operations: [read], provider: iam } + { allow: private, operations: [read], provider: userPools } + { allow: owner, operations: [create, read, update, delete] } + ] + ) { id: ID! name: String! posts: [Post] @hasMany(indexName: "byBlog", fields: ["id"]) } -type Post @model @auth(rules: [ - { allow: public, operations: [read], provider: iam}, - { allow: private, operations: [read], provider: iam}, - { allow: private, operations: [read], provider: userPools}, - { allow: owner, operations: [create, read, update, delete] } -]) { +type Post + @model + @auth( + rules: [ + { allow: public, operations: [read], provider: iam } + { allow: private, operations: [read], provider: iam } + { allow: private, operations: [read], provider: userPools } + { allow: owner, operations: [create, read, update, delete] } + ] + ) { id: ID! title: String! rating: Int! @@ -24,37 +32,41 @@ type Post @model @auth(rules: [ comments: [Comment] @hasMany(indexName: "byPost", fields: ["id"]) } -type Comment @model @auth(rules: [ - { allow: private, operations: [read], provider: iam}, - { allow: private, operations: [read], provider: userPools}, - { allow: owner, operations: [create, read, update, delete] } -]) { +type Comment + @model + @auth( + rules: [ + { allow: private, operations: [read], provider: iam } + { allow: private, operations: [read], provider: userPools } + { allow: owner, operations: [create, read, update, delete] } + ] + ) { id: ID! postID: ID! @index(name: "byPost") post: Post @belongsTo(fields: ["postID"]) content: String! } -type CpkOneToOneBidirectionalParentCD @model @auth(rules: [ - { allow: private, provider: iam} -]) { +type CpkOneToOneBidirectionalParentCD + @model + @auth(rules: [{ allow: private, provider: iam }]) { customId: ID! @primaryKey(sortKeyFields: ["name"]) name: String! implicitChild: CpkOneToOneBidirectionalChildImplicitCD @hasOne explicitChild: CpkOneToOneBidirectionalChildExplicitCD @hasOne } -type CpkOneToOneBidirectionalChildImplicitCD @model @auth(rules: [ - { allow: private, provider: iam} -]) { +type CpkOneToOneBidirectionalChildImplicitCD + @model + @auth(rules: [{ allow: private, provider: iam }]) { id: ID! @primaryKey(sortKeyFields: ["name"]) name: String! belongsToParent: CpkOneToOneBidirectionalParentCD @belongsTo } -type CpkOneToOneBidirectionalChildExplicitCD @model @auth(rules: [ - { allow: private, provider: iam} -]) { +type CpkOneToOneBidirectionalChildExplicitCD + @model + @auth(rules: [{ allow: private, provider: iam }]) { id: ID! @primaryKey(sortKeyFields: ["name"]) name: String! belongsToParentID: ID @@ -63,22 +75,41 @@ type CpkOneToOneBidirectionalChildExplicitCD @model @auth(rules: [ @belongsTo(fields: ["belongsToParentID", "belongsToParentName"]) } -type OwnerOnly @model @auth(rules: [{allow: owner}]) { +type OwnerOnly @model @auth(rules: [{ allow: owner }]) { id: ID! name: String! -} +} type lowerCase @model @auth( rules: [ - { allow: public, operations: [read], provider: apiKey }, - { allow: public, operations: [read], provider: iam }, - { allow: private, operations: [read], provider: iam }, - { allow: private, operations: [read], provider: userPools }, + { allow: public, operations: [read], provider: apiKey } + { allow: public, operations: [read], provider: iam } + { allow: private, operations: [read], provider: iam } + { allow: private, operations: [read], provider: userPools } { allow: owner, operations: [create, read, update, delete] } ] ) { id: ID! name: String! -} \ No newline at end of file +} + +type Sample + @model + @auth( + rules: [ + { allow: public, operations: [read], provider: apiKey } + { allow: public, operations: [read], provider: iam } + { allow: private, operations: [read], provider: iam } + { allow: private, operations: [read], provider: userPools } + { allow: owner, operations: [create, read, update, delete] } + ] + ) { + id: ID! + name: String + number: Int + flag: Boolean + date: AWSTime + rootbeer: Float +} diff --git a/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart b/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart index 7221982632..23cc06a74e 100644 --- a/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart +++ b/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import 'dart:async'; import 'dart:convert'; +import 'dart:math'; import 'package:amplify_api/amplify_api.dart'; import 'package:amplify_api_example/models/ModelProvider.dart'; @@ -20,6 +21,8 @@ import '../util.dart'; /// increase past the default limit. const _limit = 10000; +const _max = 10000; + void main({bool useExistingTestUser = false}) { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -62,38 +65,6 @@ void main({bool useExistingTestUser = false}) { expect(data[listBlogs][items], hasLength(greaterThanOrEqualTo(0))); }); - testWidgets('should attributeExists request', - (WidgetTester tester) async { - final title = 'Lorem Ipsum Test Post: ${uuid()}'; - const rating = 0; - final createdPost = await addPostAndBlog(title, rating); - final blogId = createdPost.blog?.id; - - // Original request with mock id - final req = ModelQueries.list( - Post.classType, - where: Post.BLOG.attributeExists(value: true), - limit: _limit, - ); - - // Copy request with actual blog id - final copiedRequest = req.copyWith( - variables: { - ...req.variables, - 'filter': { - 'blogID': {'attributeExists': true}, - }, - }, - ); - final res = await Amplify.API.query(request: copiedRequest).response; - final postFromResponse = res.data?.items[0]; - - expect(res, hasNoGraphQLErrors); - expect(postFromResponse?.blog?.id, isNotNull); - expect(postFromResponse?.blog?.id, blogId); - expect(postFromResponse?.title, title); - }); - testWidgets('should fetch when document string contains tabs', (WidgetTester tester) async { const listBlogs = 'listBlogs'; @@ -220,6 +191,51 @@ void main({bool useExistingTestUser = false}) { expect(postFromResponse?.title, title); }); + testWidgets('should return model if attribute exists', + (WidgetTester tester) async { + // Use same name to scope the query to the created model. + final name = 'Lorem Ipsum Test Sample: ${uuid()}'; + final number = Random().nextInt(_max); + await addSamplePartial( + name, + number: number, + ); + await addSamplePartial(name); + + final existsRequest = ModelQueries.list( + Sample.classType, + where: Sample.NUMBER.attributeExists().and(Sample.NAME.eq(name)), + limit: _limit, + ); + + final existsResponse = await Amplify.API + .query( + request: existsRequest, + ) + .response; + + final existsData = existsResponse.data; + expect(existsData?.items.length, 1); + expect(existsData?.items[0]?.number, number); + + final doesNotExistRequest = ModelQueries.list( + Sample.classType, + where: Sample.NUMBER + .attributeExists(exists: false) + .and(Sample.NAME.eq(name)), + limit: _limit, + ); + final doesNotExistResponse = await Amplify.API + .query( + request: doesNotExistRequest, + ) + .response; + + final doesNotExistData = doesNotExistResponse.data; + expect(doesNotExistData?.items.length, 1); + expect(doesNotExistData?.items[0]?.number, null); + }); + testWidgets('should copyWith request', (WidgetTester tester) async { final title = 'Lorem Ipsum Test Post: ${uuid()}'; const rating = 0; diff --git a/packages/api/amplify_api/example/integration_test/util.dart b/packages/api/amplify_api/example/integration_test/util.dart index eec8ae4516..841805202d 100644 --- a/packages/api/amplify_api/example/integration_test/util.dart +++ b/packages/api/amplify_api/example/integration_test/util.dart @@ -23,6 +23,7 @@ final lowerCaseCache = []; final cpkParentCache = []; final cpkExplicitChildCache = []; final cpkImplicitChildCache = []; +final sampleCache = []; class TestUser { TestUser({ @@ -217,6 +218,34 @@ Future addPostAndBlog( return addPost(title, rating, createdBlog); } +Future addSamplePartial(String name, {int? number}) async { + const document = r''' + mutation CreatePartialSample($name: String, $number: Int) { + createSample(input: {name: $name, number: $number}) { + id + name + number + } + } + '''; + final variables = {'name': name}; + if (number != null) { + variables['number'] = number; + } + final request = GraphQLRequest( + document: document, + variables: variables, + authorizationMode: APIAuthorizationType.userPools, + decodePath: 'createSample', + modelType: Sample.classType, + ); + final response = await Amplify.API.mutate(request: request).response; + expect(response, hasNoGraphQLErrors); + final sampleFromResponse = response.data!; + sampleCache.add(sampleFromResponse); + return sampleFromResponse; +} + Future deleteBlog(Blog blog) async { final request = ModelMutations.deleteById( Blog.classType, @@ -310,6 +339,18 @@ Future deleteLowerCase(lowerCase model) async { return res.data; } +Future deleteSample(Sample sample) async { + final request = ModelMutations.deleteById( + Sample.classType, + sample.modelIdentifier, + authorizationMode: APIAuthorizationType.userPools, + ); + final response = await Amplify.API.mutate(request: request).response; + expect(response, hasNoGraphQLErrors); + sampleCache.removeWhere((sampleFromCache) => sampleFromCache.id == sample.id); + return sample; +} + Future deleteTestModels() async { await Future.wait(blogCache.map(deleteBlog)); await Future.wait(postCache.map(deletePost)); @@ -317,6 +358,7 @@ Future deleteTestModels() async { await Future.wait(cpkImplicitChildCache.map(deleteCpkImplicitChild)); await Future.wait(ownerOnlyCache.map(deleteOwnerOnly)); await Future.wait(lowerCaseCache.map(deleteLowerCase)); + await Future.wait(sampleCache.map(deleteSample)); } /// Wait for subscription established for given request. diff --git a/packages/api/amplify_api/example/lib/models/ModelProvider.dart b/packages/api/amplify_api/example/lib/models/ModelProvider.dart index 4232f40f01..26f5655374 100644 --- a/packages/api/amplify_api/example/lib/models/ModelProvider.dart +++ b/packages/api/amplify_api/example/lib/models/ModelProvider.dart @@ -27,6 +27,7 @@ import 'CpkOneToOneBidirectionalChildImplicitCD.dart'; import 'CpkOneToOneBidirectionalParentCD.dart'; import 'OwnerOnly.dart'; import 'Post.dart'; +import 'Sample.dart'; import 'lowerCase.dart'; export 'Blog.dart'; @@ -36,11 +37,12 @@ export 'CpkOneToOneBidirectionalChildImplicitCD.dart'; export 'CpkOneToOneBidirectionalParentCD.dart'; export 'OwnerOnly.dart'; export 'Post.dart'; +export 'Sample.dart'; export 'lowerCase.dart'; class ModelProvider implements amplify_core.ModelProviderInterface { @override - String version = "76a7a7d8d3182c2fe17550068e585db7"; + String version = "9b304310f45499a1a0cd1d36e4665dcd"; @override List modelSchemas = [ Blog.schema, @@ -50,6 +52,7 @@ class ModelProvider implements amplify_core.ModelProviderInterface { CpkOneToOneBidirectionalParentCD.schema, OwnerOnly.schema, Post.schema, + Sample.schema, lowerCase.schema ]; @override @@ -74,6 +77,8 @@ class ModelProvider implements amplify_core.ModelProviderInterface { return OwnerOnly.classType; case "Post": return Post.classType; + case "Sample": + return Sample.classType; case "lowerCase": return lowerCase.classType; default: diff --git a/packages/api/amplify_api/example/lib/models/Sample.dart b/packages/api/amplify_api/example/lib/models/Sample.dart new file mode 100644 index 0000000000..ac11c290b3 --- /dev/null +++ b/packages/api/amplify_api/example/lib/models/Sample.dart @@ -0,0 +1,365 @@ +/* +* 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. +*/ + +// NOTE: This file is generated and may not follow lint rules defined in your app +// Generated files can be excluded from analysis in analysis_options.yaml +// For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis + +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously + +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; + +/** This is an auto generated class representing the Sample type in your schema. */ +class Sample extends amplify_core.Model { + static const classType = const _SampleModelType(); + final String id; + final String? _name; + final int? _number; + final bool? _flag; + final amplify_core.TemporalTime? _date; + final double? _rootbeer; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; + + @override + getInstanceType() => classType; + + @Deprecated( + '[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') + @override + String getId() => id; + + SampleModelIdentifier get modelIdentifier { + return SampleModelIdentifier(id: id); + } + + String? get name { + return _name; + } + + int? get number { + return _number; + } + + bool? get flag { + return _flag; + } + + amplify_core.TemporalTime? get date { + return _date; + } + + double? get rootbeer { + return _rootbeer; + } + + amplify_core.TemporalDateTime? get createdAt { + return _createdAt; + } + + amplify_core.TemporalDateTime? get updatedAt { + return _updatedAt; + } + + const Sample._internal( + {required this.id, + name, + number, + flag, + date, + rootbeer, + createdAt, + updatedAt}) + : _name = name, + _number = number, + _flag = flag, + _date = date, + _rootbeer = rootbeer, + _createdAt = createdAt, + _updatedAt = updatedAt; + + factory Sample( + {String? id, + String? name, + int? number, + bool? flag, + amplify_core.TemporalTime? date, + double? rootbeer}) { + return Sample._internal( + id: id == null ? amplify_core.UUID.getUUID() : id, + name: name, + number: number, + flag: flag, + date: date, + rootbeer: rootbeer); + } + + bool equals(Object other) { + return this == other; + } + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is Sample && + id == other.id && + _name == other._name && + _number == other._number && + _flag == other._flag && + _date == other._date && + _rootbeer == other._rootbeer; + } + + @override + int get hashCode => toString().hashCode; + + @override + String toString() { + var buffer = new StringBuffer(); + + buffer.write("Sample {"); + buffer.write("id=" + "$id" + ", "); + buffer.write("name=" + "$_name" + ", "); + buffer.write( + "number=" + (_number != null ? _number!.toString() : "null") + ", "); + buffer.write("flag=" + (_flag != null ? _flag!.toString() : "null") + ", "); + buffer.write("date=" + (_date != null ? _date!.format() : "null") + ", "); + buffer.write("rootbeer=" + + (_rootbeer != null ? _rootbeer!.toString() : "null") + + ", "); + buffer.write("createdAt=" + + (_createdAt != null ? _createdAt!.format() : "null") + + ", "); + buffer.write( + "updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); + buffer.write("}"); + + return buffer.toString(); + } + + Sample copyWith( + {String? name, + int? number, + bool? flag, + amplify_core.TemporalTime? date, + double? rootbeer}) { + return Sample._internal( + id: id, + name: name ?? this.name, + number: number ?? this.number, + flag: flag ?? this.flag, + date: date ?? this.date, + rootbeer: rootbeer ?? this.rootbeer); + } + + Sample copyWithModelFieldValues( + {ModelFieldValue? name, + ModelFieldValue? number, + ModelFieldValue? flag, + ModelFieldValue? date, + ModelFieldValue? rootbeer}) { + return Sample._internal( + id: id, + name: name == null ? this.name : name.value, + number: number == null ? this.number : number.value, + flag: flag == null ? this.flag : flag.value, + date: date == null ? this.date : date.value, + rootbeer: rootbeer == null ? this.rootbeer : rootbeer.value); + } + + Sample.fromJson(Map json) + : id = json['id'], + _name = json['name'], + _number = (json['number'] as num?)?.toInt(), + _flag = json['flag'], + _date = json['date'] != null + ? amplify_core.TemporalTime.fromString(json['date']) + : null, + _rootbeer = (json['rootbeer'] as num?)?.toDouble(), + _createdAt = json['createdAt'] != null + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) + : null, + _updatedAt = json['updatedAt'] != null + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) + : null; + + Map toJson() => { + 'id': id, + 'name': _name, + 'number': _number, + 'flag': _flag, + 'date': _date?.format(), + 'rootbeer': _rootbeer, + 'createdAt': _createdAt?.format(), + 'updatedAt': _updatedAt?.format() + }; + + Map toMap() => { + 'id': id, + 'name': _name, + 'number': _number, + 'flag': _flag, + 'date': _date, + 'rootbeer': _rootbeer, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final NUMBER = amplify_core.QueryField(fieldName: "number"); + static final FLAG = amplify_core.QueryField(fieldName: "flag"); + static final DATE = amplify_core.QueryField(fieldName: "date"); + static final ROOTBEER = amplify_core.QueryField(fieldName: "rootbeer"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { + modelSchemaDefinition.name = "Sample"; + modelSchemaDefinition.pluralName = "Samples"; + + modelSchemaDefinition.authRules = [ + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PUBLIC, + provider: amplify_core.AuthRuleProvider.APIKEY, + operations: const [amplify_core.ModelOperation.READ]), + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PUBLIC, + provider: amplify_core.AuthRuleProvider.IAM, + operations: const [amplify_core.ModelOperation.READ]), + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PRIVATE, + provider: amplify_core.AuthRuleProvider.IAM, + operations: const [amplify_core.ModelOperation.READ]), + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PRIVATE, + provider: amplify_core.AuthRuleProvider.USERPOOLS, + operations: const [amplify_core.ModelOperation.READ]), + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.OWNER, + ownerField: "owner", + identityClaim: "cognito:username", + provider: amplify_core.AuthRuleProvider.USERPOOLS, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.READ, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE + ]) + ]; + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( + key: Sample.NAME, + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( + key: Sample.NUMBER, + isRequired: false, + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( + key: Sample.FLAG, + isRequired: false, + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.bool))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( + key: Sample.DATE, + isRequired: false, + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.time))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( + key: Sample.ROOTBEER, + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.double))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.nonQueryField( + fieldName: 'createdAt', + isRequired: false, + isReadOnly: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.nonQueryField( + fieldName: 'updatedAt', + isRequired: false, + isReadOnly: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); + }); +} + +class _SampleModelType extends amplify_core.ModelType { + const _SampleModelType(); + + @override + Sample fromJson(Map jsonData) { + return Sample.fromJson(jsonData); + } + + @override + String modelName() { + return 'Sample'; + } +} + +/** + * This is an auto generated class representing the model identifier + * of [Sample] in your schema. + */ +class SampleModelIdentifier implements amplify_core.ModelIdentifier { + final String id; + + /** Create an instance of SampleModelIdentifier using [id] the primary key. */ + const SampleModelIdentifier({required this.id}); + + @override + Map serializeAsMap() => ({'id': id}); + + @override + List> serializeAsList() => serializeAsMap() + .entries + .map((entry) => ({entry.key: entry.value})) + .toList(); + + @override + String serializeAsString() => serializeAsMap().values.join('#'); + + @override + String toString() => 'SampleModelIdentifier(id: $id)'; + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + + return other is SampleModelIdentifier && id == other.id; + } + + @override + int get hashCode => id.hashCode; +} From e0e2172f4a0012719c1050e544e06bb6fe87469c Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 12 Apr 2024 12:18:54 -0500 Subject: [PATCH 04/10] empty commit to trigger build From 14604c1f54e02c14d7269a4be11a47fb67100f78 Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 12 Apr 2024 12:25:18 -0500 Subject: [PATCH 05/10] empty commit to trigger build From 16d3e6fd4da28847697d3c4f1f08333af591c3df Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Tue, 16 Apr 2024 15:36:51 -0500 Subject: [PATCH 06/10] fix: changed base class & added tests --- .../types/query/query_field_operators.dart | 20 ++++++------ .../integration_test/observe_test.dart | 31 +++++++++++++++++++ .../test/query_predicate_test.dart | 6 ++++ 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/packages/amplify_core/lib/src/types/query/query_field_operators.dart b/packages/amplify_core/lib/src/types/query/query_field_operators.dart index b2b98867c3..c3a2c60a21 100644 --- a/packages/amplify_core/lib/src/types/query/query_field_operators.dart +++ b/packages/amplify_core/lib/src/types/query/query_field_operators.dart @@ -382,26 +382,28 @@ class BeginsWithQueryOperator extends QueryFieldOperatorSingleValue { bool evaluateSerialized(String? other) => evaluate(other); } -class AttributeExistsQueryOperator extends QueryFieldOperatorSingleValue { - const AttributeExistsQueryOperator({bool exists = true}) - : super(exists, QueryFieldOperatorType.attribute_exists); +class AttributeExistsQueryOperator extends QueryFieldOperator { + const AttributeExistsQueryOperator({this.exists = true}) + : super(QueryFieldOperatorType.attribute_exists); + + final bool exists; @override - bool evaluate(bool? other) { - if (other == null) { - return false; + bool evaluate(T? other) { + if (exists == true) { + return other != null; } - return other == value; + return other == null; } @override - bool evaluateSerialized(bool? other) => evaluate(other); + bool evaluateSerialized(T? other) => evaluate(other); @override Map serializeAsMap() { return { 'operatorName': QueryFieldOperatorType.attribute_exists.toShortString(), - 'value': serializeDynamicValue(value), + 'exists': this.exists, }; } } diff --git a/packages/amplify_datastore/example/integration_test/observe_test.dart b/packages/amplify_datastore/example/integration_test/observe_test.dart index 5dc6977570..d533e90c0d 100644 --- a/packages/amplify_datastore/example/integration_test/observe_test.dart +++ b/packages/amplify_datastore/example/integration_test/observe_test.dart @@ -124,5 +124,36 @@ void main() { await Amplify.DataStore.delete(updatedBlog); await Amplify.DataStore.save(otherBlog); }); + + testWidgets( + 'observe with attribute exists query predicate filters out non matches', + (WidgetTester tester) async { + HasOneChild hasAttribute = HasOneChild(name: 'name - ${uuid()}'); + HasOneChild hasNoAttribute = HasOneChild(); + + var hasAttributeStream = Amplify.DataStore.observe(HasOneChild.classType, + where: Blog.NAME.attributeExists()) + .map((event) => event.item); + expectLater( + hasAttributeStream, + emitsInOrder( + [hasAttribute], + ), + ); + + var hasNoAttributeStream = Amplify.DataStore.observe( + HasOneChild.classType, + where: Blog.NAME.attributeExists(exists: false)) + .map((event) => event.item); + expectLater( + hasNoAttributeStream, + emitsInOrder( + [hasNoAttribute], + ), + ); + + await Amplify.DataStore.save(hasAttribute); + await Amplify.DataStore.save(hasNoAttribute); + }); }); } diff --git a/packages/amplify_datastore/test/query_predicate_test.dart b/packages/amplify_datastore/test/query_predicate_test.dart index 00c32351c3..ad02dcb275 100644 --- a/packages/amplify_datastore/test/query_predicate_test.dart +++ b/packages/amplify_datastore/test/query_predicate_test.dart @@ -439,6 +439,12 @@ void main() { expect(testPredicate.evaluate(post2), isTrue); }); + test('attributeExists', () { + QueryPredicate testPredicate = Post.LIKECOUNT.attributeExists(); + expect(testPredicate.evaluate(post4), isFalse); + expect(testPredicate.evaluate(post2), isTrue); + }); + test('Temporal type', () { QueryPredicate testPredicate = Post.CREATED.lt(TemporalDateTime( DateTime(2020, 01, 01, 12, 00), From 19f01174fda75668449170aa2e782ccadd25b785 Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Wed, 17 Apr 2024 09:13:44 -0500 Subject: [PATCH 07/10] fix: added missing type statement --- .../lib/src/graphql/factories/graphql_request_factory.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart b/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart index 6f21a6eaf3..e697d56957 100644 --- a/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart +++ b/packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart @@ -454,6 +454,11 @@ Map _queryFieldOperatorToPartialGraphQLFilter( ], }; } + if (queryFieldOperator is AttributeExistsQueryOperator) { + return { + filterExpression: _getSerializedValue(queryFieldOperator.exists), + }; + } throw ApiOperationException( 'Unable to translate the QueryFieldOperator ${queryFieldOperator.type} to a GraphQL filter.', From c0210e4b73a4dc570feb7dc31ac37d436fcca1ae Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Mon, 29 Apr 2024 14:12:44 -0500 Subject: [PATCH 08/10] empty commit to trigger build From 85970b6d57b091a6319c1b053cb6536550fedd27 Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Mon, 29 Apr 2024 14:20:40 -0500 Subject: [PATCH 09/10] fix: model updates from main --- .../types/query/query_field_operators.dart | 3 -- .../amplify_api/example/lib/models/Blog.dart | 23 +++++-------- .../example/lib/models/Comment.dart | 10 +++--- ...kOneToOneBidirectionalChildExplicitCD.dart | 13 +++----- ...kOneToOneBidirectionalChildImplicitCD.dart | 13 +++----- .../CpkOneToOneBidirectionalParentCD.dart | 24 ++++++-------- .../example/lib/models/ModelProvider.dart | 2 +- .../example/lib/models/OwnerOnly.dart | 2 +- .../amplify_api/example/lib/models/Post.dart | 32 +++++++------------ .../example/lib/models/lowerCase.dart | 2 +- 10 files changed, 45 insertions(+), 79 deletions(-) diff --git a/packages/amplify_core/lib/src/types/query/query_field_operators.dart b/packages/amplify_core/lib/src/types/query/query_field_operators.dart index 17b887e07b..ff972ef7a9 100644 --- a/packages/amplify_core/lib/src/types/query/query_field_operators.dart +++ b/packages/amplify_core/lib/src/types/query/query_field_operators.dart @@ -273,9 +273,6 @@ class AttributeExistsQueryOperator extends QueryFieldOperator { return other == null; } - @override - bool evaluateSerialized(T? other) => evaluate(other); - @override Map serializeAsMap() { return { diff --git a/packages/api/amplify_api/example/lib/models/Blog.dart b/packages/api/amplify_api/example/lib/models/Blog.dart index ce0de09c9a..12e4a09b86 100644 --- a/packages/api/amplify_api/example/lib/models/Blog.dart +++ b/packages/api/amplify_api/example/lib/models/Blog.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -132,20 +132,13 @@ class Blog extends amplify_core.Model { Blog.fromJson(Map json) : id = json['id'], _name = json['name'], - _posts = json['posts'] is Map - ? (json['posts']['items'] is List - ? (json['posts']['items'] as List) - .where((e) => e != null) - .map((e) => Post.fromJson(new Map.from(e))) - .toList() - : null) - : (json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Post.fromJson( - new Map.from(e?['serializedData']))) - .toList() - : null), + _posts = json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Post.fromJson( + new Map.from(e['serializedData']))) + .toList() + : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/api/amplify_api/example/lib/models/Comment.dart b/packages/api/amplify_api/example/lib/models/Comment.dart index 920a8e761b..113f9d9cab 100644 --- a/packages/api/amplify_api/example/lib/models/Comment.dart +++ b/packages/api/amplify_api/example/lib/models/Comment.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -131,11 +131,9 @@ class Comment extends amplify_core.Model { Comment.fromJson(Map json) : id = json['id'], - _post = json['post'] != null - ? json['post']['serializedData'] != null - ? Post.fromJson(new Map.from( - json['post']['serializedData'])) - : Post.fromJson(new Map.from(json['post'])) + _post = json['post']?['serializedData'] != null + ? Post.fromJson( + new Map.from(json['post']['serializedData'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart index 8b80838a99..026ea05e28 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -153,13 +153,10 @@ class CpkOneToOneBidirectionalChildExplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildExplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent'] != null - ? json['belongsToParent']['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) - : CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from(json['belongsToParent'])) + _belongsToParent = json['belongsToParent']?['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart index ba73514b12..06300d363a 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -153,13 +153,10 @@ class CpkOneToOneBidirectionalChildImplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildImplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent'] != null - ? json['belongsToParent']['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) - : CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from(json['belongsToParent'])) + _belongsToParent = json['belongsToParent']?['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart index dea1da5e92..8965b67dac 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -283,21 +283,15 @@ class CpkOneToOneBidirectionalParentCD extends amplify_core.Model { CpkOneToOneBidirectionalParentCD.fromJson(Map json) : _customId = json['customId'], _name = json['name'], - _implicitChild = json['implicitChild'] != null - ? json['implicitChild']['serializedData'] != null - ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( - new Map.from( - json['implicitChild']['serializedData'])) - : CpkOneToOneBidirectionalChildImplicitCD.fromJson( - new Map.from(json['implicitChild'])) + _implicitChild = json['implicitChild']?['serializedData'] != null + ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) : null, - _explicitChild = json['explicitChild'] != null - ? json['explicitChild']['serializedData'] != null - ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( - new Map.from( - json['explicitChild']['serializedData'])) - : CpkOneToOneBidirectionalChildExplicitCD.fromJson( - new Map.from(json['explicitChild'])) + _explicitChild = json['explicitChild']?['serializedData'] != null + ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/ModelProvider.dart b/packages/api/amplify_api/example/lib/models/ModelProvider.dart index 782d646ceb..26f5655374 100644 --- a/packages/api/amplify_api/example/lib/models/ModelProvider.dart +++ b/packages/api/amplify_api/example/lib/models/ModelProvider.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'Blog.dart'; diff --git a/packages/api/amplify_api/example/lib/models/OwnerOnly.dart b/packages/api/amplify_api/example/lib/models/OwnerOnly.dart index 755b46212e..39ea127d0e 100644 --- a/packages/api/amplify_api/example/lib/models/OwnerOnly.dart +++ b/packages/api/amplify_api/example/lib/models/OwnerOnly.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; diff --git a/packages/api/amplify_api/example/lib/models/Post.dart b/packages/api/amplify_api/example/lib/models/Post.dart index 061ea2297e..31b1247f4c 100644 --- a/packages/api/amplify_api/example/lib/models/Post.dart +++ b/packages/api/amplify_api/example/lib/models/Post.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -183,27 +183,17 @@ class Post extends amplify_core.Model { : id = json['id'], _title = json['title'], _rating = (json['rating'] as num?)?.toInt(), - _blog = json['blog'] != null - ? json['blog']['serializedData'] != null - ? Blog.fromJson(new Map.from( - json['blog']['serializedData'])) - : Blog.fromJson(new Map.from(json['blog'])) + _blog = json['blog']?['serializedData'] != null + ? Blog.fromJson( + new Map.from(json['blog']['serializedData'])) + : null, + _comments = json['comments'] is List + ? (json['comments'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Comment.fromJson( + new Map.from(e['serializedData']))) + .toList() : null, - _comments = json['comments'] is Map - ? (json['comments']['items'] is List - ? (json['comments']['items'] as List) - .where((e) => e != null) - .map((e) => - Comment.fromJson(new Map.from(e))) - .toList() - : null) - : (json['comments'] is List - ? (json['comments'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Comment.fromJson( - new Map.from(e?['serializedData']))) - .toList() - : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/api/amplify_api/example/lib/models/lowerCase.dart b/packages/api/amplify_api/example/lib/models/lowerCase.dart index 9dfe030a67..3f2fcc7c7f 100644 --- a/packages/api/amplify_api/example/lib/models/lowerCase.dart +++ b/packages/api/amplify_api/example/lib/models/lowerCase.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; From 2c5218613b44b1bd57b5f629e104edc2c312b3bb Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Mon, 29 Apr 2024 15:01:55 -0500 Subject: [PATCH 10/10] fix: regen models --- .../amplify_api/example/lib/models/Blog.dart | 23 ++++++++----- .../example/lib/models/Comment.dart | 10 +++--- ...kOneToOneBidirectionalChildExplicitCD.dart | 13 +++++--- ...kOneToOneBidirectionalChildImplicitCD.dart | 13 +++++--- .../CpkOneToOneBidirectionalParentCD.dart | 24 ++++++++------ .../example/lib/models/ModelProvider.dart | 2 +- .../example/lib/models/OwnerOnly.dart | 2 +- .../amplify_api/example/lib/models/Post.dart | 32 ++++++++++++------- .../example/lib/models/Sample.dart | 2 +- .../example/lib/models/lowerCase.dart | 2 +- 10 files changed, 77 insertions(+), 46 deletions(-) diff --git a/packages/api/amplify_api/example/lib/models/Blog.dart b/packages/api/amplify_api/example/lib/models/Blog.dart index 12e4a09b86..ce0de09c9a 100644 --- a/packages/api/amplify_api/example/lib/models/Blog.dart +++ b/packages/api/amplify_api/example/lib/models/Blog.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -132,13 +132,20 @@ class Blog extends amplify_core.Model { Blog.fromJson(Map json) : id = json['id'], _name = json['name'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Post.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => Post.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Post.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/api/amplify_api/example/lib/models/Comment.dart b/packages/api/amplify_api/example/lib/models/Comment.dart index 113f9d9cab..920a8e761b 100644 --- a/packages/api/amplify_api/example/lib/models/Comment.dart +++ b/packages/api/amplify_api/example/lib/models/Comment.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -131,9 +131,11 @@ class Comment extends amplify_core.Model { Comment.fromJson(Map json) : id = json['id'], - _post = json['post']?['serializedData'] != null - ? Post.fromJson( - new Map.from(json['post']['serializedData'])) + _post = json['post'] != null + ? json['post']['serializedData'] != null + ? Post.fromJson(new Map.from( + json['post']['serializedData'])) + : Post.fromJson(new Map.from(json['post'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart index 026ea05e28..8b80838a99 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildExplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildExplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart index 06300d363a..ba73514b12 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildImplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildImplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart index 8965b67dac..dea1da5e92 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -283,15 +283,21 @@ class CpkOneToOneBidirectionalParentCD extends amplify_core.Model { CpkOneToOneBidirectionalParentCD.fromJson(Map json) : _customId = json['customId'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( - new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from(json['implicitChild'])) : null, - _explicitChild = json['explicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( - new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/ModelProvider.dart b/packages/api/amplify_api/example/lib/models/ModelProvider.dart index 26f5655374..782d646ceb 100644 --- a/packages/api/amplify_api/example/lib/models/ModelProvider.dart +++ b/packages/api/amplify_api/example/lib/models/ModelProvider.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'Blog.dart'; diff --git a/packages/api/amplify_api/example/lib/models/OwnerOnly.dart b/packages/api/amplify_api/example/lib/models/OwnerOnly.dart index 39ea127d0e..755b46212e 100644 --- a/packages/api/amplify_api/example/lib/models/OwnerOnly.dart +++ b/packages/api/amplify_api/example/lib/models/OwnerOnly.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; diff --git a/packages/api/amplify_api/example/lib/models/Post.dart b/packages/api/amplify_api/example/lib/models/Post.dart index 31b1247f4c..061ea2297e 100644 --- a/packages/api/amplify_api/example/lib/models/Post.dart +++ b/packages/api/amplify_api/example/lib/models/Post.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; @@ -183,17 +183,27 @@ class Post extends amplify_core.Model { : id = json['id'], _title = json['title'], _rating = (json['rating'] as num?)?.toInt(), - _blog = json['blog']?['serializedData'] != null - ? Blog.fromJson( - new Map.from(json['blog']['serializedData'])) - : null, - _comments = json['comments'] is List - ? (json['comments'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Comment.fromJson( - new Map.from(e['serializedData']))) - .toList() + _blog = json['blog'] != null + ? json['blog']['serializedData'] != null + ? Blog.fromJson(new Map.from( + json['blog']['serializedData'])) + : Blog.fromJson(new Map.from(json['blog'])) : null, + _comments = json['comments'] is Map + ? (json['comments']['items'] is List + ? (json['comments']['items'] as List) + .where((e) => e != null) + .map((e) => + Comment.fromJson(new Map.from(e))) + .toList() + : null) + : (json['comments'] is List + ? (json['comments'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Comment.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/api/amplify_api/example/lib/models/Sample.dart b/packages/api/amplify_api/example/lib/models/Sample.dart index ac11c290b3..9db8e79be7 100644 --- a/packages/api/amplify_api/example/lib/models/Sample.dart +++ b/packages/api/amplify_api/example/lib/models/Sample.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core; diff --git a/packages/api/amplify_api/example/lib/models/lowerCase.dart b/packages/api/amplify_api/example/lib/models/lowerCase.dart index 3f2fcc7c7f..9dfe030a67 100644 --- a/packages/api/amplify_api/example/lib/models/lowerCase.dart +++ b/packages/api/amplify_api/example/lib/models/lowerCase.dart @@ -17,7 +17,7 @@ // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis -// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; import 'package:amplify_core/amplify_core.dart' as amplify_core;