From 0b3672b09849290394b7a775beaccf1ec6379dbf Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Thu, 16 Nov 2023 11:40:46 -0600 Subject: [PATCH 1/3] fix(api): GraphQL Model Helpers support lowercase model names --- .../lib/src/graphql/factories/graphql_request_factory.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0cb87855c4..fbb99f7e38 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 @@ -126,7 +126,7 @@ class GraphQLRequestFactory { ) { var upperOutput = ''; var lowerOutput = ''; - final modelName = schema.name; + final modelName = _capitalize(schema.name); // build inputs based on request operation switch (operation) { @@ -209,7 +209,7 @@ class GraphQLRequestFactory { getModelSchemaByModelName(modelType.modelName(), requestOperation); // e.g. "Blog" or "Blogs" - final name = _getName(schema, requestOperation); + final name = _capitalize(_getName(schema, requestOperation)); // e.g. "query" or "mutation" final requestTypeVal = requestType.name; // e.g. "get" or "list" From ee51e9ee3a419a4b8ff546965a2970562a1b0bef Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Thu, 16 Nov 2023 11:41:56 -0600 Subject: [PATCH 2/3] chore: added test & codegen changes --- .../api/apiintegmultiauth/schema.graphql | 15 + .../graphql/user_pools_test.dart | 18 ++ .../example/integration_test/util.dart | 14 + .../ios/Runner.xcodeproj/project.pbxproj | 3 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../amplify_api/example/lib/models/Blog.dart | 157 ++++++----- .../example/lib/models/Comment.dart | 147 +++++----- ...kOneToOneBidirectionalChildExplicitCD.dart | 136 +++++---- ...kOneToOneBidirectionalChildImplicitCD.dart | 136 +++++---- .../CpkOneToOneBidirectionalParentCD.dart | 217 +++++++++------ .../example/lib/models/ModelProvider.dart | 27 +- .../example/lib/models/OwnerOnly.dart | 116 ++++---- .../amplify_api/example/lib/models/Post.dart | 180 ++++++------ .../example/lib/models/lowerCase.dart | 257 ++++++++++++++++++ 14 files changed, 955 insertions(+), 470 deletions(-) create mode 100644 packages/api/amplify_api/example/lib/models/lowerCase.dart 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 2d9e29de14..d6da35c282 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 @@ -67,3 +67,18 @@ 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: owner, operations: [create, read, update, delete] } + ] + ) { + id: ID! + name: String! +} \ No newline at end of file diff --git a/packages/api/amplify_api/example/integration_test/graphql/user_pools_test.dart b/packages/api/amplify_api/example/integration_test/graphql/user_pools_test.dart index 42200b70af..af3d5f5daf 100644 --- a/packages/api/amplify_api/example/integration_test/graphql/user_pools_test.dart +++ b/packages/api/amplify_api/example/integration_test/graphql/user_pools_test.dart @@ -122,6 +122,24 @@ void main({bool useExistingTestUser = false}) { expect(data.rating, equals(rating)); }); + testWidgets('should CREATE a lower case model name with Model helper', + (WidgetTester tester) async { + final name = 'Integration Test lowercase - ${uuid()}'; + final model = lowerCase(name: name); + + final req = ModelMutations.create( + model, + authorizationMode: APIAuthorizationType.userPools, + ); + final res = await Amplify.API.mutate(request: req).response; + expect(res, hasNoGraphQLErrors); + final data = res.data; + if (data != null) lowerCaseCache.add(data); + + expect(data?.name, equals(model.name)); + expect(data?.id, equals(model.id)); + }); + testWidgets('should UPDATE a blog with Model helper', (WidgetTester tester) async { const oldName = 'Integration Test Blog to update'; diff --git a/packages/api/amplify_api/example/integration_test/util.dart b/packages/api/amplify_api/example/integration_test/util.dart index 4efee87a8f..eec8ae4516 100644 --- a/packages/api/amplify_api/example/integration_test/util.dart +++ b/packages/api/amplify_api/example/integration_test/util.dart @@ -19,6 +19,7 @@ TestUser? testUser; final blogCache = []; final postCache = []; final ownerOnlyCache = []; +final lowerCaseCache = []; final cpkParentCache = []; final cpkExplicitChildCache = []; final cpkImplicitChildCache = []; @@ -297,12 +298,25 @@ Future deleteOwnerOnly(OwnerOnly model) async { return res.data; } +Future deleteLowerCase(lowerCase model) async { + final request = ModelMutations.deleteById( + lowerCase.classType, + model.modelIdentifier, + authorizationMode: APIAuthorizationType.userPools, + ); + final res = await Amplify.API.mutate(request: request).response; + expect(res, hasNoGraphQLErrors); + lowerCaseCache.removeWhere((modelFromCache) => modelFromCache.id == model.id); + return res.data; +} + Future deleteTestModels() async { await Future.wait(blogCache.map(deleteBlog)); await Future.wait(postCache.map(deletePost)); await Future.wait(cpkExplicitChildCache.map(deleteCpkExplicitChild)); await Future.wait(cpkImplicitChildCache.map(deleteCpkImplicitChild)); await Future.wait(ownerOnlyCache.map(deleteOwnerOnly)); + await Future.wait(lowerCaseCache.map(deleteLowerCase)); } /// Wait for subscription established for given request. diff --git a/packages/api/amplify_api/example/ios/Runner.xcodeproj/project.pbxproj b/packages/api/amplify_api/example/ios/Runner.xcodeproj/project.pbxproj index 4edc8c4604..4de3b7f396 100644 --- a/packages/api/amplify_api/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/api/amplify_api/example/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -226,6 +226,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/api/amplify_api/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/api/amplify_api/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a335..a6b826db27 100644 --- a/packages/api/amplify_api/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/api/amplify_api/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ ? _posts; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -50,10 +48,10 @@ class Blog extends Model { try { return _name!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -63,11 +61,11 @@ class Blog extends Model { return _posts; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -80,7 +78,7 @@ class Blog extends Model { factory Blog({String? id, required String name, List? posts}) { return Blog._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, posts: posts != null ? List.unmodifiable(posts) : posts); } @@ -103,7 +101,7 @@ class Blog extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Blog {"); buffer.write("id=" + "$id" + ", "); @@ -123,6 +121,14 @@ class Blog extends Model { id: id, name: name ?? this.name, posts: posts ?? this.posts); } + Blog copyWithModelFieldValues( + {ModelFieldValue? name, ModelFieldValue?>? posts}) { + return Blog._internal( + id: id, + name: name == null ? this.name : name.value, + posts: posts == null ? this.posts : posts.value); + } + Blog.fromJson(Map json) : id = json['id'], _name = json['name'], @@ -130,14 +136,14 @@ class Blog extends Model { ? (json['posts'] as List) .where((e) => e?['serializedData'] != null) .map((e) => Post.fromJson( - Map.from(e['serializedData']))) + new Map.from(e['serializedData']))) .toList() : null, _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -156,76 +162,84 @@ class Blog extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField POSTS = QueryField( + 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 POSTS = amplify_core.QueryField( fieldName: "posts", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, ofModelName: 'Post')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Post')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Blog"; modelSchemaDefinition.pluralName = "Blogs"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.PUBLIC, - provider: AuthRuleProvider.APIKEY, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.PUBLIC, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.USERPOOLS, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.OWNER, + 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: AuthRuleProvider.USERPOOLS, - operations: [ - ModelOperation.CREATE, - ModelOperation.READ, - ModelOperation.UPDATE, - ModelOperation.DELETE + 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(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Blog.NAME, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.hasMany( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany( key: Blog.POSTS, isRequired: false, ofModelName: 'Post', associatedKey: Post.BLOG)); - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + 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 _BlogModelType extends ModelType { +class _BlogModelType extends amplify_core.ModelType { const _BlogModelType(); @override @@ -239,13 +253,14 @@ class _BlogModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Blog] in your schema. -@immutable -class BlogModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Blog] in your schema. + */ +class BlogModelIdentifier implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of BlogModelIdentifier using [id] the primary key. + /** Create an instance of BlogModelIdentifier using [id] the primary key. */ const BlogModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api/example/lib/models/Comment.dart b/packages/api/amplify_api/example/lib/models/Comment.dart index 59753eea16..113f9d9cab 100644 --- a/packages/api/amplify_api/example/lib/models/Comment.dart +++ b/packages/api/amplify_api/example/lib/models/Comment.dart @@ -20,18 +20,16 @@ // 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'; -import 'package:flutter/foundation.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the Comment type in your schema. -@immutable -class Comment extends Model { - static const classType = _CommentModelType(); +/** This is an auto generated class representing the Comment type in your schema. */ +class Comment extends amplify_core.Model { + static const classType = const _CommentModelType(); final String id; final Post? _post; final String? _content; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -53,20 +51,20 @@ class Comment extends Model { try { return _content!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -79,7 +77,9 @@ class Comment extends Model { factory Comment({String? id, Post? post, required String content}) { return Comment._internal( - id: id == null ? UUID.getUUID() : id, post: post, content: content); + id: id == null ? amplify_core.UUID.getUUID() : id, + post: post, + content: content); } bool equals(Object other) { @@ -100,7 +100,7 @@ class Comment extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Comment {"); buffer.write("id=" + "$id" + ", "); @@ -121,18 +121,26 @@ class Comment extends Model { id: id, post: post ?? this.post, content: content ?? this.content); } + Comment copyWithModelFieldValues( + {ModelFieldValue? post, ModelFieldValue? content}) { + return Comment._internal( + id: id, + post: post == null ? this.post : post.value, + content: content == null ? this.content : content.value); + } + Comment.fromJson(Map json) : id = json['id'], _post = json['post']?['serializedData'] != null ? Post.fromJson( - Map.from(json['post']['serializedData'])) + new Map.from(json['post']['serializedData'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -151,72 +159,80 @@ class Comment extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField POST = QueryField( + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final POST = amplify_core.QueryField( fieldName: "post", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, ofModelName: 'Post')); - static final QueryField CONTENT = QueryField(fieldName: "content"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Post')); + static final CONTENT = amplify_core.QueryField(fieldName: "content"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Comment"; modelSchemaDefinition.pluralName = "Comments"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.USERPOOLS, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.OWNER, + 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: AuthRuleProvider.USERPOOLS, - operations: [ - ModelOperation.CREATE, - ModelOperation.READ, - ModelOperation.UPDATE, - ModelOperation.DELETE + provider: amplify_core.AuthRuleProvider.USERPOOLS, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.READ, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE ]) ]; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["postID"], name: "byPost") + amplify_core.ModelIndex(fields: const ["postID"], name: "byPost") ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: Comment.POST, isRequired: false, targetNames: ['postID'], ofModelName: 'Post')); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Comment.CONTENT, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + 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 _CommentModelType extends ModelType { +class _CommentModelType extends amplify_core.ModelType { const _CommentModelType(); @override @@ -230,13 +246,14 @@ class _CommentModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Comment] in your schema. -@immutable -class CommentModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Comment] in your schema. + */ +class CommentModelIdentifier implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of CommentModelIdentifier using [id] the primary key. + /** Create an instance of CommentModelIdentifier using [id] the primary key. */ const CommentModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart index 83fe7ce786..026ea05e28 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart @@ -20,18 +20,17 @@ // 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'; -import 'package:flutter/foundation.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the CpkOneToOneBidirectionalChildExplicitCD type in your schema. -@immutable -class CpkOneToOneBidirectionalChildExplicitCD extends Model { - static const classType = _CpkOneToOneBidirectionalChildExplicitCDModelType(); +/** This is an auto generated class representing the CpkOneToOneBidirectionalChildExplicitCD type in your schema. */ +class CpkOneToOneBidirectionalChildExplicitCD extends amplify_core.Model { + static const classType = + const _CpkOneToOneBidirectionalChildExplicitCDModelType(); final String id; final String? _name; final CpkOneToOneBidirectionalParentCD? _belongsToParent; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -46,10 +45,10 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { return CpkOneToOneBidirectionalChildExplicitCDModelIdentifier( id: id, name: _name!); } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -59,10 +58,10 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { try { return _name!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -72,11 +71,11 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { return _belongsToParent; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -92,7 +91,7 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { required String name, CpkOneToOneBidirectionalParentCD? belongsToParent}) { return CpkOneToOneBidirectionalChildExplicitCD._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, belongsToParent: belongsToParent); } @@ -115,7 +114,7 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CpkOneToOneBidirectionalChildExplicitCD {"); buffer.write("id=" + "$id" + ", "); @@ -141,19 +140,29 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { belongsToParent: belongsToParent ?? this.belongsToParent); } + CpkOneToOneBidirectionalChildExplicitCD copyWithModelFieldValues( + {ModelFieldValue? belongsToParent}) { + return CpkOneToOneBidirectionalChildExplicitCD._internal( + id: id, + name: name, + belongsToParent: belongsToParent == null + ? this.belongsToParent + : belongsToParent.value); + } + CpkOneToOneBidirectionalChildExplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], _belongsToParent = json['belongsToParent']?['serializedData'] != null ? CpkOneToOneBidirectionalParentCD.fromJson( - Map.from( + new Map.from( json['belongsToParent']['serializedData'])) : null, _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -172,62 +181,73 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier< + static final amplify_core.QueryModelIdentifier< CpkOneToOneBidirectionalChildExplicitCDModelIdentifier> - MODEL_IDENTIFIER = QueryModelIdentifier< + MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier< CpkOneToOneBidirectionalChildExplicitCDModelIdentifier>(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField BELONGSTOPARENT = QueryField( + static final ID = amplify_core.QueryField(fieldName: "id"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final BELONGSTOPARENT = amplify_core.QueryField( fieldName: "belongsToParent", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'CpkOneToOneBidirectionalParentCD')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkOneToOneBidirectionalChildExplicitCD"; modelSchemaDefinition.pluralName = "CpkOneToOneBidirectionalChildExplicitCDS"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]) + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PRIVATE, + provider: amplify_core.AuthRuleProvider.IAM, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE, + amplify_core.ModelOperation.READ + ]) ]; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["id", "name"], name: null) + amplify_core.ModelIndex(fields: const ["id", "name"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalChildExplicitCD.NAME, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: CpkOneToOneBidirectionalChildExplicitCD.BELONGSTOPARENT, isRequired: false, targetNames: ['belongsToParentID', 'belongsToParentName'], ofModelName: 'CpkOneToOneBidirectionalParentCD')); - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + 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 _CpkOneToOneBidirectionalChildExplicitCDModelType - extends ModelType { + extends amplify_core.ModelType { const _CpkOneToOneBidirectionalChildExplicitCDModelType(); @override @@ -242,16 +262,20 @@ class _CpkOneToOneBidirectionalChildExplicitCDModelType } } -/// This is an auto generated class representing the model identifier -/// of [CpkOneToOneBidirectionalChildExplicitCD] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [CpkOneToOneBidirectionalChildExplicitCD] in your schema. + */ class CpkOneToOneBidirectionalChildExplicitCDModelIdentifier - implements ModelIdentifier { + implements + amplify_core.ModelIdentifier { final String id; final String name; - /// Create an instance of CpkOneToOneBidirectionalChildExplicitCDModelIdentifier using [id] the primary key. - /// And [name] the sort key. + /** + * Create an instance of CpkOneToOneBidirectionalChildExplicitCDModelIdentifier using [id] the primary key. + * And [name] the sort key. + */ const CpkOneToOneBidirectionalChildExplicitCDModelIdentifier( {required this.id, required this.name}); diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart index 88650b6e08..06300d363a 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart @@ -20,18 +20,17 @@ // 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'; -import 'package:flutter/foundation.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the CpkOneToOneBidirectionalChildImplicitCD type in your schema. -@immutable -class CpkOneToOneBidirectionalChildImplicitCD extends Model { - static const classType = _CpkOneToOneBidirectionalChildImplicitCDModelType(); +/** This is an auto generated class representing the CpkOneToOneBidirectionalChildImplicitCD type in your schema. */ +class CpkOneToOneBidirectionalChildImplicitCD extends amplify_core.Model { + static const classType = + const _CpkOneToOneBidirectionalChildImplicitCDModelType(); final String id; final String? _name; final CpkOneToOneBidirectionalParentCD? _belongsToParent; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -46,10 +45,10 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { return CpkOneToOneBidirectionalChildImplicitCDModelIdentifier( id: id, name: _name!); } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -59,10 +58,10 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { try { return _name!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -72,11 +71,11 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { return _belongsToParent; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -92,7 +91,7 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { required String name, CpkOneToOneBidirectionalParentCD? belongsToParent}) { return CpkOneToOneBidirectionalChildImplicitCD._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, belongsToParent: belongsToParent); } @@ -115,7 +114,7 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CpkOneToOneBidirectionalChildImplicitCD {"); buffer.write("id=" + "$id" + ", "); @@ -141,19 +140,29 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { belongsToParent: belongsToParent ?? this.belongsToParent); } + CpkOneToOneBidirectionalChildImplicitCD copyWithModelFieldValues( + {ModelFieldValue? belongsToParent}) { + return CpkOneToOneBidirectionalChildImplicitCD._internal( + id: id, + name: name, + belongsToParent: belongsToParent == null + ? this.belongsToParent + : belongsToParent.value); + } + CpkOneToOneBidirectionalChildImplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], _belongsToParent = json['belongsToParent']?['serializedData'] != null ? CpkOneToOneBidirectionalParentCD.fromJson( - Map.from( + new Map.from( json['belongsToParent']['serializedData'])) : null, _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -172,41 +181,48 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier< + static final amplify_core.QueryModelIdentifier< CpkOneToOneBidirectionalChildImplicitCDModelIdentifier> - MODEL_IDENTIFIER = QueryModelIdentifier< + MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier< CpkOneToOneBidirectionalChildImplicitCDModelIdentifier>(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField BELONGSTOPARENT = QueryField( + static final ID = amplify_core.QueryField(fieldName: "id"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final BELONGSTOPARENT = amplify_core.QueryField( fieldName: "belongsToParent", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'CpkOneToOneBidirectionalParentCD')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkOneToOneBidirectionalChildImplicitCD"; modelSchemaDefinition.pluralName = "CpkOneToOneBidirectionalChildImplicitCDS"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]) + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PRIVATE, + provider: amplify_core.AuthRuleProvider.IAM, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE, + amplify_core.ModelOperation.READ + ]) ]; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["id", "name"], name: null) + amplify_core.ModelIndex(fields: const ["id", "name"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalChildImplicitCD.NAME, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: CpkOneToOneBidirectionalChildImplicitCD.BELONGSTOPARENT, isRequired: false, targetNames: [ @@ -215,22 +231,26 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { ], ofModelName: 'CpkOneToOneBidirectionalParentCD')); - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + 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 _CpkOneToOneBidirectionalChildImplicitCDModelType - extends ModelType { + extends amplify_core.ModelType { const _CpkOneToOneBidirectionalChildImplicitCDModelType(); @override @@ -245,16 +265,20 @@ class _CpkOneToOneBidirectionalChildImplicitCDModelType } } -/// This is an auto generated class representing the model identifier -/// of [CpkOneToOneBidirectionalChildImplicitCD] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [CpkOneToOneBidirectionalChildImplicitCD] in your schema. + */ class CpkOneToOneBidirectionalChildImplicitCDModelIdentifier - implements ModelIdentifier { + implements + amplify_core.ModelIdentifier { final String id; final String name; - /// Create an instance of CpkOneToOneBidirectionalChildImplicitCDModelIdentifier using [id] the primary key. - /// And [name] the sort key. + /** + * Create an instance of CpkOneToOneBidirectionalChildImplicitCDModelIdentifier using [id] the primary key. + * And [name] the sort key. + */ const CpkOneToOneBidirectionalChildImplicitCDModelIdentifier( {required this.id, required this.name}); diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart index 7b1116a620..8965b67dac 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart @@ -20,19 +20,17 @@ // 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'; -import 'package:flutter/foundation.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the CpkOneToOneBidirectionalParentCD type in your schema. -@immutable -class CpkOneToOneBidirectionalParentCD extends Model { - static const classType = _CpkOneToOneBidirectionalParentCDModelType(); +/** This is an auto generated class representing the CpkOneToOneBidirectionalParentCD type in your schema. */ +class CpkOneToOneBidirectionalParentCD extends amplify_core.Model { + static const classType = const _CpkOneToOneBidirectionalParentCDModelType(); final String? _customId; final String? _name; final CpkOneToOneBidirectionalChildImplicitCD? _implicitChild; final CpkOneToOneBidirectionalChildExplicitCD? _explicitChild; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; final String? _cpkOneToOneBidirectionalParentCDImplicitChildId; final String? _cpkOneToOneBidirectionalParentCDImplicitChildName; final String? _cpkOneToOneBidirectionalParentCDExplicitChildId; @@ -51,10 +49,10 @@ class CpkOneToOneBidirectionalParentCD extends Model { return CpkOneToOneBidirectionalParentCDModelIdentifier( customId: _customId!, name: _name!); } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -64,10 +62,10 @@ class CpkOneToOneBidirectionalParentCD extends Model { try { return _customId!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -77,10 +75,10 @@ class CpkOneToOneBidirectionalParentCD extends Model { try { return _name!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -94,11 +92,11 @@ class CpkOneToOneBidirectionalParentCD extends Model { return _explicitChild; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -195,7 +193,7 @@ class CpkOneToOneBidirectionalParentCD extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CpkOneToOneBidirectionalParentCD {"); buffer.write("customId=" + "$_customId" + ", "); @@ -248,24 +246,58 @@ class CpkOneToOneBidirectionalParentCD extends Model { this.cpkOneToOneBidirectionalParentCDExplicitChildName); } + CpkOneToOneBidirectionalParentCD copyWithModelFieldValues( + {ModelFieldValue? implicitChild, + ModelFieldValue? explicitChild, + ModelFieldValue? cpkOneToOneBidirectionalParentCDImplicitChildId, + ModelFieldValue? + cpkOneToOneBidirectionalParentCDImplicitChildName, + ModelFieldValue? cpkOneToOneBidirectionalParentCDExplicitChildId, + ModelFieldValue? + cpkOneToOneBidirectionalParentCDExplicitChildName}) { + return CpkOneToOneBidirectionalParentCD._internal( + customId: customId, + name: name, + implicitChild: + implicitChild == null ? this.implicitChild : implicitChild.value, + explicitChild: + explicitChild == null ? this.explicitChild : explicitChild.value, + cpkOneToOneBidirectionalParentCDImplicitChildId: + cpkOneToOneBidirectionalParentCDImplicitChildId == null + ? this.cpkOneToOneBidirectionalParentCDImplicitChildId + : cpkOneToOneBidirectionalParentCDImplicitChildId.value, + cpkOneToOneBidirectionalParentCDImplicitChildName: + cpkOneToOneBidirectionalParentCDImplicitChildName == null + ? this.cpkOneToOneBidirectionalParentCDImplicitChildName + : cpkOneToOneBidirectionalParentCDImplicitChildName.value, + cpkOneToOneBidirectionalParentCDExplicitChildId: + cpkOneToOneBidirectionalParentCDExplicitChildId == null + ? this.cpkOneToOneBidirectionalParentCDExplicitChildId + : cpkOneToOneBidirectionalParentCDExplicitChildId.value, + cpkOneToOneBidirectionalParentCDExplicitChildName: + cpkOneToOneBidirectionalParentCDExplicitChildName == null + ? this.cpkOneToOneBidirectionalParentCDExplicitChildName + : cpkOneToOneBidirectionalParentCDExplicitChildName.value); + } + CpkOneToOneBidirectionalParentCD.fromJson(Map json) : _customId = json['customId'], _name = json['name'], _implicitChild = json['implicitChild']?['serializedData'] != null ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( - Map.from( + new Map.from( json['implicitChild']['serializedData'])) : null, _explicitChild = json['explicitChild']?['serializedData'] != null ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( - Map.from( + new Map.from( json['explicitChild']['serializedData'])) : null, _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null, _cpkOneToOneBidirectionalParentCDImplicitChildId = json['cpkOneToOneBidirectionalParentCDImplicitChildId'], @@ -310,109 +342,129 @@ class CpkOneToOneBidirectionalParentCD extends Model { _cpkOneToOneBidirectionalParentCDExplicitChildName }; - static final QueryModelIdentifier< - CpkOneToOneBidirectionalParentCDModelIdentifier> MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField CUSTOMID = QueryField(fieldName: "customId"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField IMPLICITCHILD = QueryField( + static final amplify_core + .QueryModelIdentifier + MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier< + CpkOneToOneBidirectionalParentCDModelIdentifier>(); + static final CUSTOMID = amplify_core.QueryField(fieldName: "customId"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final IMPLICITCHILD = amplify_core.QueryField( fieldName: "implicitChild", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'CpkOneToOneBidirectionalChildImplicitCD')); - static final QueryField EXPLICITCHILD = QueryField( + static final EXPLICITCHILD = amplify_core.QueryField( fieldName: "explicitChild", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'CpkOneToOneBidirectionalChildExplicitCD')); - static final QueryField CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDID = - QueryField(fieldName: "cpkOneToOneBidirectionalParentCDImplicitChildId"); - static final QueryField CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDNAME = - QueryField( + static final CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDID = + amplify_core.QueryField( + fieldName: "cpkOneToOneBidirectionalParentCDImplicitChildId"); + static final CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDNAME = + amplify_core.QueryField( fieldName: "cpkOneToOneBidirectionalParentCDImplicitChildName"); - static final QueryField CPKONETOONEBIDIRECTIONALPARENTCDEXPLICITCHILDID = - QueryField(fieldName: "cpkOneToOneBidirectionalParentCDExplicitChildId"); - static final QueryField CPKONETOONEBIDIRECTIONALPARENTCDEXPLICITCHILDNAME = - QueryField( + static final CPKONETOONEBIDIRECTIONALPARENTCDEXPLICITCHILDID = + amplify_core.QueryField( + fieldName: "cpkOneToOneBidirectionalParentCDExplicitChildId"); + static final CPKONETOONEBIDIRECTIONALPARENTCDEXPLICITCHILDNAME = + amplify_core.QueryField( fieldName: "cpkOneToOneBidirectionalParentCDExplicitChildName"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkOneToOneBidirectionalParentCD"; modelSchemaDefinition.pluralName = "CpkOneToOneBidirectionalParentCDS"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]) + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PRIVATE, + provider: amplify_core.AuthRuleProvider.IAM, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE, + amplify_core.ModelOperation.READ + ]) ]; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["customId", "name"], name: null) + amplify_core.ModelIndex(fields: const ["customId", "name"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalParentCD.CUSTOMID, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalParentCD.NAME, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.hasOne( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasOne( key: CpkOneToOneBidirectionalParentCD.IMPLICITCHILD, isRequired: false, ofModelName: 'CpkOneToOneBidirectionalChildImplicitCD', associatedKey: CpkOneToOneBidirectionalChildImplicitCD.BELONGSTOPARENT)); - modelSchemaDefinition.addField(ModelFieldDefinition.hasOne( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasOne( key: CpkOneToOneBidirectionalParentCD.EXPLICITCHILD, isRequired: false, ofModelName: 'CpkOneToOneBidirectionalChildExplicitCD', associatedKey: CpkOneToOneBidirectionalChildExplicitCD.BELONGSTOPARENT)); - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.field( + 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))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalParentCD .CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDID, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalParentCD .CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDNAME, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalParentCD .CPKONETOONEBIDIRECTIONALPARENTCDEXPLICITCHILDID, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkOneToOneBidirectionalParentCD .CPKONETOONEBIDIRECTIONALPARENTCDEXPLICITCHILDNAME, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); }); } class _CpkOneToOneBidirectionalParentCDModelType - extends ModelType { + extends amplify_core.ModelType { const _CpkOneToOneBidirectionalParentCDModelType(); @override @@ -426,16 +478,19 @@ class _CpkOneToOneBidirectionalParentCDModelType } } -/// This is an auto generated class representing the model identifier -/// of [CpkOneToOneBidirectionalParentCD] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [CpkOneToOneBidirectionalParentCD] in your schema. + */ class CpkOneToOneBidirectionalParentCDModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String customId; final String name; - /// Create an instance of CpkOneToOneBidirectionalParentCDModelIdentifier using [customId] the primary key. - /// And [name] the sort key. + /** + * Create an instance of CpkOneToOneBidirectionalParentCDModelIdentifier using [customId] the primary key. + * And [name] the sort key. + */ const CpkOneToOneBidirectionalParentCDModelIdentifier( {required this.customId, required this.name}); diff --git a/packages/api/amplify_api/example/lib/models/ModelProvider.dart b/packages/api/amplify_api/example/lib/models/ModelProvider.dart index 810cecdbf9..4232f40f01 100644 --- a/packages/api/amplify_api/example/lib/models/ModelProvider.dart +++ b/packages/api/amplify_api/example/lib/models/ModelProvider.dart @@ -19,7 +19,7 @@ // 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'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'Blog.dart'; import 'Comment.dart'; import 'CpkOneToOneBidirectionalChildExplicitCD.dart'; @@ -27,6 +27,7 @@ import 'CpkOneToOneBidirectionalChildImplicitCD.dart'; import 'CpkOneToOneBidirectionalParentCD.dart'; import 'OwnerOnly.dart'; import 'Post.dart'; +import 'lowerCase.dart'; export 'Blog.dart'; export 'Comment.dart'; @@ -35,27 +36,29 @@ export 'CpkOneToOneBidirectionalChildImplicitCD.dart'; export 'CpkOneToOneBidirectionalParentCD.dart'; export 'OwnerOnly.dart'; export 'Post.dart'; +export 'lowerCase.dart'; -class ModelProvider implements ModelProviderInterface { +class ModelProvider implements amplify_core.ModelProviderInterface { @override - String version = "a88eeb9e37e28459e7e16f3f2f218f9e"; + String version = "76a7a7d8d3182c2fe17550068e585db7"; @override - List modelSchemas = [ + List modelSchemas = [ Blog.schema, Comment.schema, CpkOneToOneBidirectionalChildExplicitCD.schema, CpkOneToOneBidirectionalChildImplicitCD.schema, CpkOneToOneBidirectionalParentCD.schema, OwnerOnly.schema, - Post.schema + Post.schema, + lowerCase.schema ]; - static final ModelProvider _instance = ModelProvider(); @override - List customTypeSchemas = []; + List customTypeSchemas = []; + static final ModelProvider _instance = ModelProvider(); static ModelProvider get instance => _instance; - ModelType getModelTypeByModelName(String modelName) { + amplify_core.ModelType getModelTypeByModelName(String modelName) { switch (modelName) { case "Blog": return Blog.classType; @@ -71,6 +74,8 @@ class ModelProvider implements ModelProviderInterface { return OwnerOnly.classType; case "Post": return Post.classType; + case "lowerCase": + return lowerCase.classType; default: throw Exception( "Failed to find model in model provider for model name: " + @@ -78,3 +83,9 @@ class ModelProvider implements ModelProviderInterface { } } } + +class ModelFieldValue { + const ModelFieldValue.value(this.value); + + final T value; +} diff --git a/packages/api/amplify_api/example/lib/models/OwnerOnly.dart b/packages/api/amplify_api/example/lib/models/OwnerOnly.dart index bf6e1ac3c5..39ea127d0e 100644 --- a/packages/api/amplify_api/example/lib/models/OwnerOnly.dart +++ b/packages/api/amplify_api/example/lib/models/OwnerOnly.dart @@ -19,17 +19,16 @@ // 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'; -import 'package:flutter/foundation.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the OwnerOnly type in your schema. -@immutable -class OwnerOnly extends Model { - static const classType = _OwnerOnlyModelType(); +/** This is an auto generated class representing the OwnerOnly type in your schema. */ +class OwnerOnly extends amplify_core.Model { + static const classType = const _OwnerOnlyModelType(); final String id; final String? _name; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -47,20 +46,20 @@ class OwnerOnly extends Model { try { return _name!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -72,7 +71,7 @@ class OwnerOnly extends Model { factory OwnerOnly({String? id, required String name}) { return OwnerOnly._internal( - id: id == null ? UUID.getUUID() : id, name: name); + id: id == null ? amplify_core.UUID.getUUID() : id, name: name); } bool equals(Object other) { @@ -90,7 +89,7 @@ class OwnerOnly extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("OwnerOnly {"); buffer.write("id=" + "$id" + ", "); @@ -109,14 +108,19 @@ class OwnerOnly extends Model { return OwnerOnly._internal(id: id, name: name ?? this.name); } + OwnerOnly copyWithModelFieldValues({ModelFieldValue? name}) { + return OwnerOnly._internal( + id: id, name: name == null ? this.name : name.value); + } + OwnerOnly.fromJson(Map json) : id = json['id'], _name = json['name'], _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -133,51 +137,57 @@ class OwnerOnly extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField NAME = QueryField(fieldName: "name"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + 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 var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "OwnerOnly"; modelSchemaDefinition.pluralName = "OwnerOnlies"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.OWNER, + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.OWNER, ownerField: "owner", identityClaim: "cognito:username", - provider: AuthRuleProvider.USERPOOLS, - operations: [ - ModelOperation.CREATE, - ModelOperation.UPDATE, - ModelOperation.DELETE, - ModelOperation.READ + provider: amplify_core.AuthRuleProvider.USERPOOLS, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE, + amplify_core.ModelOperation.READ ]) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: OwnerOnly.NAME, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + 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 _OwnerOnlyModelType extends ModelType { +class _OwnerOnlyModelType extends amplify_core.ModelType { const _OwnerOnlyModelType(); @override @@ -191,13 +201,15 @@ class _OwnerOnlyModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [OwnerOnly] in your schema. -@immutable -class OwnerOnlyModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [OwnerOnly] in your schema. + */ +class OwnerOnlyModelIdentifier + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of OwnerOnlyModelIdentifier using [id] the primary key. + /** Create an instance of OwnerOnlyModelIdentifier using [id] the primary key. */ const OwnerOnlyModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api/example/lib/models/Post.dart b/packages/api/amplify_api/example/lib/models/Post.dart index 30352e854d..31b1247f4c 100644 --- a/packages/api/amplify_api/example/lib/models/Post.dart +++ b/packages/api/amplify_api/example/lib/models/Post.dart @@ -20,21 +20,19 @@ // 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'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'package:collection/collection.dart'; -import 'package:flutter/foundation.dart'; -/// This is an auto generated class representing the Post type in your schema. -@immutable -class Post extends Model { - static const classType = _PostModelType(); +/** This is an auto generated class representing the Post type in your schema. */ +class Post extends amplify_core.Model { + static const classType = const _PostModelType(); final String id; final String? _title; final int? _rating; final Blog? _blog; final List? _comments; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -52,10 +50,10 @@ class Post extends Model { try { return _title!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -65,10 +63,10 @@ class Post extends Model { try { return _rating!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -82,11 +80,11 @@ class Post extends Model { return _comments; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -112,7 +110,7 @@ class Post extends Model { Blog? blog, List? comments}) { return Post._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, title: title, rating: rating, blog: blog, @@ -140,7 +138,7 @@ class Post extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Post {"); buffer.write("id=" + "$id" + ", "); @@ -168,26 +166,39 @@ class Post extends Model { comments: comments ?? this.comments); } + Post copyWithModelFieldValues( + {ModelFieldValue? title, + ModelFieldValue? rating, + ModelFieldValue? blog, + ModelFieldValue?>? comments}) { + return Post._internal( + id: id, + title: title == null ? this.title : title.value, + rating: rating == null ? this.rating : rating.value, + blog: blog == null ? this.blog : blog.value, + comments: comments == null ? this.comments : comments.value); + } + Post.fromJson(Map json) : id = json['id'], _title = json['title'], _rating = (json['rating'] as num?)?.toInt(), _blog = json['blog']?['serializedData'] != null ? Blog.fromJson( - Map.from(json['blog']['serializedData'])) + 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( - Map.from(e['serializedData']))) + new Map.from(e['serializedData']))) .toList() : null, _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -210,92 +221,102 @@ class Post extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField TITLE = QueryField(fieldName: "title"); - static final QueryField RATING = QueryField(fieldName: "rating"); - static final QueryField BLOG = QueryField( + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final TITLE = amplify_core.QueryField(fieldName: "title"); + static final RATING = amplify_core.QueryField(fieldName: "rating"); + static final BLOG = amplify_core.QueryField( fieldName: "blog", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, ofModelName: 'Blog')); - static final QueryField COMMENTS = QueryField( + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Blog')); + static final COMMENTS = amplify_core.QueryField( fieldName: "comments", - fieldType: - ModelFieldType(ModelFieldTypeEnum.model, ofModelName: 'Comment')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Comment')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Post"; modelSchemaDefinition.pluralName = "Posts"; modelSchemaDefinition.authRules = [ - AuthRule( - authStrategy: AuthStrategy.PUBLIC, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.IAM, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.PRIVATE, - provider: AuthRuleProvider.USERPOOLS, - operations: [ModelOperation.READ]), - AuthRule( - authStrategy: AuthStrategy.OWNER, + 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: AuthRuleProvider.USERPOOLS, - operations: [ - ModelOperation.CREATE, - ModelOperation.READ, - ModelOperation.UPDATE, - ModelOperation.DELETE + provider: amplify_core.AuthRuleProvider.USERPOOLS, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.READ, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE ]) ]; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["blogID"], name: "byBlog") + amplify_core.ModelIndex(fields: const ["blogID"], name: "byBlog") ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Post.TITLE, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Post.RATING, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: Post.BLOG, isRequired: false, targetNames: ['blogID'], ofModelName: 'Blog')); - modelSchemaDefinition.addField(ModelFieldDefinition.hasMany( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany( key: Post.COMMENTS, isRequired: false, ofModelName: 'Comment', associatedKey: Comment.POST)); - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'createdAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( - fieldName: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + 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 _PostModelType extends ModelType { +class _PostModelType extends amplify_core.ModelType { const _PostModelType(); @override @@ -309,13 +330,14 @@ class _PostModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Post] in your schema. -@immutable -class PostModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Post] in your schema. + */ +class PostModelIdentifier implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of PostModelIdentifier using [id] the primary key. + /** Create an instance of PostModelIdentifier using [id] the primary key. */ const PostModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api/example/lib/models/lowerCase.dart b/packages/api/amplify_api/example/lib/models/lowerCase.dart new file mode 100644 index 0000000000..3f2fcc7c7f --- /dev/null +++ b/packages/api/amplify_api/example/lib/models/lowerCase.dart @@ -0,0 +1,257 @@ +/* +* 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 lowerCase type in your schema. */ +class lowerCase extends amplify_core.Model { + static const classType = const _lowerCaseModelType(); + final String id; + final String? _name; + 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; + + lowerCaseModelIdentifier get modelIdentifier { + return lowerCaseModelIdentifier(id: id); + } + + String get name { + try { + return _name!; + } catch (e) { + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages + .codeGenRequiredFieldForceCastExceptionMessage, + recoverySuggestion: amplify_core.AmplifyExceptionMessages + .codeGenRequiredFieldForceCastRecoverySuggestion, + underlyingException: e.toString()); + } + } + + amplify_core.TemporalDateTime? get createdAt { + return _createdAt; + } + + amplify_core.TemporalDateTime? get updatedAt { + return _updatedAt; + } + + const lowerCase._internal( + {required this.id, required name, createdAt, updatedAt}) + : _name = name, + _createdAt = createdAt, + _updatedAt = updatedAt; + + factory lowerCase({String? id, required String name}) { + return lowerCase._internal( + id: id == null ? amplify_core.UUID.getUUID() : id, name: name); + } + + bool equals(Object other) { + return this == other; + } + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is lowerCase && id == other.id && _name == other._name; + } + + @override + int get hashCode => toString().hashCode; + + @override + String toString() { + var buffer = new StringBuffer(); + + buffer.write("lowerCase {"); + buffer.write("id=" + "$id" + ", "); + buffer.write("name=" + "$_name" + ", "); + buffer.write("createdAt=" + + (_createdAt != null ? _createdAt!.format() : "null") + + ", "); + buffer.write( + "updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); + buffer.write("}"); + + return buffer.toString(); + } + + lowerCase copyWith({String? name}) { + return lowerCase._internal(id: id, name: name ?? this.name); + } + + lowerCase copyWithModelFieldValues({ModelFieldValue? name}) { + return lowerCase._internal( + id: id, name: name == null ? this.name : name.value); + } + + lowerCase.fromJson(Map json) + : id = json['id'], + _name = json['name'], + _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, + 'createdAt': _createdAt?.format(), + 'updatedAt': _updatedAt?.format() + }; + + Map toMap() => { + 'id': id, + 'name': _name, + '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 var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { + modelSchemaDefinition.name = "lowerCase"; + modelSchemaDefinition.pluralName = "lowerCases"; + + 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: lowerCase.NAME, + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + 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 _lowerCaseModelType extends amplify_core.ModelType { + const _lowerCaseModelType(); + + @override + lowerCase fromJson(Map jsonData) { + return lowerCase.fromJson(jsonData); + } + + @override + String modelName() { + return 'lowerCase'; + } +} + +/** + * This is an auto generated class representing the model identifier + * of [lowerCase] in your schema. + */ +class lowerCaseModelIdentifier + implements amplify_core.ModelIdentifier { + final String id; + + /** Create an instance of lowerCaseModelIdentifier using [id] the primary key. */ + const lowerCaseModelIdentifier({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() => 'lowerCaseModelIdentifier(id: $id)'; + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + + return other is lowerCaseModelIdentifier && id == other.id; + } + + @override + int get hashCode => id.hashCode; +} From 3bd5658311d376ca47db39b06a471165df8cc5fc Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Tue, 21 Nov 2023 12:08:04 -0600 Subject: [PATCH 3/3] chore: amplify backend artifacts --- packages/api/amplify_api/example/amplify/README.md | 8 ++++++++ ...apiintegmultiauth0aef1d4a-cloudformation-template.json | 2 +- ...131fe55a131fe55aPreSignup-cloudformation-template.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 packages/api/amplify_api/example/amplify/README.md diff --git a/packages/api/amplify_api/example/amplify/README.md b/packages/api/amplify_api/example/amplify/README.md new file mode 100644 index 0000000000..7c0a9e285f --- /dev/null +++ b/packages/api/amplify_api/example/amplify/README.md @@ -0,0 +1,8 @@ +# Getting Started with Amplify CLI +This directory was generated by [Amplify CLI](https://docs.amplify.aws/cli). + +Helpful resources: +- Amplify documentation: https://docs.amplify.aws +- Amplify CLI documentation: https://docs.amplify.aws/cli +- More details on this folder & generated files: https://docs.amplify.aws/cli/reference/files +- Join Amplify's community: https://amplify.aws/community/ diff --git a/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth0aef1d4a/apiintegmultiauth0aef1d4a-cloudformation-template.json b/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth0aef1d4a/apiintegmultiauth0aef1d4a-cloudformation-template.json index a529aea6d4..1f1190e910 100644 --- a/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth0aef1d4a/apiintegmultiauth0aef1d4a-cloudformation-template.json +++ b/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth0aef1d4a/apiintegmultiauth0aef1d4a-cloudformation-template.json @@ -1,6 +1,6 @@ { "AWSTemplateFormatVersion": "2010-09-09", - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"Amplify\",\"createdWith\":\"9.2.1\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"Amplify\",\"createdWith\":\"12.8.2\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Parameters": { "CloudWatchRule": { "Type": "String", diff --git a/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth131fe55a131fe55aPreSignup/apiintegmultiauth131fe55a131fe55aPreSignup-cloudformation-template.json b/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth131fe55a131fe55aPreSignup/apiintegmultiauth131fe55a131fe55aPreSignup-cloudformation-template.json index 2e4409c227..6bc1cff90c 100644 --- a/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth131fe55a131fe55aPreSignup/apiintegmultiauth131fe55a131fe55aPreSignup-cloudformation-template.json +++ b/packages/api/amplify_api/example/amplify/backend/function/apiintegmultiauth131fe55a131fe55aPreSignup/apiintegmultiauth131fe55a131fe55aPreSignup-cloudformation-template.json @@ -1,6 +1,6 @@ { "AWSTemplateFormatVersion": "2010-09-09", - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"Amplify\",\"createdWith\":\"9.2.1\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"Amplify\",\"createdWith\":\"12.8.2\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Parameters": { "DOMAINBLACKLIST": { "Type": "String",