diff --git a/.github/composite_actions/fetch_backends/action.yaml b/.github/composite_actions/fetch_backends/action.yaml index cc59ac3bf1..01070b3dfd 100644 --- a/.github/composite_actions/fetch_backends/action.yaml +++ b/.github/composite_actions/fetch_backends/action.yaml @@ -46,7 +46,7 @@ runs: - name: Undo any codegen changes from amplify pull shell: bash - run: dart pub global run aft exec --include=${{ inputs.scope }} -- [ -d "lib/models" ] && git checkout lib/models/ || exit 0 + run: dart pub global run aft exec --include=${{ inputs.scope }} -- [ -d "lib/models" ] && git checkout '**/lib/models/*' || exit 0 - name: Delete AWS profile shell: bash diff --git a/packages/amplify_core/lib/src/types/datastore/conflict_handler/datastore_conflict_handler.dart b/packages/amplify_core/lib/src/types/datastore/conflict_handler/datastore_conflict_handler.dart index b6aaa8cb57..5a3a89766d 100644 --- a/packages/amplify_core/lib/src/types/datastore/conflict_handler/datastore_conflict_handler.dart +++ b/packages/amplify_core/lib/src/types/datastore/conflict_handler/datastore_conflict_handler.dart @@ -16,12 +16,8 @@ class ConflictData { ModelType modelType, Map localJson, Map remoteJson, - ) : local = modelType.fromJson( - (localJson['serializedData'] as Map).cast(), - ), - remote = modelType.fromJson( - (remoteJson['serializedData'] as Map).cast(), - ); + ) : local = modelType.fromJson(localJson), + remote = modelType.fromJson(remoteJson); final Model local; final Model remote; diff --git a/packages/amplify_core/lib/src/types/datastore/hub/hub_event_element.dart b/packages/amplify_core/lib/src/types/datastore/hub/hub_event_element.dart index 66534b57c4..96923e7094 100644 --- a/packages/amplify_core/lib/src/types/datastore/hub/hub_event_element.dart +++ b/packages/amplify_core/lib/src/types/datastore/hub/hub_event_element.dart @@ -29,10 +29,7 @@ Model _parseModelFromMap( ) { final serializedElement = serializedHubEventElement['element'] as Map; final modelName = serializedHubEventElement['modelName'] as String; - final modelData = serializedElement['model'] as Map; - final serializedModelData = - (modelData['serializedData'] as Map).cast(); - return provider - .getModelTypeByModelName(modelName) - .fromJson(serializedModelData); + final modelData = Map.from(serializedElement['model'] as Map) + .cast(); + return provider.getModelTypeByModelName(modelName).fromJson(modelData); } diff --git a/packages/amplify_core/lib/src/types/datastore/models/subscription_event.dart b/packages/amplify_core/lib/src/types/datastore/models/subscription_event.dart index 6ebb4718b6..3838a51e9b 100644 --- a/packages/amplify_core/lib/src/types/datastore/models/subscription_event.dart +++ b/packages/amplify_core/lib/src/types/datastore/models/subscription_event.dart @@ -21,9 +21,7 @@ class SubscriptionEvent { final serializedItem = Map.from(map['item'] as Map); return SubscriptionEvent( - item: modelType.fromJson( - Map.from(serializedItem['serializedData'] as Map), - ), + item: modelType.fromJson(serializedItem), eventType: EventType.values .firstWhere((e) => e.name == map['eventType'] as String?), modelType: modelType, diff --git a/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedCustomType.kt b/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedCustomType.kt index cf438de94f..1ed4e8cf81 100644 --- a/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedCustomType.kt +++ b/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedCustomType.kt @@ -3,6 +3,7 @@ package com.amazonaws.amplify.amplify_datastore.types.model +import com.amazonaws.amplify.amplify_datastore.util.cast import com.amplifyframework.core.model.CustomTypeSchema import com.amplifyframework.core.model.SerializedCustomType import com.amplifyframework.core.model.temporal.Temporal @@ -16,10 +17,11 @@ data class FlutterSerializedCustomType(val serializedCustomType: SerializedCusto private val customTypeName: String = parseCustomTypeName(serializedCustomType.customTypeName) fun toMap(): Map { - return mapOf( - "serializedData" to serializedData, - "customTypeName" to customTypeName - ) + val cleanedSerializedData: Map = serializedData.filterValues { it != null }.cast() + + val modelNameMap = mapOf("customTypeName" to customTypeName) + + return cleanedSerializedData+modelNameMap } private fun parseCustomTypeName(customTypeName: String?): String = customTypeName ?: "" diff --git a/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedModel.kt b/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedModel.kt index 69d7face9f..cf2755d783 100644 --- a/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedModel.kt +++ b/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterSerializedModel.kt @@ -22,12 +22,12 @@ data class FlutterSerializedModel(val serializedModel: SerializedModel) { parseModelName(serializedModel.modelName) // ModelSchema -> SerializedModel should always have a name fun toMap(): Map { - val cleanedSerializedData: Map = serializedData.filterValues { it != null } - return mapOf( - "serializedData" to cleanedSerializedData, - "modelName" to modelName - ) + val cleanedSerializedData: Map = serializedData.filterValues { it != null }.cast() + + val modelNameMap = mapOf("__modelName" to modelName) + + return modelNameMap+cleanedSerializedData } private fun parseModelName(modelName: String?): String { diff --git a/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifyDataStoreHubTest.kt b/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifyDataStoreHubTest.kt index 6ff7356902..b5891c0fbe 100644 --- a/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifyDataStoreHubTest.kt +++ b/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifyDataStoreHubTest.kt @@ -79,12 +79,11 @@ class AmplifyDataStoreHubTest { val element: HashMap = eventData["element"] as HashMap var metadataMap: HashMap val modelMap: HashMap = element["model"] as HashMap - val serializedData: HashMap = modelMap["serializedData"] as HashMap val modelMetadata = ModelMetadata(modelMap["id"] as String, null, null, null) val modelData = mapOf( - "id" to serializedData["id"] as String, - "title" to serializedData["title"] as String, - "created" to Temporal.DateTime(serializedData["created"] as String) + "id" to modelMap["id"] as String, + "title" to modelMap["title"] as String, + "created" to Temporal.DateTime(modelMap["created"] as String) ) val instance = SerializedModel.builder() .modelSchema(modelSchema) @@ -128,7 +127,6 @@ class AmplifyDataStoreHubTest { val element: HashMap = eventData["element"] as HashMap val metadataMap: HashMap = element["syncMetadata"] as HashMap val modelMap: HashMap = element["model"] as HashMap - val serializedData: HashMap = modelMap["serializedData"] as HashMap val modelMetadata = ModelMetadata( metadataMap["id"] as String, metadataMap["_deleted"] as Boolean, @@ -136,9 +134,9 @@ class AmplifyDataStoreHubTest { time ) val modelData = mapOf( - "id" to serializedData["id"] as String, - "title" to serializedData["title"] as String, - "created" to Temporal.DateTime(serializedData["created"] as String) + "id" to modelMap["id"] as String, + "title" to modelMap["title"] as String, + "created" to Temporal.DateTime(modelMap["created"] as String) ) val instance = SerializedModel.builder() .modelSchema(modelSchema) diff --git a/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifySerializedModelTest.kt b/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifySerializedModelTest.kt index 9d8b0df92e..8b47388e26 100644 --- a/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifySerializedModelTest.kt +++ b/packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifySerializedModelTest.kt @@ -6,10 +6,7 @@ package com.amazonaws.amplify.amplify_datastore import com.amazonaws.amplify.amplify_datastore.types.model.FlutterSerializedModel import org.junit.Assert import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner -@RunWith(RobolectricTestRunner::class) class AmplifySerializedModelTest { private var serializedModelMaps: Map = ( @@ -63,14 +60,8 @@ class AmplifySerializedModelTest { // timestamp value is expected as Long, however readMapFromFile util create Integer for this field // Correct the field before assertion val correctedRefMap = refMap.mapValues { - if (it.key == "serializedData") { - (it.value as Map).mapValues { entry -> - if (entry.key == "timestampType") { - (entry.value as Number).toLong() - } else { - entry.value - } - } + if (it.key == "timestampType") { + (it.value as Number).toLong() } else { it.value } @@ -90,8 +81,8 @@ class AmplifySerializedModelTest { // Verify result Assert.assertEquals( - flutterSerializedModel.toMap(), - expectedResult + expectedResult, + flutterSerializedModel.toMap() ) } } diff --git a/packages/amplify_datastore/example/ios/Flutter/AppFrameworkInfo.plist b/packages/amplify_datastore/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105df..7c56964006 100644 --- a/packages/amplify_datastore/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/amplify_datastore/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/packages/amplify_datastore/example/ios/Runner.xcodeproj/project.pbxproj b/packages/amplify_datastore/example/ios/Runner.xcodeproj/project.pbxproj index 9f76d7a8f1..d09cdfed52 100644 --- a/packages/amplify_datastore/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/amplify_datastore/example/ios/Runner.xcodeproj/project.pbxproj @@ -376,7 +376,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1420; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 4B4F4F0B2982D06800204FE6 = { @@ -461,6 +461,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/amplify_datastore/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/amplify_datastore/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 5c5f1b037d..ca2087b9e8 100644 --- a/packages/amplify_datastore/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/amplify_datastore/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? BelongsToParent.fromJson(new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? BelongsToParent.fromJson(new Map.from( + json['belongsToParent']['serializedData'])) + : BelongsToParent.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/BelongsToChildImplicit.dart b/packages/amplify_datastore/example/lib/models/BelongsToChildImplicit.dart index d21defa21a..939438988d 100644 --- a/packages/amplify_datastore/example/lib/models/BelongsToChildImplicit.dart +++ b/packages/amplify_datastore/example/lib/models/BelongsToChildImplicit.dart @@ -132,9 +132,12 @@ class BelongsToChildImplicit extends amplify_core.Model { BelongsToChildImplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? BelongsToParent.fromJson(new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? BelongsToParent.fromJson(new Map.from( + json['belongsToParent']['serializedData'])) + : BelongsToParent.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/BelongsToParent.dart b/packages/amplify_datastore/example/lib/models/BelongsToParent.dart index 405e1f8512..433b6186e5 100644 --- a/packages/amplify_datastore/example/lib/models/BelongsToParent.dart +++ b/packages/amplify_datastore/example/lib/models/BelongsToParent.dart @@ -192,13 +192,19 @@ class BelongsToParent extends amplify_core.Model { BelongsToParent.fromJson(Map json) : id = json['id'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? BelongsToChildImplicit.fromJson(new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? BelongsToChildImplicit.fromJson(new Map.from( + json['implicitChild']['serializedData'])) + : BelongsToChildImplicit.fromJson( + new Map.from(json['implicitChild'])) : null, - _explicitChild = json['explicitChild']?['serializedData'] != null - ? BelongsToChildExplicit.fromJson(new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? BelongsToChildExplicit.fromJson(new Map.from( + json['explicitChild']['serializedData'])) + : BelongsToChildExplicit.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/Blog.dart b/packages/amplify_datastore/example/lib/models/Blog.dart index 3766053aa0..642020667e 100644 --- a/packages/amplify_datastore/example/lib/models/Blog.dart +++ b/packages/amplify_datastore/example/lib/models/Blog.dart @@ -132,13 +132,20 @@ class Blog extends amplify_core.Model { Blog.fromJson(Map json) : id = json['id'], _name = json['name'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Post.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => Post.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Post.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/Comment.dart b/packages/amplify_datastore/example/lib/models/Comment.dart index 5fea748f01..a98a6f17b2 100644 --- a/packages/amplify_datastore/example/lib/models/Comment.dart +++ b/packages/amplify_datastore/example/lib/models/Comment.dart @@ -131,9 +131,11 @@ class Comment extends amplify_core.Model { Comment.fromJson(Map json) : id = json['id'], - _post = json['post']?['serializedData'] != null - ? Post.fromJson( - new Map.from(json['post']['serializedData'])) + _post = json['post'] != null + ? json['post']['serializedData'] != null + ? Post.fromJson(new Map.from( + json['post']['serializedData'])) + : Post.fromJson(new Map.from(json['post'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null diff --git a/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalExplicit.dart b/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalExplicit.dart index 40027a8ccd..9be873a722 100644 --- a/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalExplicit.dart +++ b/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalExplicit.dart @@ -151,10 +151,13 @@ class CpkHasManyChildBidirectionalExplicit extends amplify_core.Model { CpkHasManyChildBidirectionalExplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _hasManyParent = json['hasManyParent']?['serializedData'] != null - ? CpkHasManyParentBidirectionalExplicit.fromJson( - new Map.from( - json['hasManyParent']['serializedData'])) + _hasManyParent = json['hasManyParent'] != null + ? json['hasManyParent']['serializedData'] != null + ? CpkHasManyParentBidirectionalExplicit.fromJson( + new Map.from( + json['hasManyParent']['serializedData'])) + : CpkHasManyParentBidirectionalExplicit.fromJson( + new Map.from(json['hasManyParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalImplicit.dart b/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalImplicit.dart index 6da08965b9..f320d39e6c 100644 --- a/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalImplicit.dart +++ b/packages/amplify_datastore/example/lib/models/CpkHasManyChildBidirectionalImplicit.dart @@ -151,10 +151,13 @@ class CpkHasManyChildBidirectionalImplicit extends amplify_core.Model { CpkHasManyChildBidirectionalImplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _hasManyParent = json['hasManyParent']?['serializedData'] != null - ? CpkHasManyParentBidirectionalImplicit.fromJson( - new Map.from( - json['hasManyParent']['serializedData'])) + _hasManyParent = json['hasManyParent'] != null + ? json['hasManyParent']['serializedData'] != null + ? CpkHasManyParentBidirectionalImplicit.fromJson( + new Map.from( + json['hasManyParent']['serializedData'])) + : CpkHasManyParentBidirectionalImplicit.fromJson( + new Map.from(json['hasManyParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalExplicit.dart b/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalExplicit.dart index 41e258d426..ee59bcb5b0 100644 --- a/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalExplicit.dart +++ b/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalExplicit.dart @@ -165,14 +165,22 @@ class CpkHasManyParentBidirectionalExplicit extends amplify_core.Model { CpkHasManyParentBidirectionalExplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _bidirectionalExplicitChildren = - json['bidirectionalExplicitChildren'] is List + _bidirectionalExplicitChildren = json['bidirectionalExplicitChildren'] + is Map + ? (json['bidirectionalExplicitChildren']['items'] is List + ? (json['bidirectionalExplicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => CpkHasManyChildBidirectionalExplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['bidirectionalExplicitChildren'] is List ? (json['bidirectionalExplicitChildren'] as List) .where((e) => e?['serializedData'] != null) .map((e) => CpkHasManyChildBidirectionalExplicit.fromJson( - new Map.from(e['serializedData']))) + new Map.from(e?['serializedData']))) .toList() - : null, + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalImplicit.dart b/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalImplicit.dart index 9e3b3a5723..0d4c552776 100644 --- a/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalImplicit.dart +++ b/packages/amplify_datastore/example/lib/models/CpkHasManyParentBidirectionalImplicit.dart @@ -165,14 +165,22 @@ class CpkHasManyParentBidirectionalImplicit extends amplify_core.Model { CpkHasManyParentBidirectionalImplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _bidirectionalImplicitChildren = - json['bidirectionalImplicitChildren'] is List + _bidirectionalImplicitChildren = json['bidirectionalImplicitChildren'] + is Map + ? (json['bidirectionalImplicitChildren']['items'] is List + ? (json['bidirectionalImplicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => CpkHasManyChildBidirectionalImplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['bidirectionalImplicitChildren'] is List ? (json['bidirectionalImplicitChildren'] as List) .where((e) => e?['serializedData'] != null) .map((e) => CpkHasManyChildBidirectionalImplicit.fromJson( - new Map.from(e['serializedData']))) + new Map.from(e?['serializedData']))) .toList() - : null, + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/CpkHasManyUnidirectionalParent.dart b/packages/amplify_datastore/example/lib/models/CpkHasManyUnidirectionalParent.dart index 586b4b834f..485950b32d 100644 --- a/packages/amplify_datastore/example/lib/models/CpkHasManyUnidirectionalParent.dart +++ b/packages/amplify_datastore/example/lib/models/CpkHasManyUnidirectionalParent.dart @@ -180,20 +180,36 @@ class CpkHasManyUnidirectionalParent extends amplify_core.Model { CpkHasManyUnidirectionalParent.fromJson(Map json) : id = json['id'], _name = json['name'], - _implicitChildren = json['implicitChildren'] is List - ? (json['implicitChildren'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => CpkHasManyUnidirectionalChildImplicit.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, - _explicitChildren = json['explicitChildren'] is List - ? (json['explicitChildren'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => CpkHasManyUnidirectionalChildExplicit.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _implicitChildren = json['implicitChildren'] is Map + ? (json['implicitChildren']['items'] is List + ? (json['implicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => CpkHasManyUnidirectionalChildImplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['implicitChildren'] is List + ? (json['implicitChildren'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => CpkHasManyUnidirectionalChildImplicit.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), + _explicitChildren = json['explicitChildren'] is Map + ? (json['explicitChildren']['items'] is List + ? (json['explicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => CpkHasManyUnidirectionalChildExplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['explicitChildren'] is List + ? (json['explicitChildren'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => CpkHasManyUnidirectionalChildExplicit.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/CpkHasOneUnidirectionalParent.dart b/packages/amplify_datastore/example/lib/models/CpkHasOneUnidirectionalParent.dart index 66d99c916e..d1213aca75 100644 --- a/packages/amplify_datastore/example/lib/models/CpkHasOneUnidirectionalParent.dart +++ b/packages/amplify_datastore/example/lib/models/CpkHasOneUnidirectionalParent.dart @@ -251,17 +251,23 @@ class CpkHasOneUnidirectionalParent extends amplify_core.Model { CpkHasOneUnidirectionalParent.fromJson(Map json) : id = json['id'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? CpkHasOneUnidirectionalChild.fromJson( - new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? CpkHasOneUnidirectionalChild.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) + : CpkHasOneUnidirectionalChild.fromJson( + new Map.from(json['implicitChild'])) : null, _explicitChildID = json['explicitChildID'], _explicitChildName = json['explicitChildName'], - _explicitChild = json['explicitChild']?['serializedData'] != null - ? CpkHasOneUnidirectionalChild.fromJson( - new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? CpkHasOneUnidirectionalChild.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) + : CpkHasOneUnidirectionalChild.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkManyToManyPost.dart b/packages/amplify_datastore/example/lib/models/CpkManyToManyPost.dart index b04c95e4b0..8a123630d2 100644 --- a/packages/amplify_datastore/example/lib/models/CpkManyToManyPost.dart +++ b/packages/amplify_datastore/example/lib/models/CpkManyToManyPost.dart @@ -134,13 +134,21 @@ class CpkManyToManyPost extends amplify_core.Model { CpkManyToManyPost.fromJson(Map json) : id = json['id'], _title = json['title'], - _tags = json['tags'] is List - ? (json['tags'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => CpkPostTags.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _tags = json['tags'] is Map + ? (json['tags']['items'] is List + ? (json['tags']['items'] as List) + .where((e) => e != null) + .map((e) => + CpkPostTags.fromJson(new Map.from(e))) + .toList() + : null) + : (json['tags'] is List + ? (json['tags'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => CpkPostTags.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/CpkManyToManyTag.dart b/packages/amplify_datastore/example/lib/models/CpkManyToManyTag.dart index 2b98b102d5..4a650314c7 100644 --- a/packages/amplify_datastore/example/lib/models/CpkManyToManyTag.dart +++ b/packages/amplify_datastore/example/lib/models/CpkManyToManyTag.dart @@ -140,13 +140,21 @@ class CpkManyToManyTag extends amplify_core.Model { CpkManyToManyTag.fromJson(Map json) : id = json['id'], _label = json['label'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => CpkPostTags.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => + CpkPostTags.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => CpkPostTags.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart index b21b4ca743..ea33b2f95c 100644 --- a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart +++ b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildExplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildExplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitID.dart b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitID.dart index 25ed70b01c..59711b032f 100644 --- a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitID.dart +++ b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildExplicitID.dart @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildExplicitID extends amplify_core.Model { CpkOneToOneBidirectionalChildExplicitID.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentID.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentID.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentID.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart index 1e583b1183..f79cd646e6 100644 --- a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart +++ b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildImplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildImplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitID.dart b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitID.dart index af453c2cc6..5e5662bb69 100644 --- a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitID.dart +++ b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalChildImplicitID.dart @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildImplicitID extends amplify_core.Model { CpkOneToOneBidirectionalChildImplicitID.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentID.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentID.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentID.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentCD.dart b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentCD.dart index 68f644eb65..b1b445ad2f 100644 --- a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentCD.dart +++ b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentCD.dart @@ -283,15 +283,21 @@ class CpkOneToOneBidirectionalParentCD extends amplify_core.Model { CpkOneToOneBidirectionalParentCD.fromJson(Map json) : _customId = json['customId'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( - new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from(json['implicitChild'])) : null, - _explicitChild = json['explicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( - new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentID.dart b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentID.dart index 47efeada12..28b0750829 100644 --- a/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentID.dart +++ b/packages/amplify_datastore/example/lib/models/CpkOneToOneBidirectionalParentID.dart @@ -269,15 +269,21 @@ class CpkOneToOneBidirectionalParentID extends amplify_core.Model { CpkOneToOneBidirectionalParentID.fromJson(Map json) : id = json['id'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildImplicitID.fromJson( - new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildImplicitID.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildImplicitID.fromJson( + new Map.from(json['implicitChild'])) : null, - _explicitChild = json['explicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildExplicitID.fromJson( - new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildExplicitID.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildExplicitID.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CpkPostTags.dart b/packages/amplify_datastore/example/lib/models/CpkPostTags.dart index 374e3c5238..33c35c657f 100644 --- a/packages/amplify_datastore/example/lib/models/CpkPostTags.dart +++ b/packages/amplify_datastore/example/lib/models/CpkPostTags.dart @@ -160,14 +160,19 @@ class CpkPostTags extends amplify_core.Model { CpkPostTags.fromJson(Map json) : id = json['id'], - _cpkManyToManyPost = - json['cpkManyToManyPost']?['serializedData'] != null + _cpkManyToManyPost = json['cpkManyToManyPost'] != null + ? json['cpkManyToManyPost']['serializedData'] != null ? CpkManyToManyPost.fromJson(new Map.from( json['cpkManyToManyPost']['serializedData'])) - : null, - _cpkManyToManyTag = json['cpkManyToManyTag']?['serializedData'] != null - ? CpkManyToManyTag.fromJson(new Map.from( - json['cpkManyToManyTag']['serializedData'])) + : CpkManyToManyPost.fromJson( + new Map.from(json['cpkManyToManyPost'])) + : null, + _cpkManyToManyTag = json['cpkManyToManyTag'] != null + ? json['cpkManyToManyTag']['serializedData'] != null + ? CpkManyToManyTag.fromJson(new Map.from( + json['cpkManyToManyTag']['serializedData'])) + : CpkManyToManyTag.fromJson( + new Map.from(json['cpkManyToManyTag'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/CustomTypeWithAppsyncScalarTypes.dart b/packages/amplify_datastore/example/lib/models/CustomTypeWithAppsyncScalarTypes.dart index b91ab2377a..d678bf8514 100644 --- a/packages/amplify_datastore/example/lib/models/CustomTypeWithAppsyncScalarTypes.dart +++ b/packages/amplify_datastore/example/lib/models/CustomTypeWithAppsyncScalarTypes.dart @@ -737,15 +737,15 @@ class CustomTypeWithAppsyncScalarTypes { e, EnumField.values)!) .toList() : null, - _customTypeValue = json['customTypeValue']?['serializedData'] != null - ? SimpleCustomType.fromJson(new Map.from( - json['customTypeValue']['serializedData'])) + _customTypeValue = json['customTypeValue'] != null + ? SimpleCustomType.fromJson( + new Map.from(json['customTypeValue'])) : null, _listOfCustomTypeValue = json['listOfCustomTypeValue'] is List ? (json['listOfCustomTypeValue'] as List) .where((e) => e != null) - .map((e) => SimpleCustomType.fromJson( - new Map.from(e['serializedData']))) + .map((e) => + SimpleCustomType.fromJson(new Map.from(e))) .toList() : null; diff --git a/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalExplicit.dart b/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalExplicit.dart index 7b1cdf3d00..6c62ee0a37 100644 --- a/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalExplicit.dart +++ b/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalExplicit.dart @@ -133,10 +133,13 @@ class HasManyChildBiDirectionalExplicit extends amplify_core.Model { HasManyChildBiDirectionalExplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _hasManyParent = json['hasManyParent']?['serializedData'] != null - ? HasManyParentBiDirectionalExplicit.fromJson( - new Map.from( - json['hasManyParent']['serializedData'])) + _hasManyParent = json['hasManyParent'] != null + ? json['hasManyParent']['serializedData'] != null + ? HasManyParentBiDirectionalExplicit.fromJson( + new Map.from( + json['hasManyParent']['serializedData'])) + : HasManyParentBiDirectionalExplicit.fromJson( + new Map.from(json['hasManyParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalImplicit.dart b/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalImplicit.dart index 83c675f9b6..67eee845f7 100644 --- a/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalImplicit.dart +++ b/packages/amplify_datastore/example/lib/models/HasManyChildBiDirectionalImplicit.dart @@ -133,10 +133,13 @@ class HasManyChildBiDirectionalImplicit extends amplify_core.Model { HasManyChildBiDirectionalImplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _hasManyParent = json['hasManyParent']?['serializedData'] != null - ? HasManyParentBiDirectionalImplicit.fromJson( - new Map.from( - json['hasManyParent']['serializedData'])) + _hasManyParent = json['hasManyParent'] != null + ? json['hasManyParent']['serializedData'] != null + ? HasManyParentBiDirectionalImplicit.fromJson( + new Map.from( + json['hasManyParent']['serializedData'])) + : HasManyParentBiDirectionalImplicit.fromJson( + new Map.from(json['hasManyParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/HasManyParent.dart b/packages/amplify_datastore/example/lib/models/HasManyParent.dart index b98bef22ac..7391542c22 100644 --- a/packages/amplify_datastore/example/lib/models/HasManyParent.dart +++ b/packages/amplify_datastore/example/lib/models/HasManyParent.dart @@ -159,20 +159,36 @@ class HasManyParent extends amplify_core.Model { HasManyParent.fromJson(Map json) : id = json['id'], _name = json['name'], - _implicitChildren = json['implicitChildren'] is List - ? (json['implicitChildren'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => HasManyChildImplicit.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, - _explicitChildren = json['explicitChildren'] is List - ? (json['explicitChildren'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => HasManyChildExplicit.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _implicitChildren = json['implicitChildren'] is Map + ? (json['implicitChildren']['items'] is List + ? (json['implicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => HasManyChildImplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['implicitChildren'] is List + ? (json['implicitChildren'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => HasManyChildImplicit.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), + _explicitChildren = json['explicitChildren'] is Map + ? (json['explicitChildren']['items'] is List + ? (json['explicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => HasManyChildExplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['explicitChildren'] is List + ? (json['explicitChildren'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => HasManyChildExplicit.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalExplicit.dart b/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalExplicit.dart index babe82f0fc..0851dd3608 100644 --- a/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalExplicit.dart +++ b/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalExplicit.dart @@ -143,14 +143,22 @@ class HasManyParentBiDirectionalExplicit extends amplify_core.Model { HasManyParentBiDirectionalExplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _biDirectionalExplicitChildren = - json['biDirectionalExplicitChildren'] is List + _biDirectionalExplicitChildren = json['biDirectionalExplicitChildren'] + is Map + ? (json['biDirectionalExplicitChildren']['items'] is List + ? (json['biDirectionalExplicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => HasManyChildBiDirectionalExplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['biDirectionalExplicitChildren'] is List ? (json['biDirectionalExplicitChildren'] as List) .where((e) => e?['serializedData'] != null) .map((e) => HasManyChildBiDirectionalExplicit.fromJson( - new Map.from(e['serializedData']))) + new Map.from(e?['serializedData']))) .toList() - : null, + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalImplicit.dart b/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalImplicit.dart index 8596d8bca4..bf1514cfa4 100644 --- a/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalImplicit.dart +++ b/packages/amplify_datastore/example/lib/models/HasManyParentBiDirectionalImplicit.dart @@ -143,14 +143,22 @@ class HasManyParentBiDirectionalImplicit extends amplify_core.Model { HasManyParentBiDirectionalImplicit.fromJson(Map json) : id = json['id'], _name = json['name'], - _biDirectionalImplicitChildren = - json['biDirectionalImplicitChildren'] is List + _biDirectionalImplicitChildren = json['biDirectionalImplicitChildren'] + is Map + ? (json['biDirectionalImplicitChildren']['items'] is List + ? (json['biDirectionalImplicitChildren']['items'] as List) + .where((e) => e != null) + .map((e) => HasManyChildBiDirectionalImplicit.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['biDirectionalImplicitChildren'] is List ? (json['biDirectionalImplicitChildren'] as List) .where((e) => e?['serializedData'] != null) .map((e) => HasManyChildBiDirectionalImplicit.fromJson( - new Map.from(e['serializedData']))) + new Map.from(e?['serializedData']))) .toList() - : null, + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/HasOneParent.dart b/packages/amplify_datastore/example/lib/models/HasOneParent.dart index 556122b3e1..af284e1900 100644 --- a/packages/amplify_datastore/example/lib/models/HasOneParent.dart +++ b/packages/amplify_datastore/example/lib/models/HasOneParent.dart @@ -187,14 +187,20 @@ class HasOneParent extends amplify_core.Model { HasOneParent.fromJson(Map json) : id = json['id'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? HasOneChild.fromJson(new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? HasOneChild.fromJson(new Map.from( + json['implicitChild']['serializedData'])) + : HasOneChild.fromJson( + new Map.from(json['implicitChild'])) : null, _explicitChildID = json['explicitChildID'], - _explicitChild = json['explicitChild']?['serializedData'] != null - ? HasOneChild.fromJson(new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? HasOneChild.fromJson(new Map.from( + json['explicitChild']['serializedData'])) + : HasOneChild.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/ModelWithCustomType.dart b/packages/amplify_datastore/example/lib/models/ModelWithCustomType.dart index f7483b3ff0..c4b331997f 100644 --- a/packages/amplify_datastore/example/lib/models/ModelWithCustomType.dart +++ b/packages/amplify_datastore/example/lib/models/ModelWithCustomType.dart @@ -151,16 +151,15 @@ class ModelWithCustomType extends amplify_core.Model { ModelWithCustomType.fromJson(Map json) : id = json['id'], - _customTypeValue = json['customTypeValue']?['serializedData'] != null + _customTypeValue = json['customTypeValue'] != null ? CustomTypeWithAppsyncScalarTypes.fromJson( - new Map.from( - json['customTypeValue']['serializedData'])) + new Map.from(json['customTypeValue'])) : null, _listOfCustomTypeValue = json['listOfCustomTypeValue'] is List ? (json['listOfCustomTypeValue'] as List) .where((e) => e != null) .map((e) => CustomTypeWithAppsyncScalarTypes.fromJson( - new Map.from(e['serializedData']))) + new Map.from(e))) .toList() : null, _createdAt = json['createdAt'] != null diff --git a/packages/amplify_datastore/example/lib/models/MultiRelatedAttendee.dart b/packages/amplify_datastore/example/lib/models/MultiRelatedAttendee.dart index 0a271df8e0..61e76925fc 100644 --- a/packages/amplify_datastore/example/lib/models/MultiRelatedAttendee.dart +++ b/packages/amplify_datastore/example/lib/models/MultiRelatedAttendee.dart @@ -114,13 +114,21 @@ class MultiRelatedAttendee extends amplify_core.Model { MultiRelatedAttendee.fromJson(Map json) : id = json['id'], - _meetings = json['meetings'] is List - ? (json['meetings'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => MultiRelatedRegistration.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _meetings = json['meetings'] is Map + ? (json['meetings']['items'] is List + ? (json['meetings']['items'] as List) + .where((e) => e != null) + .map((e) => MultiRelatedRegistration.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['meetings'] is List + ? (json['meetings'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => MultiRelatedRegistration.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/MultiRelatedMeeting.dart b/packages/amplify_datastore/example/lib/models/MultiRelatedMeeting.dart index 125cd76262..2d8a9faf3e 100644 --- a/packages/amplify_datastore/example/lib/models/MultiRelatedMeeting.dart +++ b/packages/amplify_datastore/example/lib/models/MultiRelatedMeeting.dart @@ -141,13 +141,21 @@ class MultiRelatedMeeting extends amplify_core.Model { MultiRelatedMeeting.fromJson(Map json) : id = json['id'], _title = json['title'], - _attendees = json['attendees'] is List - ? (json['attendees'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => MultiRelatedRegistration.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _attendees = json['attendees'] is Map + ? (json['attendees']['items'] is List + ? (json['attendees']['items'] as List) + .where((e) => e != null) + .map((e) => MultiRelatedRegistration.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['attendees'] is List + ? (json['attendees'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => MultiRelatedRegistration.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/MultiRelatedRegistration.dart b/packages/amplify_datastore/example/lib/models/MultiRelatedRegistration.dart index 589cee8cff..2b77ee2d7d 100644 --- a/packages/amplify_datastore/example/lib/models/MultiRelatedRegistration.dart +++ b/packages/amplify_datastore/example/lib/models/MultiRelatedRegistration.dart @@ -154,13 +154,19 @@ class MultiRelatedRegistration extends amplify_core.Model { MultiRelatedRegistration.fromJson(Map json) : id = json['id'], - _meeting = json['meeting']?['serializedData'] != null - ? MultiRelatedMeeting.fromJson(new Map.from( - json['meeting']['serializedData'])) + _meeting = json['meeting'] != null + ? json['meeting']['serializedData'] != null + ? MultiRelatedMeeting.fromJson(new Map.from( + json['meeting']['serializedData'])) + : MultiRelatedMeeting.fromJson( + new Map.from(json['meeting'])) : null, - _attendee = json['attendee']?['serializedData'] != null - ? MultiRelatedAttendee.fromJson(new Map.from( - json['attendee']['serializedData'])) + _attendee = json['attendee'] != null + ? json['attendee']['serializedData'] != null + ? MultiRelatedAttendee.fromJson(new Map.from( + json['attendee']['serializedData'])) + : MultiRelatedAttendee.fromJson( + new Map.from(json['attendee'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/Post.dart b/packages/amplify_datastore/example/lib/models/Post.dart index a3579f4a26..d2cbd976de 100644 --- a/packages/amplify_datastore/example/lib/models/Post.dart +++ b/packages/amplify_datastore/example/lib/models/Post.dart @@ -219,24 +219,42 @@ class Post extends amplify_core.Model { _created = json['created'] != null ? amplify_core.TemporalDateTime.fromString(json['created']) : null, - _blog = json['blog']?['serializedData'] != null - ? Blog.fromJson( - new Map.from(json['blog']['serializedData'])) - : null, - _comments = json['comments'] is List - ? (json['comments'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Comment.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, - _tags = json['tags'] is List - ? (json['tags'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => PostTags.fromJson( - new Map.from(e['serializedData']))) - .toList() + _blog = json['blog'] != null + ? json['blog']['serializedData'] != null + ? Blog.fromJson(new Map.from( + json['blog']['serializedData'])) + : Blog.fromJson(new Map.from(json['blog'])) : null, + _comments = json['comments'] is Map + ? (json['comments']['items'] is List + ? (json['comments']['items'] as List) + .where((e) => e != null) + .map((e) => + Comment.fromJson(new Map.from(e))) + .toList() + : null) + : (json['comments'] is List + ? (json['comments'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Comment.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), + _tags = json['tags'] is Map + ? (json['tags']['items'] is List + ? (json['tags']['items'] as List) + .where((e) => e != null) + .map((e) => + PostTags.fromJson(new Map.from(e))) + .toList() + : null) + : (json['tags'] is List + ? (json['tags'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => PostTags.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/example/lib/models/PostTags.dart b/packages/amplify_datastore/example/lib/models/PostTags.dart index c44f688721..240fd3231c 100644 --- a/packages/amplify_datastore/example/lib/models/PostTags.dart +++ b/packages/amplify_datastore/example/lib/models/PostTags.dart @@ -140,13 +140,17 @@ class PostTags extends amplify_core.Model { PostTags.fromJson(Map json) : id = json['id'], - _post = json['post']?['serializedData'] != null - ? Post.fromJson( - new Map.from(json['post']['serializedData'])) + _post = json['post'] != null + ? json['post']['serializedData'] != null + ? Post.fromJson(new Map.from( + json['post']['serializedData'])) + : Post.fromJson(new Map.from(json['post'])) : null, - _tag = json['tag']?['serializedData'] != null - ? Tag.fromJson( - new Map.from(json['tag']['serializedData'])) + _tag = json['tag'] != null + ? json['tag']['serializedData'] != null + ? Tag.fromJson(new Map.from( + json['tag']['serializedData'])) + : Tag.fromJson(new Map.from(json['tag'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/amplify_datastore/example/lib/models/Tag.dart b/packages/amplify_datastore/example/lib/models/Tag.dart index b6de2bac37..abaac9ce3c 100644 --- a/packages/amplify_datastore/example/lib/models/Tag.dart +++ b/packages/amplify_datastore/example/lib/models/Tag.dart @@ -133,13 +133,21 @@ class Tag extends amplify_core.Model { Tag.fromJson(Map json) : id = json['id'], _label = json['label'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => PostTags.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => + PostTags.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => PostTags.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/amplify_datastore/ios/Classes/types/hub/FlutterHubElement.swift b/packages/amplify_datastore/ios/Classes/types/hub/FlutterHubElement.swift index df68a5fbf4..c0e6925b21 100644 --- a/packages/amplify_datastore/ios/Classes/types/hub/FlutterHubElement.swift +++ b/packages/amplify_datastore/ios/Classes/types/hub/FlutterHubElement.swift @@ -50,13 +50,12 @@ public struct FlutterHubElement { modelName: modelName ) self.version = hubElement.version - let serializedData = model["serializedData"] as? [String: Any] ?? [:] - self.deleted = serializedData["_deleted"] as? Bool ?? false - if let value = serializedData["_lastChangedAt"] as? Double { + self.deleted = self.model["_deleted"] as? Bool ?? false + if let value = self.model["_lastChangedAt"] as? Double { self.lastChangedAt = Int(value) - } else if let value = serializedData["_lastChangedAt"] as? String { + } else if let value = self.model["_lastChangedAt"] as? String { self.lastChangedAt = Int(value) - } else if let value = serializedData["_lastChangedAt"] as? Int { + } else if let value = self.model["_lastChangedAt"] as? Int { self.lastChangedAt = value } } catch { diff --git a/packages/amplify_datastore/ios/Classes/types/model/FlutterSerializedModel.swift b/packages/amplify_datastore/ios/Classes/types/model/FlutterSerializedModel.swift index 0f311d23d5..3cca3cd7b1 100644 --- a/packages/amplify_datastore/ios/Classes/types/model/FlutterSerializedModel.swift +++ b/packages/amplify_datastore/ios/Classes/types/model/FlutterSerializedModel.swift @@ -230,30 +230,31 @@ public struct FlutterSerializedModel: Model, ModelIdentifiable, JSONValueHolder continue } - result[key] = [ - "modelName": nextModelName, - "serializedData": try generateSerializedData( + let dataMap = try generateSerializedData( values: deserializedValue, modelSchemaRegistry: modelSchemaRegistry, customTypeSchemaRegistry: customTypeSchemaRegistry, modelName: nextModelName ) - ] + let modelNameMap = ["__modelName": nextModelName] + + result[key] = dataMap.merging(modelNameMap) { (current, _) in current } } // if a field has a single CustomType value presented as JSONValue.object else if case .embedded(_, .some(let customTypeSchema)) = field?.type, case .some(.object(let deserializedValue)) = values[key] { let customTypeName = customTypeSchema.name - result[key] = [ - "customTypeName": customTypeName, - "serializedData": try FlutterSerializedModel.generateSerializedData( + let dataMap = try FlutterSerializedModel.generateSerializedData( values: deserializedValue, modelSchemaRegistry: modelSchemaRegistry, customTypeSchemaRegistry: customTypeSchemaRegistry, modelName: customTypeName ) - ] + let modelNameMap = ["customTypeName": customTypeName] + + result[key] = dataMap.merging(modelNameMap) { (current, _) in current } + } } else if case .collection = field?.type{ continue @@ -266,15 +267,14 @@ public struct FlutterSerializedModel: Model, ModelIdentifiable, JSONValueHolder case .embeddedCollection(_, .some(let customTypeSchema)) = field?.type { let customTypeName = customTypeSchema.name - deserializedArray.append([ - "customTypeName": customTypeName, - "serializedData": try FlutterSerializedModel.generateSerializedData( + let dataMap = try FlutterSerializedModel.generateSerializedData( values: deserializedItem, modelSchemaRegistry: modelSchemaRegistry, customTypeSchemaRegistry: customTypeSchemaRegistry, modelName: customTypeName ) - ]) + let modelNameMap = ["customTypeName": customTypeName] + deserializedArray.append(dataMap.merging(modelNameMap) { (current, _) in current }) } else { deserializedArray.append(deserializeValue(value: item, fieldType: fieldType)) } @@ -320,15 +320,14 @@ public struct FlutterSerializedModel: Model, ModelIdentifiable, JSONValueHolder customTypeSchemaRegistry: FlutterSchemaRegistry, modelName: String ) throws -> [String: Any] { - return [ - "modelName": modelName, - "serializedData": try FlutterSerializedModel.generateSerializedData( + let dataMap = try FlutterSerializedModel.generateSerializedData( values: values, modelSchemaRegistry: modelSchemaRegistry, customTypeSchemaRegistry: customTypeSchemaRegistry, modelName: modelName ) - ] + let modelNameMap = ["__modelName": modelName] + return dataMap.merging(modelNameMap) { (current, _) in current } } } diff --git a/packages/amplify_datastore/lib/src/method_channel_datastore.dart b/packages/amplify_datastore/lib/src/method_channel_datastore.dart index fe198c47fa..735cc87b3a 100644 --- a/packages/amplify_datastore/lib/src/method_channel_datastore.dart +++ b/packages/amplify_datastore/lib/src/method_channel_datastore.dart @@ -55,7 +55,7 @@ class AmplifyDataStoreMethodChannel extends AmplifyDataStore { Map arguments = (call.arguments as Map).cast(); - final modelName = arguments["modelName"] as String; + final modelName = arguments["__modelName"] as String; final modelType = modelProvider!.getModelTypeByModelName(modelName); ConflictData conflictData = ConflictData.fromJson( @@ -140,9 +140,8 @@ class AmplifyDataStoreMethodChannel extends AmplifyDataStore { throw DataStoreException( AmplifyExceptionMessages.nullReturnedFromMethodChannel); return serializedResults - .map((serializedResult) => modelType.fromJson( - new Map.from( - serializedResult["serializedData"]))) + .map((serializedResult) => modelType + .fromJson(new Map.from(serializedResult))) .toList(); } on PlatformException catch (e) { throw _deserializeException(e); @@ -262,7 +261,7 @@ class AmplifyDataStoreMethodChannel extends AmplifyDataStore { String _getModelNameFromEvent(Map serializedEvent) { Map serializedItem = Map.from(serializedEvent["item"]); - return serializedItem["modelName"] as String; + return serializedItem["__modelName"] as String; } AmplifyException _deserializeExceptionFromMap(Map e) { diff --git a/packages/amplify_datastore/test/amplify_datastore_stream_controller_test.dart b/packages/amplify_datastore/test/amplify_datastore_stream_controller_test.dart index 65403fd0a6..5aaf195416 100644 --- a/packages/amplify_datastore/test/amplify_datastore_stream_controller_test.dart +++ b/packages/amplify_datastore/test/amplify_datastore_stream_controller_test.dart @@ -208,8 +208,8 @@ void main() { sub.cancel(); OutboxMutationEvent payload = events.last.payload as OutboxMutationEvent; - TemporalDateTime parsedDate = TemporalDateTime.fromString( - json["element"]["model"]["serializedData"]["created"]); + TemporalDateTime parsedDate = + TemporalDateTime.fromString(json["element"]["model"]["created"]); expect(events.last, isInstanceOf()); expect(payload.modelName, "Post"); expect(payload.element, isInstanceOf()); @@ -245,8 +245,8 @@ void main() { OutboxMutationEvent payload = events.last.payload as OutboxMutationEvent; HubEventElementWithMetadata element = payload.element as HubEventElementWithMetadata; - TemporalDateTime parsedDate = TemporalDateTime.fromString( - json["element"]["model"]["serializedData"]["created"]); + TemporalDateTime parsedDate = + TemporalDateTime.fromString(json["element"]["model"]["created"]); expect(events.last, isInstanceOf()); expect(payload.modelName, "Post"); expect(element, isInstanceOf()); diff --git a/packages/amplify_datastore/test/resources/hub/outboxMutationEnqueuedEvent.json b/packages/amplify_datastore/test/resources/hub/outboxMutationEnqueuedEvent.json index e20be659d1..3e680b6edd 100644 --- a/packages/amplify_datastore/test/resources/hub/outboxMutationEnqueuedEvent.json +++ b/packages/amplify_datastore/test/resources/hub/outboxMutationEnqueuedEvent.json @@ -1,15 +1,13 @@ { - "eventName": "outboxMutationEnqueued", - "modelName": "Post", - "element": { - "model": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "serializedData": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "title": "Title 1", - "rating": 5, - "created": "2020-02-20T20:20:20-08:00" - } - } + "eventName": "outboxMutationEnqueued", + "modelName": "Post", + "element": { + "model": { + "__modelName": "Post", + "id": "43036c6b-8044-4309-bddc-262b6c686026", + "title": "Title 1", + "rating": 5, + "created": "2020-02-20T20:20:20-08:00" } -} \ No newline at end of file + } +} diff --git a/packages/amplify_datastore/test/resources/hub/outboxMutationProcessedEvent.json b/packages/amplify_datastore/test/resources/hub/outboxMutationProcessedEvent.json index f8f7419de4..d53fb1a6a1 100644 --- a/packages/amplify_datastore/test/resources/hub/outboxMutationProcessedEvent.json +++ b/packages/amplify_datastore/test/resources/hub/outboxMutationProcessedEvent.json @@ -1,21 +1,18 @@ { - "eventName": "outboxMutationProcessed", - "modelName": "Post", - "element": { - "syncMetadata": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "_lastChangedAt": 1624492860, - "_deleted": false, - "_version": 1 - }, - "model": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "serializedData": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "title": "Title 1", - "rating": 5, - "created": "2020-02-20T20:20:20-08:00" - } - } + "eventName": "outboxMutationProcessed", + "modelName": "Post", + "element": { + "syncMetadata": { + "id": "43036c6b-8044-4309-bddc-262b6c686026", + "_lastChangedAt": 1624492860, + "_deleted": false, + "_version": 1 + }, + "model": { + "id": "43036c6b-8044-4309-bddc-262b6c686026", + "title": "Title 1", + "rating": 5, + "created": "2020-02-20T20:20:20-08:00" } -} \ No newline at end of file + } +} diff --git a/packages/amplify_datastore/test/resources/model_schema/serialized_model_maps.json b/packages/amplify_datastore/test/resources/model_schema/serialized_model_maps.json index 1bc7838786..f38c49ef5e 100644 --- a/packages/amplify_datastore/test/resources/model_schema/serialized_model_maps.json +++ b/packages/amplify_datastore/test/resources/model_schema/serialized_model_maps.json @@ -1,100 +1,78 @@ { - "BlogSerializedMap" : { - "modelName" : "Blog", - "serializedData" : { - "id" : "999", - "name" : "blog name" - } + "BlogSerializedMap": { + "__modelName": "Blog", + "id": "999", + "name": "blog name" }, - "CommentSerializedMap" : { - "modelName" : "Comment", - "serializedData" : { - "id" : "999", - "post" : { - "id": "555" - }, - "content" : "content" - } + "CommentSerializedMap": { + "__modelName": "Comment", + "id": "999", + "post": { + "id": "555" + }, + "content": "content" }, - "PostSerializedMap" : { - "modelName" : "Post", - "serializedData" : { - "id" : "999", - "title" : "post title", - "created" : "2020-11-25T01:28:49.000Z", - "blog" : { - "id" : "555" - } + "PostSerializedMap": { + "__modelName": "Post", + "id": "999", + "title": "post title", + "created": "2020-11-25T01:28:49.000Z", + "blog": { + "id": "555" } }, - "AllTypeModelSerializedMap" : { - "modelName" : "AllTypeModel", - "serializedData" : { - "id" : "999", - "stringType" : "string value", - "intType" : 10, - "floatType" : 9.99, - "boolType" : true, - "dateType" : "2020-09-09", - "dateTimeType" : "2020-11-25T01:28:49.000Z", - "timeType" : "20:20:20:020", - "timestampType" : 999, - "enumType" : "maybe" - } + "AllTypeModelSerializedMap": { + "__modelName": "AllTypeModel", + "id": "999", + "stringType": "string value", + "intType": 10, + "floatType": 9.99, + "boolType": true, + "dateType": "2020-09-09", + "dateTimeType": "2020-11-25T01:28:49.000Z", + "timeType": "20:20:20:020", + "timestampType": 999, + "enumType": "maybe" }, "PersonModelSerializedMap": { - "modelName": "Person", - "serializedData": { - "id": "123", - "name": "Tester Testing", - "contact": { - "customTypeName": "Contact", - "serializedData": { - "email": "test@testing.com", - "phone": { - "customTypeName": "Phone", - "serializedData": { - "country": "+1", - "area": "415", - "number": "6666666" - } - }, - "mailingAddresses": [ - { - "customTypeName": "Address", - "serializedData": { - "line1": "000 Somewhere far", - "line2": "apt 4", - "city": "San Francisco", - "state": "CA", - "postalCode": "94115" - } - }, - { - "customTypeName": "Address", - "serializedData": { - "line1": "111 Somewhere close", - "line2": null, - "city": "Seattle", - "state": "WA", - "postalCode": "98101" - } - } - ] - } + "__modelName": "Person", + "id": "123", + "name": "Tester Testing", + "contact": { + "customTypeName": "Contact", + "email": "test@testing.com", + "phone": { + "customTypeName": "Phone", + "country": "+1", + "area": "415", + "number": "6666666" }, - "propertiesAddresses": [ + "mailingAddresses": [ + { + "customTypeName": "Address", + "line1": "000 Somewhere far", + "line2": "apt 4", + "city": "San Francisco", + "state": "CA", + "postalCode": "94115" + }, { "customTypeName": "Address", - "serializedData": { - "line1": "222 Somewhere in the middle", - "line2": null, - "city": "Portland", - "state": "OR", - "postalCode": "97035" - } + "line1": "111 Somewhere close", + "city": "Seattle", + "state": "WA", + "postalCode": "98101" } ] - } + }, + "propertiesAddresses": [ + { + "customTypeName": "Address", + "line1": "222 Somewhere in the middle", + "city": "Portland", + "state": "OR", + "postalCode": "97035" + } + ] } } diff --git a/packages/amplify_datastore/test/resources/observe_api/blog_type_success_event.json b/packages/amplify_datastore/test/resources/observe_api/blog_type_success_event.json index be39bb8c3f..7d63522c15 100644 --- a/packages/amplify_datastore/test/resources/observe_api/blog_type_success_event.json +++ b/packages/amplify_datastore/test/resources/observe_api/blog_type_success_event.json @@ -1,11 +1,9 @@ { "eventType": "create", "item": { - "modelName": "Blog", - "serializedData": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "title": "Title 2", - "created": "2020-02-20T20:20:20-08:00" - } + "__modelName": "Blog", + "id": "43036c6b-8044-4309-bddc-262b6c686026", + "title": "Title 2", + "created": "2020-02-20T20:20:20-08:00" } } diff --git a/packages/amplify_datastore/test/resources/observe_api/post_type_success_event.json b/packages/amplify_datastore/test/resources/observe_api/post_type_success_event.json index dca16413e9..b3c90cd7f3 100644 --- a/packages/amplify_datastore/test/resources/observe_api/post_type_success_event.json +++ b/packages/amplify_datastore/test/resources/observe_api/post_type_success_event.json @@ -1,12 +1,10 @@ { "eventType": "create", "item": { - "modelName": "Post", - "serializedData": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "title": "Title 2", - "created": "2020-02-20T20:20:20-08:00", - "rating": 0 - } + "__modelName": "Post", + "id": "43036c6b-8044-4309-bddc-262b6c686026", + "title": "Title 2", + "created": "2020-02-20T20:20:20-08:00", + "rating": 0 } } diff --git a/packages/amplify_datastore/test/resources/query_api/response/2_results.json b/packages/amplify_datastore/test/resources/query_api/response/2_results.json index 56aa336958..42c40babee 100644 --- a/packages/amplify_datastore/test/resources/query_api/response/2_results.json +++ b/packages/amplify_datastore/test/resources/query_api/response/2_results.json @@ -1,20 +1,16 @@ [ { - "modelName": "Post", - "serializedData": { - "id": "4281dfba-96c8-4a38-9a8e-35c7e893ea47", - "title": "Title 1", - "rating": 4, - "created": "2020-02-20T20:20:20+03:50" - } + "__modelName": "Post", + "id": "4281dfba-96c8-4a38-9a8e-35c7e893ea47", + "title": "Title 1", + "rating": 4, + "created": "2020-02-20T20:20:20+03:50" }, { - "modelName": "Post", - "serializedData": { - "id": "43036c6b-8044-4309-bddc-262b6c686026", - "title": "Title 2", - "rating": 6, - "created": "2020-02-20T20:20:20-08:00" - } + "__modelName": "Post", + "id": "43036c6b-8044-4309-bddc-262b6c686026", + "title": "Title 2", + "rating": 6, + "created": "2020-02-20T20:20:20-08:00" } ] diff --git a/packages/amplify_datastore/test/resources/query_api/response/nested_results.json b/packages/amplify_datastore/test/resources/query_api/response/nested_results.json index 13ed7070d1..476be5037a 100644 --- a/packages/amplify_datastore/test/resources/query_api/response/nested_results.json +++ b/packages/amplify_datastore/test/resources/query_api/response/nested_results.json @@ -1,19 +1,14 @@ [ { - "modelName" : "Comment", - "serializedData" : { - "id" : "39c3c0e6-8726-436e-8cdf-bff38e9a62da", - "post" : { - "id" : "e50ffa8f-783b-4780-89b4-27043ffc35be", - "modelName" : "", - "serializedData" : { - "id" : "e50ffa8f-783b-4780-89b4-27043ffc35be", - "title" : "some title", - "rating" : 10, - "created" : "2020-11-25T01:28:49.000Z" - } - }, - "content" : "Loving Amplify Datastore!" - } + "__modelName": "Comment", + "id": "39c3c0e6-8726-436e-8cdf-bff38e9a62da", + "post": { + "__modelName": "", + "id": "e50ffa8f-783b-4780-89b4-27043ffc35be", + "title": "some title", + "rating": 10, + "created": "2020-11-25T01:28:49.000Z" + }, + "content": "Loving Amplify Datastore!" } -] \ No newline at end of file +] diff --git a/packages/api/amplify_api/example/ios/Podfile b/packages/api/amplify_api/example/ios/Podfile index 10f3c9b470..bfbfcc742d 100644 --- a/packages/api/amplify_api/example/ios/Podfile +++ b/packages/api/amplify_api/example/ios/Podfile @@ -37,5 +37,9 @@ end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) + # Workaround for: https://github.com/flutter/flutter/issues/126449 + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' + end end end diff --git a/packages/api/amplify_api/example/lib/models/Blog.dart b/packages/api/amplify_api/example/lib/models/Blog.dart index 12e4a09b86..0c69c66f89 100644 --- a/packages/api/amplify_api/example/lib/models/Blog.dart +++ b/packages/api/amplify_api/example/lib/models/Blog.dart @@ -132,13 +132,20 @@ class Blog extends amplify_core.Model { Blog.fromJson(Map json) : id = json['id'], _name = json['name'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Post.fromJson( - new Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => Post.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Post.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/api/amplify_api/example/lib/models/Comment.dart b/packages/api/amplify_api/example/lib/models/Comment.dart index 113f9d9cab..2d4c68cce0 100644 --- a/packages/api/amplify_api/example/lib/models/Comment.dart +++ b/packages/api/amplify_api/example/lib/models/Comment.dart @@ -131,9 +131,11 @@ class Comment extends amplify_core.Model { Comment.fromJson(Map json) : id = json['id'], - _post = json['post']?['serializedData'] != null - ? Post.fromJson( - new Map.from(json['post']['serializedData'])) + _post = json['post'] != null + ? json['post']['serializedData'] != null + ? Post.fromJson(new Map.from( + json['post']['serializedData'])) + : Post.fromJson(new Map.from(json['post'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart index 026ea05e28..86d82e2bf3 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildExplicitCD.dart @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildExplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildExplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart index 06300d363a..ca34290768 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalChildImplicitCD.dart @@ -153,10 +153,13 @@ class CpkOneToOneBidirectionalChildImplicitCD extends amplify_core.Model { CpkOneToOneBidirectionalChildImplicitCD.fromJson(Map json) : id = json['id'], _name = json['name'], - _belongsToParent = json['belongsToParent']?['serializedData'] != null - ? CpkOneToOneBidirectionalParentCD.fromJson( - new Map.from( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart index 8965b67dac..854fd558e6 100644 --- a/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart +++ b/packages/api/amplify_api/example/lib/models/CpkOneToOneBidirectionalParentCD.dart @@ -283,15 +283,21 @@ class CpkOneToOneBidirectionalParentCD extends amplify_core.Model { CpkOneToOneBidirectionalParentCD.fromJson(Map json) : _customId = json['customId'], _name = json['name'], - _implicitChild = json['implicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( - new Map.from( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from(json['implicitChild'])) : null, - _explicitChild = json['explicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( - new Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) diff --git a/packages/api/amplify_api/example/lib/models/Post.dart b/packages/api/amplify_api/example/lib/models/Post.dart index 31b1247f4c..2b2a70b17e 100644 --- a/packages/api/amplify_api/example/lib/models/Post.dart +++ b/packages/api/amplify_api/example/lib/models/Post.dart @@ -183,17 +183,27 @@ class Post extends amplify_core.Model { : id = json['id'], _title = json['title'], _rating = (json['rating'] as num?)?.toInt(), - _blog = json['blog']?['serializedData'] != null - ? Blog.fromJson( - new Map.from(json['blog']['serializedData'])) - : null, - _comments = json['comments'] is List - ? (json['comments'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Comment.fromJson( - new Map.from(e['serializedData']))) - .toList() + _blog = json['blog'] != null + ? json['blog']['serializedData'] != null + ? Blog.fromJson(new Map.from( + json['blog']['serializedData'])) + : Blog.fromJson(new Map.from(json['blog'])) : null, + _comments = json['comments'] is Map + ? (json['comments']['items'] is List + ? (json['comments']['items'] as List) + .where((e) => e != null) + .map((e) => + Comment.fromJson(new Map.from(e))) + .toList() + : null) + : (json['comments'] is List + ? (json['comments'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Comment.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, diff --git a/packages/api/amplify_api_dart/lib/src/graphql/helpers/graphql_response_decoder.dart b/packages/api/amplify_api_dart/lib/src/graphql/helpers/graphql_response_decoder.dart index 538a8ba855..9b4cfe063a 100644 --- a/packages/api/amplify_api_dart/lib/src/graphql/helpers/graphql_response_decoder.dart +++ b/packages/api/amplify_api_dart/lib/src/graphql/helpers/graphql_response_decoder.dart @@ -5,7 +5,6 @@ import 'dart:convert'; -import 'package:amplify_api_dart/src/graphql/utils.dart'; import 'package:amplify_core/amplify_core.dart'; const _nextToken = 'nextToken'; @@ -76,12 +75,7 @@ class GraphQLResponseDecoder { // Found a JSON object to represent the model, parse it using model's fromJSON. T decodedData; - final modelSchema = getModelSchemaByModelName(modelType.modelName(), null); - dataJson = transformAppSyncJsonToModelJson( - dataJson!, - modelSchema, - isPaginated: modelType is PaginatedModelType, - ); + if (modelType is PaginatedModelType) { final filter = request.variables['filter'] as Map?; final limit = request.variables['limit'] as int?; diff --git a/packages/api/amplify_api_dart/lib/src/graphql/utils.dart b/packages/api/amplify_api_dart/lib/src/graphql/utils.dart index e8db5b07d1..965cf3456b 100644 --- a/packages/api/amplify_api_dart/lib/src/graphql/utils.dart +++ b/packages/api/amplify_api_dart/lib/src/graphql/utils.dart @@ -3,8 +3,6 @@ import 'package:amplify_core/amplify_core.dart'; -const _serializedData = 'serializedData'; - /// "items", the key name for nested data in AppSync const items = 'items'; @@ -101,86 +99,3 @@ ModelSchema getModelSchemaByModelName( return schema; } - -/// Transform the JSON from AppSync so it matches the fromJson in codegen models. -/// 1) Look for a parent in the schema. If that parent exists in the JSON, transform it. -/// 2) Look for list of children under [fieldName]["items"] and hoist up so no more ["items"]. -Map transformAppSyncJsonToModelJson( - Map input, - ModelSchema modelSchema, { - bool isPaginated = false, -}) { - input = {...input}; // avoid mutating original - - // check for list at top-level and transform each entry - if (isPaginated && input[items] is List) { - final transformedItems = (input[items] as List) - .map( - (dynamic e) => e != null - ? transformAppSyncJsonToModelJson( - e as Map, - modelSchema, - ) - : null, - ) - .toList(); - input.update(items, (dynamic value) => transformedItems); - return input; - } - - final relatedFields = _getRelatedFields(modelSchema); - - // transform parents/hasOne recursively - for (final parentField in relatedFields.singleFields) { - final ofModelName = - parentField.type.ofModelName ?? parentField.type.ofCustomTypeName; - final inputValue = input[parentField.name]; - if ((inputValue is Map || inputValue is List) && ofModelName != null) { - final parentSchema = getModelSchemaByModelName(ofModelName, null); - input.update(parentField.name, (dynamic parentData) { - if (parentData is List) { - // only used for embeddedCollection - return parentData - .map( - (dynamic e) => { - _serializedData: transformAppSyncJsonToModelJson( - e as Map, - parentSchema, - ), - }, - ) - .toList(); - } - return { - _serializedData: transformAppSyncJsonToModelJson( - parentData as Map, - parentSchema, - ), - }; - }); - } - } - - // transform children recursively - for (final childField in relatedFields.hasManyFields) { - final ofModelName = childField.type.ofModelName; - final inputValue = input[childField.name]; - final inputItems = (inputValue is Map) ? inputValue[items] as List? : null; - if (inputItems is List && ofModelName != null) { - final childSchema = getModelSchemaByModelName(ofModelName, null); - final transformedItems = inputItems - .map( - (dynamic item) => { - _serializedData: transformAppSyncJsonToModelJson( - item as Map, - childSchema, - ), - }, - ) - .toList(); - input.update(childField.name, (dynamic value) => transformedItems); - } - } - - return input; -} diff --git a/packages/api/amplify_api_dart/test/graphql_helpers_test.dart b/packages/api/amplify_api_dart/test/graphql_helpers_test.dart index 64e286d174..497ef3fa1a 100644 --- a/packages/api/amplify_api_dart/test/graphql_helpers_test.dart +++ b/packages/api/amplify_api_dart/test/graphql_helpers_test.dart @@ -5,7 +5,6 @@ import 'dart:convert'; import 'package:amplify_api_dart/amplify_api_dart.dart'; import 'package:amplify_api_dart/src/graphql/helpers/graphql_response_decoder.dart'; -import 'package:amplify_api_dart/src/graphql/utils.dart'; import 'package:amplify_core/amplify_core.dart'; import 'package:test/test.dart'; @@ -890,207 +889,6 @@ void main() { ); }); }); - - group('transformAppSyncJsonToModelJson', () { - test('should be no-op for flat JSON with no parents/children', () { - final input = {'id': 'abc123', 'name': 'Lorem Ipsum'}; - final output = transformAppSyncJsonToModelJson(input, Blog.schema); - expect(input, output); - }); - - test('should be no-op for flat JSON with null parent/children', () { - final blogInput = { - 'id': 'abc123', - 'name': 'Lorem Ipsum', - 'posts': null, - }; - final blogOutput = - transformAppSyncJsonToModelJson(blogInput, Blog.schema); - expect(blogInput, blogOutput); - - final postInput = { - 'id': 'abc123', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'comments': null, - 'blog': null, - }; - final postOutput = - transformAppSyncJsonToModelJson(postInput, Post.schema); - expect(postInput, postOutput); - }); - - test('should translate children to expected format', () { - final input = { - 'id': 'abc123', - 'name': 'Lorem Ipsum', - 'posts': { - 'items': [ - {'id': 'xyz456', 'rating': 0, 'title': 'Lorem ipsum'}, - ], - }, - }; - final expectedOutput = { - 'id': 'abc123', - 'name': 'Lorem Ipsum', - 'posts': [ - { - 'serializedData': { - 'id': 'xyz456', - 'rating': 0, - 'title': 'Lorem ipsum', - }, - } - ], - }; - final output = transformAppSyncJsonToModelJson(input, Blog.schema); - expect(output, expectedOutput); - }); - - test('should translate parents and children to expected format', () { - final input = { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'comments': { - 'items': [ - {'id': 'def456', 'content': 'Worst... post... ever!'}, - ], - }, - 'blog': {'id': 'abc123', 'title': 'blog about life'}, - }; - final expectedOutput = { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'comments': [ - { - 'serializedData': { - 'id': 'def456', - 'content': 'Worst... post... ever!', - }, - } - ], - 'blog': { - 'serializedData': {'id': 'abc123', 'title': 'blog about life'}, - }, - }; - final output = transformAppSyncJsonToModelJson(input, Post.schema); - expect(output, expectedOutput); - }); - - test('should translate list to expected format', () { - final input = { - 'items': [ - { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'blog': {'id': 'abc123', 'title': 'blog about life'}, - }, - { - 'id': 'lmn456', - 'title': 'Lorem Ipsum better', - 'rating': 0, - 'blog': {'id': 'abc123', 'title': 'blog about life'}, - } - ], - }; - final expectedOutput = { - 'items': [ - { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'blog': { - 'serializedData': {'id': 'abc123', 'title': 'blog about life'}, - }, - }, - { - 'id': 'lmn456', - 'title': 'Lorem Ipsum better', - 'rating': 0, - 'blog': { - 'serializedData': {'id': 'abc123', 'title': 'blog about life'}, - }, - } - ], - }; - final output = transformAppSyncJsonToModelJson( - input, - Post.schema, - isPaginated: true, - ); - expect(output, expectedOutput); - }); - - test('should translate list with a null entry to expected format', () { - final input = { - 'items': [ - { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'blog': {'id': 'abc123', 'title': 'blog about life'}, - }, - null, - ], - }; - final expectedOutput = { - 'items': [ - { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'blog': { - 'serializedData': {'id': 'abc123', 'title': 'blog about life'}, - }, - }, - null, - ], - }; - final output = transformAppSyncJsonToModelJson( - input, - Post.schema, - isPaginated: true, - ); - expect(output, expectedOutput); - }); - - test('should result in no-op if wrong schema provided', () { - final input = { - 'id': 'xyz456', - 'title': 'Lorem Ipsum', - 'rating': 0, - 'comments': { - 'items': [ - {'id': 'def456', 'content': 'Worst... post... ever!'}, - ], - }, - 'blog': {'id': 'abc123', 'title': 'blog about life'}, - }; - final output = transformAppSyncJsonToModelJson(input, Comment.schema); - expect(output, input); - }); - - test('should translate custom type model', () { - final input = { - 'id': 'xyz456', - 'customTypeValue': {'stringValue': 'abc123'}, - }; - final expectedOutput = { - 'id': 'xyz456', - 'customTypeValue': { - 'serializedData': {'stringValue': 'abc123'}, - }, - }; - final output = transformAppSyncJsonToModelJson( - input, - ModelWithCustomType.schema, - ); - expect(output, expectedOutput); - }); - }); }); group('without ModelProvider', () { diff --git a/packages/api/amplify_api_dart/test/graphql_test.dart b/packages/api/amplify_api_dart/test/graphql_test.dart index aa3e567536..a7f7dbdd15 100644 --- a/packages/api/amplify_api_dart/test/graphql_test.dart +++ b/packages/api/amplify_api_dart/test/graphql_test.dart @@ -692,4 +692,148 @@ void main() { ); }); }); + + group('Model fromJson()', () { + final mockBlogJson = Map.from({ + 'id': '2219c0fe-5243-48ec-8449-b3a2c8fbd3f5', + 'name': 'Example Blog - 7dc976d7-53a0-47e7-8617-3e62ccebc9e9', + }); + final mockPostJson = Map.from({ + 'id': '3bb89c75-22a9-4ee6-94b0-2fc0a20f01a4', + 'title': 'Example Post - ee824e31-e85d-4faf-97a0-f00649b32599', + 'rating': 3, + 'createdAt': '2024-04-04T15:06:30.203Z', + 'updatedAt': '2024-04-04T15:06:30.203Z', + }); + final mockCommentsJson = List>.from([ + { + 'content': 'Example Comment - fbc844fa-6ef4-4594-a2ed-9d124275ed30', + 'id': '288d2f5d-39fa-4d70-8fd9-467a4dee9d41', + }, + { + 'content': 'Example Comment - c09ed2ea-1d9b-4bff-baf4-f19d806338ee', + 'id': '84908a82-826a-45d3-978c-0842ad26a493', + }, + { + 'content': 'Example Comment - f83339ee-0845-4930-be08-bd592ef29321', + 'id': '3cebd81c-fb26-4adc-996a-b869ff83fa8b', + }, + { + 'content': 'Example Comment - 6fc3b904-b977-4256-96a9-43221d01d046', + 'id': 'cac2e916-3fc9-4842-8ba6-ce58e59f163c', + } + ]); + final appsyncResponse = Map.from({ + ...mockPostJson, + 'comments': { + 'items': mockCommentsJson, + }, + 'blog': mockBlogJson, + }); + final appsyncSerializedResponse = Map.from({ + ...mockPostJson, + 'comments': [ + { + 'serializedData': mockCommentsJson[0], + }, + { + 'serializedData': mockCommentsJson[1], + }, + { + 'serializedData': mockCommentsJson[2], + }, + { + 'serializedData': mockCommentsJson[3], + }, + ], + 'blog': {'serializedData': mockBlogJson}, + }); + final nullResponse = Map.from({ + ...mockPostJson, + 'comments': null, + 'blog': null, + }); + + final malformedResponse = Map.from({ + ...mockPostJson, + 'comments': 'foo', + 'blog': null, + }); + + test('should work with nested models V2', () async { + final post = Post.fromJson(appsyncResponse); + + expect( + post.id, + mockPostJson['id'], + ); + expect( + post.blog?.name, + mockBlogJson['name'], + ); + expect( + post.comments?.length, + mockCommentsJson.length, + ); + expect( + post.comments?[0].content, + mockCommentsJson[0]['content'], + ); + }); + + test('should work with nested models V1', () async { + final post = Post.fromJson(appsyncSerializedResponse); + + expect( + post.id, + mockPostJson['id'], + ); + expect( + post.blog?.name, + mockBlogJson['name'], + ); + expect( + post.comments?.length, + mockCommentsJson.length, + ); + expect( + post.comments?[0].content, + mockCommentsJson[0]['content'], + ); + }); + + test('should work with null nested models', () async { + final post = Post.fromJson(nullResponse); + + expect( + post.id, + mockPostJson['id'], + ); + expect( + post.blog, + isNull, + ); + expect( + post.comments, + isNull, + ); + }); + + test('should gracefully handle wrong types', () async { + final post = Post.fromJson(malformedResponse); + + expect( + post.id, + mockPostJson['id'], + ); + expect( + post.blog, + isNull, + ); + expect( + post.comments, + isNull, + ); + }); + }); } diff --git a/packages/api/amplify_api_dart/test/test_models/Blog.dart b/packages/api/amplify_api_dart/test/test_models/Blog.dart index d033bae013..d44cda2f11 100644 --- a/packages/api/amplify_api_dart/test/test_models/Blog.dart +++ b/packages/api/amplify_api_dart/test/test_models/Blog.dart @@ -1,27 +1,36 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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; +import 'package:collection/collection.dart'; -/// This is an auto generated class representing the Blog type in your schema. -@immutable -class Blog extends Model { - static const classType = _BlogModelType(); +/** This is an auto generated class representing the Blog type in your schema. */ +class Blog extends amplify_core.Model { + static const classType = const _BlogModelType(); final String id; final String? _name; final List? _posts; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -39,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()); } @@ -52,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; } @@ -69,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); } @@ -92,7 +101,7 @@ class Blog extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Blog {"); buffer.write("id=" + "$id" + ", "); @@ -112,21 +121,36 @@ 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'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Post.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => Post.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Post.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), _createdAt = json['createdAt'] != null - ? 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() => { @@ -137,62 +161,83 @@ class Blog extends Model { 'updatedAt': _updatedAt?.format() }; - 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( + Map toMap() => { + 'id': id, + 'name': _name, + 'posts': _posts, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final POSTS = amplify_core.QueryField( fieldName: "posts", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, - ofModelName: (Post).toString())); - 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.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).toString(), + 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 Blog fromJson(Map jsonData) { return Blog.fromJson(jsonData); } + + @override + String modelName() { + return 'Blog'; + } } -/// 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_dart/test/test_models/Comment.dart b/packages/api/amplify_api_dart/test/test_models/Comment.dart index 555dab139f..6236a3d272 100644 --- a/packages/api/amplify_api_dart/test/test_models/Comment.dart +++ b/packages/api/amplify_api_dart/test/test_models/Comment.dart @@ -1,26 +1,35 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 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; @@ -42,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; } @@ -68,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) { @@ -89,7 +100,7 @@ class Comment extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Comment {"); buffer.write("id=" + "$id" + ", "); @@ -110,18 +121,28 @@ 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'])) + _post = json['post'] != null + ? json['post']['serializedData'] != null + ? Post.fromJson(new Map.from( + json['post']['serializedData'])) + : Post.fromJson(new Map.from(json['post'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null - ? 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() => { @@ -132,66 +153,88 @@ class Comment extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField POST = QueryField( + Map toMap() => { + 'id': id, + 'post': _post, + 'content': _content, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + 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).toString())); - 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.indexes = [ - ModelIndex(fields: const ["postID", "content"], name: "byPost") + amplify_core.ModelIndex( + fields: const ["postID", "content"], 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).toString())); + 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 Comment fromJson(Map jsonData) { return Comment.fromJson(jsonData); } + + @override + String modelName() { + return 'Comment'; + } } -/// 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_dart/test/test_models/CpkIntIndexes.dart b/packages/api/amplify_api_dart/test/test_models/CpkIntIndexes.dart index f86500e4cb..65f2fe5667 100644 --- a/packages/api/amplify_api_dart/test/test_models/CpkIntIndexes.dart +++ b/packages/api/amplify_api_dart/test/test_models/CpkIntIndexes.dart @@ -1,26 +1,35 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 CPKIntIndexes type in your schema. */ -@immutable -class CpkIntIndexes extends Model { +/** This is an auto generated class representing the CpkIntIndexes type in your schema. */ +class CpkIntIndexes extends amplify_core.Model { static const classType = const _CpkIntIndexesModelType(); final String? _name; final int? _fieldA; final int? _fieldB; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -35,10 +44,10 @@ class CpkIntIndexes extends Model { return CpkIntIndexesModelIdentifier( name: _name!, fieldA: _fieldA!, fieldB: _fieldB!); } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -48,10 +57,10 @@ class CpkIntIndexes extends Model { try { return _name!; } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -61,10 +70,10 @@ class CpkIntIndexes extends Model { try { return _fieldA!; } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -74,20 +83,20 @@ class CpkIntIndexes extends Model { try { return _fieldB!; } catch (e) { - throw new 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; } @@ -144,15 +153,19 @@ class CpkIntIndexes extends Model { return CpkIntIndexes._internal(name: name, fieldA: fieldA, fieldB: fieldB); } + CpkIntIndexes copyWithModelFieldValues() { + return CpkIntIndexes._internal(name: name, fieldA: fieldA, fieldB: fieldB); + } + CpkIntIndexes.fromJson(Map json) : _name = json['name'], _fieldA = (json['fieldA'] as num?)?.toInt(), _fieldB = (json['fieldB'] as num?)?.toInt(), _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() => { @@ -171,64 +184,73 @@ class CpkIntIndexes extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier - MODEL_IDENTIFIER = QueryModelIdentifier(); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField FIELDA = QueryField(fieldName: "fieldA"); - static final QueryField FIELDB = QueryField(fieldName: "fieldB"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final FIELDA = amplify_core.QueryField(fieldName: "fieldA"); + static final FIELDB = amplify_core.QueryField(fieldName: "fieldB"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkIntIndexes"; modelSchemaDefinition.pluralName = "CpkIntIndexes"; 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.indexes = [ - ModelIndex(fields: const ["name", "fieldA", "fieldB"], name: null) + amplify_core.ModelIndex( + fields: const ["name", "fieldA", "fieldB"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkIntIndexes.NAME, 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: CpkIntIndexes.FIELDA, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkIntIndexes.FIELDB, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); - - 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.int))); + + 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 _CpkIntIndexesModelType extends ModelType { +class _CpkIntIndexesModelType extends amplify_core.ModelType { const _CpkIntIndexesModelType(); @override @@ -246,8 +268,8 @@ class _CpkIntIndexesModelType extends ModelType { * This is an auto generated class representing the model identifier * of [CpkIntIndexes] in your schema. */ -@immutable -class CpkIntIndexesModelIdentifier implements ModelIdentifier { +class CpkIntIndexesModelIdentifier + implements amplify_core.ModelIdentifier { final String name; final int fieldA; final int fieldB; diff --git a/packages/api/amplify_api_dart/test/test_models/CpkIntPrimaryKey.dart b/packages/api/amplify_api_dart/test/test_models/CpkIntPrimaryKey.dart index ac5385dadf..ffb150eea1 100644 --- a/packages/api/amplify_api_dart/test/test_models/CpkIntPrimaryKey.dart +++ b/packages/api/amplify_api_dart/test/test_models/CpkIntPrimaryKey.dart @@ -1,26 +1,35 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 CPKIntPrimaryKey type in your schema. */ -@immutable -class CpkIntPrimaryKey extends Model { +/** This is an auto generated class representing the CpkIntPrimaryKey type in your schema. */ +class CpkIntPrimaryKey extends amplify_core.Model { static const classType = const _CpkIntPrimaryKeyModelType(); final int? _intAsId; final int? _fieldA; final int? _fieldB; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -35,10 +44,10 @@ class CpkIntPrimaryKey extends Model { return CpkIntPrimaryKeyModelIdentifier( intAsId: _intAsId!, fieldA: _fieldA!, fieldB: _fieldB!); } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -48,10 +57,10 @@ class CpkIntPrimaryKey extends Model { try { return _intAsId!; } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -61,10 +70,10 @@ class CpkIntPrimaryKey extends Model { try { return _fieldA!; } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -74,20 +83,20 @@ class CpkIntPrimaryKey extends Model { try { return _fieldB!; } catch (e) { - throw new 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; } @@ -151,15 +160,20 @@ class CpkIntPrimaryKey extends Model { intAsId: intAsId, fieldA: fieldA, fieldB: fieldB); } + CpkIntPrimaryKey copyWithModelFieldValues() { + return CpkIntPrimaryKey._internal( + intAsId: intAsId, fieldA: fieldA, fieldB: fieldB); + } + CpkIntPrimaryKey.fromJson(Map json) : _intAsId = (json['intAsId'] as num?)?.toInt(), _fieldA = (json['fieldA'] as num?)?.toInt(), _fieldB = (json['fieldB'] as num?)?.toInt(), _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() => { @@ -178,65 +192,74 @@ class CpkIntPrimaryKey extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier - MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField INTASID = QueryField(fieldName: "intAsId"); - static final QueryField FIELDA = QueryField(fieldName: "fieldA"); - static final QueryField FIELDB = QueryField(fieldName: "fieldB"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static final amplify_core + .QueryModelIdentifier MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final INTASID = amplify_core.QueryField(fieldName: "intAsId"); + static final FIELDA = amplify_core.QueryField(fieldName: "fieldA"); + static final FIELDB = amplify_core.QueryField(fieldName: "fieldB"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkIntPrimaryKey"; modelSchemaDefinition.pluralName = "CpkIntPrimaryKeys"; 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.indexes = [ - ModelIndex(fields: const ["intAsId", "fieldA", "fieldB"], name: null) + amplify_core.ModelIndex( + fields: const ["intAsId", "fieldA", "fieldB"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkIntPrimaryKey.INTASID, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkIntPrimaryKey.FIELDA, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CpkIntPrimaryKey.FIELDB, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); - - 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.int))); + + 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 _CpkIntPrimaryKeyModelType extends ModelType { +class _CpkIntPrimaryKeyModelType + extends amplify_core.ModelType { const _CpkIntPrimaryKeyModelType(); @override @@ -254,9 +277,8 @@ class _CpkIntPrimaryKeyModelType extends ModelType { * This is an auto generated class representing the model identifier * of [CpkIntPrimaryKey] in your schema. */ -@immutable class CpkIntPrimaryKeyModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final int intAsId; final int fieldA; final int fieldB; diff --git a/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildExplicitCD.dart b/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildExplicitCD.dart index 26485e07f9..a2f2255597 100644 --- a/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildExplicitCD.dart +++ b/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildExplicitCD.dart @@ -1,26 +1,36 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 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; @@ -35,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()); } @@ -48,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()); } @@ -61,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; } @@ -81,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); } @@ -104,7 +114,7 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CpkOneToOneBidirectionalChildExplicitCD {"); buffer.write("id=" + "$id" + ", "); @@ -130,19 +140,32 @@ 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( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null - ? 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() => { @@ -153,55 +176,69 @@ class CpkOneToOneBidirectionalChildExplicitCD extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier< + Map toMap() => { + 'id': id, + 'name': _name, + 'belongsToParent': _belongsToParent, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + 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, - ofModelName: (CpkOneToOneBidirectionalParentCD).toString())); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'CpkOneToOneBidirectionalParentCD')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkOneToOneBidirectionalChildExplicitCD"; modelSchemaDefinition.pluralName = "CpkOneToOneBidirectionalChildExplicitCDS"; 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).toString())); - - 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))); + targetNames: ['belongsToParentID', 'belongsToParentName'], + ofModelName: 'CpkOneToOneBidirectionalParentCD')); + + 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 @@ -209,18 +246,27 @@ class _CpkOneToOneBidirectionalChildExplicitCDModelType Map jsonData) { return CpkOneToOneBidirectionalChildExplicitCD.fromJson(jsonData); } + + @override + String modelName() { + return 'CpkOneToOneBidirectionalChildExplicitCD'; + } } -/// 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_dart/test/test_models/CpkOneToOneBidirectionalChildImplicitCD.dart b/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildImplicitCD.dart index e697eadab1..4bb5a075f2 100644 --- a/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildImplicitCD.dart +++ b/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalChildImplicitCD.dart @@ -1,26 +1,36 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 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; @@ -35,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()); } @@ -48,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()); } @@ -61,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; } @@ -81,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); } @@ -104,7 +114,7 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CpkOneToOneBidirectionalChildImplicitCD {"); buffer.write("id=" + "$id" + ", "); @@ -130,19 +140,32 @@ 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( - json['belongsToParent']['serializedData'])) + _belongsToParent = json['belongsToParent'] != null + ? json['belongsToParent']['serializedData'] != null + ? CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from( + json['belongsToParent']['serializedData'])) + : CpkOneToOneBidirectionalParentCD.fromJson( + new Map.from(json['belongsToParent'])) : null, _createdAt = json['createdAt'] != null - ? 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() => { @@ -153,58 +176,72 @@ class CpkOneToOneBidirectionalChildImplicitCD extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier< + Map toMap() => { + 'id': id, + 'name': _name, + 'belongsToParent': _belongsToParent, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + 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, - ofModelName: (CpkOneToOneBidirectionalParentCD).toString())); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'CpkOneToOneBidirectionalParentCD')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CpkOneToOneBidirectionalChildImplicitCD"; modelSchemaDefinition.pluralName = "CpkOneToOneBidirectionalChildImplicitCDS"; 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: [ - "cpkOneToOneBidirectionalChildImplicitCDBelongsToParentCustomId", - "cpkOneToOneBidirectionalChildImplicitCDBelongsToParentName" + 'cpkOneToOneBidirectionalChildImplicitCDBelongsToParentCustomId', + 'cpkOneToOneBidirectionalChildImplicitCDBelongsToParentName' ], - ofModelName: (CpkOneToOneBidirectionalParentCD).toString())); - - 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))); + ofModelName: 'CpkOneToOneBidirectionalParentCD')); + + 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 @@ -212,18 +249,27 @@ class _CpkOneToOneBidirectionalChildImplicitCDModelType Map jsonData) { return CpkOneToOneBidirectionalChildImplicitCD.fromJson(jsonData); } + + @override + String modelName() { + return 'CpkOneToOneBidirectionalChildImplicitCD'; + } } -/// 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_dart/test/test_models/CpkOneToOneBidirectionalParentCD.dart b/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalParentCD.dart index 620acfd974..077efa2c2a 100644 --- a/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalParentCD.dart +++ b/packages/api/amplify_api_dart/test/test_models/CpkOneToOneBidirectionalParentCD.dart @@ -1,27 +1,36 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 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; @@ -40,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()); } @@ -53,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()); } @@ -66,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()); } @@ -83,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; } @@ -184,7 +193,7 @@ class CpkOneToOneBidirectionalParentCD extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CpkOneToOneBidirectionalParentCD {"); buffer.write("customId=" + "$_customId" + ", "); @@ -237,24 +246,64 @@ 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( - json['implicitChild']['serializedData'])) + _implicitChild = json['implicitChild'] != null + ? json['implicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from( + json['implicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildImplicitCD.fromJson( + new Map.from(json['implicitChild'])) : null, - _explicitChild = json['explicitChild']?['serializedData'] != null - ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( - Map.from( - json['explicitChild']['serializedData'])) + _explicitChild = json['explicitChild'] != null + ? json['explicitChild']['serializedData'] != null + ? CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from( + json['explicitChild']['serializedData'])) + : CpkOneToOneBidirectionalChildExplicitCD.fromJson( + new Map.from(json['explicitChild'])) : null, _createdAt = json['createdAt'] != null - ? 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'], @@ -282,120 +331,160 @@ 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( + Map toMap() => { + 'customId': _customId, + 'name': _name, + 'implicitChild': _implicitChild, + 'explicitChild': _explicitChild, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt, + 'cpkOneToOneBidirectionalParentCDImplicitChildId': + _cpkOneToOneBidirectionalParentCDImplicitChildId, + 'cpkOneToOneBidirectionalParentCDImplicitChildName': + _cpkOneToOneBidirectionalParentCDImplicitChildName, + 'cpkOneToOneBidirectionalParentCDExplicitChildId': + _cpkOneToOneBidirectionalParentCDExplicitChildId, + 'cpkOneToOneBidirectionalParentCDExplicitChildName': + _cpkOneToOneBidirectionalParentCDExplicitChildName + }; + + 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, - ofModelName: (CpkOneToOneBidirectionalChildImplicitCD).toString())); - static final QueryField EXPLICITCHILD = QueryField( + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'CpkOneToOneBidirectionalChildImplicitCD')); + static final EXPLICITCHILD = amplify_core.QueryField( fieldName: "explicitChild", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, - ofModelName: (CpkOneToOneBidirectionalChildExplicitCD).toString())); - static final QueryField CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDID = - QueryField(fieldName: "cpkOneToOneBidirectionalParentCDImplicitChildId"); - static final QueryField CPKONETOONEBIDIRECTIONALPARENTCDIMPLICITCHILDNAME = - QueryField( + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'CpkOneToOneBidirectionalChildExplicitCD')); + 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.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).toString(), + ofModelName: 'CpkOneToOneBidirectionalChildImplicitCD', associatedKey: CpkOneToOneBidirectionalChildImplicitCD.BELONGSTOPARENT)); - modelSchemaDefinition.addField(ModelFieldDefinition.hasOne( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasOne( key: CpkOneToOneBidirectionalParentCD.EXPLICITCHILD, isRequired: false, - ofModelName: (CpkOneToOneBidirectionalChildExplicitCD).toString(), + 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 CpkOneToOneBidirectionalParentCD fromJson(Map jsonData) { return CpkOneToOneBidirectionalParentCD.fromJson(jsonData); } + + @override + String modelName() { + return 'CpkOneToOneBidirectionalParentCD'; + } } -/// 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_dart/test/test_models/CustomOwnerField.dart b/packages/api/amplify_api_dart/test/test_models/CustomOwnerField.dart index 37c8068fc5..599a7c851f 100644 --- a/packages/api/amplify_api_dart/test/test_models/CustomOwnerField.dart +++ b/packages/api/amplify_api_dart/test/test_models/CustomOwnerField.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,20 +19,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 'package:amplify_core/amplify_core.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; /** This is an auto generated class representing the CustomOwnerField type in your schema. */ -@immutable -class CustomOwnerField extends Model { +class CustomOwnerField extends amplify_core.Model { static const classType = const _CustomOwnerFieldModelType(); final String id; final String? _name; final List? _owners; final String? _private; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -38,10 +49,10 @@ class CustomOwnerField extends Model { try { return _name!; } catch (e) { - throw new AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -55,11 +66,11 @@ class CustomOwnerField extends Model { return _private; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -77,7 +88,7 @@ class CustomOwnerField extends Model { List? owners, String? private}) { return CustomOwnerField._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, owners: owners != null ? List.unmodifiable(owners) : owners, private: private); @@ -129,16 +140,27 @@ class CustomOwnerField extends Model { private: private ?? this.private); } + CustomOwnerField copyWithModelFieldValues( + {ModelFieldValue? name, + ModelFieldValue?>? owners, + ModelFieldValue? private}) { + return CustomOwnerField._internal( + id: id, + name: name == null ? this.name : name.value, + owners: owners == null ? this.owners : owners.value, + private: private == null ? this.private : private.value); + } + CustomOwnerField.fromJson(Map json) : id = json['id'], _name = json['name'], _owners = json['owners']?.cast(), _private = json['private'], _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() => { @@ -159,72 +181,82 @@ class CustomOwnerField 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 OWNERS = QueryField(fieldName: "owners"); - static final QueryField PRIVATE = QueryField(fieldName: "private"); - 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 final OWNERS = amplify_core.QueryField(fieldName: "owners"); + static final PRIVATE = amplify_core.QueryField(fieldName: "private"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CustomOwnerField"; modelSchemaDefinition.pluralName = "CustomOwnerFields"; modelSchemaDefinition.authRules = [ - AuthRule(authStrategy: AuthStrategy.PRIVATE, operations: [ - ModelOperation.CREATE, - ModelOperation.UPDATE, - ModelOperation.DELETE, - ModelOperation.READ - ]), - AuthRule( - authStrategy: AuthStrategy.OWNER, + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.PRIVATE, + operations: const [ + amplify_core.ModelOperation.CREATE, + amplify_core.ModelOperation.UPDATE, + amplify_core.ModelOperation.DELETE, + amplify_core.ModelOperation.READ + ]), + amplify_core.AuthRule( + authStrategy: amplify_core.AuthStrategy.OWNER, ownerField: "owners", 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: CustomOwnerField.NAME, 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: CustomOwnerField.OWNERS, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: CustomOwnerField.PRIVATE, isRequired: false, - 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 _CustomOwnerFieldModelType extends ModelType { +class _CustomOwnerFieldModelType + extends amplify_core.ModelType { const _CustomOwnerFieldModelType(); @override @@ -242,9 +274,8 @@ class _CustomOwnerFieldModelType extends ModelType { * This is an auto generated class representing the model identifier * of [CustomOwnerField] in your schema. */ -@immutable class CustomOwnerFieldModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; /** Create an instance of CustomOwnerFieldModelIdentifier using [id] the primary key. */ diff --git a/packages/api/amplify_api_dart/test/test_models/CustomTypeWithAppsyncScalarTypes.dart b/packages/api/amplify_api_dart/test/test_models/CustomTypeWithAppsyncScalarTypes.dart index 7c8fb7cb4d..db943926cf 100644 --- a/packages/api/amplify_api_dart/test/test_models/CustomTypeWithAppsyncScalarTypes.dart +++ b/packages/api/amplify_api_dart/test/test_models/CustomTypeWithAppsyncScalarTypes.dart @@ -1,20 +1,29 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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; +import 'package:collection/collection.dart'; -/// This is an auto generated class representing the CustomTypeWithAppsyncScalarTypes type in your schema. -@immutable +/** This is an auto generated class representing the CustomTypeWithAppsyncScalarTypes type in your schema. */ class CustomTypeWithAppsyncScalarTypes { final String? _stringValue; final List? _listOfStringValue; @@ -24,14 +33,14 @@ class CustomTypeWithAppsyncScalarTypes { final List? _listOfFloatValue; final bool? _booleanValue; final List? _listOfBooleanValue; - final TemporalDate? _awsDateValue; - final List? _listOfAWSDateValue; - final TemporalDateTime? _awsDateTimeValue; - final List? _listOfAWSDateTimeValue; - final TemporalTime? _awsTimeValue; - final List? _listOfAWSTimeValue; - final TemporalTimestamp? _awsTimestampValue; - final List? _listOfAWSTimestampValue; + final amplify_core.TemporalDate? _awsDateValue; + final List? _listOfAWSDateValue; + final amplify_core.TemporalDateTime? _awsDateTimeValue; + final List? _listOfAWSDateTimeValue; + final amplify_core.TemporalTime? _awsTimeValue; + final List? _listOfAWSTimeValue; + final amplify_core.TemporalTimestamp? _awsTimestampValue; + final List? _listOfAWSTimestampValue; final String? _awsEmailValue; final List? _listOfAWSEmailValue; final String? _awsJsonValue; @@ -79,35 +88,35 @@ class CustomTypeWithAppsyncScalarTypes { return _listOfBooleanValue; } - TemporalDate? get awsDateValue { + amplify_core.TemporalDate? get awsDateValue { return _awsDateValue; } - List? get listOfAWSDateValue { + List? get listOfAWSDateValue { return _listOfAWSDateValue; } - TemporalDateTime? get awsDateTimeValue { + amplify_core.TemporalDateTime? get awsDateTimeValue { return _awsDateTimeValue; } - List? get listOfAWSDateTimeValue { + List? get listOfAWSDateTimeValue { return _listOfAWSDateTimeValue; } - TemporalTime? get awsTimeValue { + amplify_core.TemporalTime? get awsTimeValue { return _awsTimeValue; } - List? get listOfAWSTimeValue { + List? get listOfAWSTimeValue { return _listOfAWSTimeValue; } - TemporalTimestamp? get awsTimestampValue { + amplify_core.TemporalTimestamp? get awsTimestampValue { return _awsTimestampValue; } - List? get listOfAWSTimestampValue { + List? get listOfAWSTimestampValue { return _listOfAWSTimestampValue; } @@ -238,14 +247,14 @@ class CustomTypeWithAppsyncScalarTypes { List? listOfFloatValue, bool? booleanValue, List? listOfBooleanValue, - TemporalDate? awsDateValue, - List? listOfAWSDateValue, - TemporalDateTime? awsDateTimeValue, - List? listOfAWSDateTimeValue, - TemporalTime? awsTimeValue, - List? listOfAWSTimeValue, - TemporalTimestamp? awsTimestampValue, - List? listOfAWSTimestampValue, + amplify_core.TemporalDate? awsDateValue, + List? listOfAWSDateValue, + amplify_core.TemporalDateTime? awsDateTimeValue, + List? listOfAWSDateTimeValue, + amplify_core.TemporalTime? awsTimeValue, + List? listOfAWSTimeValue, + amplify_core.TemporalTimestamp? awsTimestampValue, + List? listOfAWSTimestampValue, String? awsEmailValue, List? listOfAWSEmailValue, String? awsJsonValue, @@ -279,19 +288,21 @@ class CustomTypeWithAppsyncScalarTypes { : listOfBooleanValue, awsDateValue: awsDateValue, listOfAWSDateValue: listOfAWSDateValue != null - ? List.unmodifiable(listOfAWSDateValue) + ? List.unmodifiable(listOfAWSDateValue) : listOfAWSDateValue, awsDateTimeValue: awsDateTimeValue, listOfAWSDateTimeValue: listOfAWSDateTimeValue != null - ? List.unmodifiable(listOfAWSDateTimeValue) + ? List.unmodifiable( + listOfAWSDateTimeValue) : listOfAWSDateTimeValue, awsTimeValue: awsTimeValue, listOfAWSTimeValue: listOfAWSTimeValue != null - ? List.unmodifiable(listOfAWSTimeValue) + ? List.unmodifiable(listOfAWSTimeValue) : listOfAWSTimeValue, awsTimestampValue: awsTimestampValue, listOfAWSTimestampValue: listOfAWSTimestampValue != null - ? List.unmodifiable(listOfAWSTimestampValue) + ? List.unmodifiable( + listOfAWSTimestampValue) : listOfAWSTimestampValue, awsEmailValue: awsEmailValue, listOfAWSEmailValue: listOfAWSEmailValue != null @@ -383,7 +394,7 @@ class CustomTypeWithAppsyncScalarTypes { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("CustomTypeWithAppsyncScalarTypes {"); buffer.write("stringValue=" + "$_stringValue" + ", "); @@ -471,11 +482,13 @@ class CustomTypeWithAppsyncScalarTypes { : "null") + ", "); buffer.write("enumValue=" + - (_enumValue != null ? enumToString(_enumValue)! : "null") + + (_enumValue != null ? amplify_core.enumToString(_enumValue)! : "null") + ", "); buffer.write("listOfEnumValue=" + (_listOfEnumValue != null - ? _listOfEnumValue!.map((e) => enumToString(e)).toString() + ? _listOfEnumValue! + .map((e) => amplify_core.enumToString(e)) + .toString() : "null") + ", "); buffer.write("customTypeValue=" + @@ -499,14 +512,14 @@ class CustomTypeWithAppsyncScalarTypes { List? listOfFloatValue, bool? booleanValue, List? listOfBooleanValue, - TemporalDate? awsDateValue, - List? listOfAWSDateValue, - TemporalDateTime? awsDateTimeValue, - List? listOfAWSDateTimeValue, - TemporalTime? awsTimeValue, - List? listOfAWSTimeValue, - TemporalTimestamp? awsTimestampValue, - List? listOfAWSTimestampValue, + amplify_core.TemporalDate? awsDateValue, + List? listOfAWSDateValue, + amplify_core.TemporalDateTime? awsDateTimeValue, + List? listOfAWSDateTimeValue, + amplify_core.TemporalTime? awsTimeValue, + List? listOfAWSTimeValue, + amplify_core.TemporalTimestamp? awsTimestampValue, + List? listOfAWSTimestampValue, String? awsEmailValue, List? listOfAWSEmailValue, String? awsJsonValue, @@ -558,6 +571,115 @@ class CustomTypeWithAppsyncScalarTypes { listOfCustomTypeValue ?? this.listOfCustomTypeValue); } + CustomTypeWithAppsyncScalarTypes copyWithModelFieldValues( + {ModelFieldValue? stringValue, + ModelFieldValue?>? listOfStringValue, + ModelFieldValue? intValue, + ModelFieldValue?>? listOfIntValue, + ModelFieldValue? floatValue, + ModelFieldValue?>? listOfFloatValue, + ModelFieldValue? booleanValue, + ModelFieldValue?>? listOfBooleanValue, + ModelFieldValue? awsDateValue, + ModelFieldValue?>? listOfAWSDateValue, + ModelFieldValue? awsDateTimeValue, + ModelFieldValue?>? + listOfAWSDateTimeValue, + ModelFieldValue? awsTimeValue, + ModelFieldValue?>? listOfAWSTimeValue, + ModelFieldValue? awsTimestampValue, + ModelFieldValue?>? + listOfAWSTimestampValue, + ModelFieldValue? awsEmailValue, + ModelFieldValue?>? listOfAWSEmailValue, + ModelFieldValue? awsJsonValue, + ModelFieldValue?>? listOfAWSJsonValue, + ModelFieldValue? awsPhoneValue, + ModelFieldValue?>? listOfAWSPhoneValue, + ModelFieldValue? awsURLValue, + ModelFieldValue?>? listOfAWSURLValue, + ModelFieldValue? awsIPAddressValue, + ModelFieldValue?>? listOfAWSIPAddressValue, + ModelFieldValue? enumValue, + ModelFieldValue?>? listOfEnumValue, + ModelFieldValue? customTypeValue, + ModelFieldValue?>? listOfCustomTypeValue}) { + return CustomTypeWithAppsyncScalarTypes._internal( + stringValue: stringValue == null ? this.stringValue : stringValue.value, + listOfStringValue: listOfStringValue == null + ? this.listOfStringValue + : listOfStringValue.value, + intValue: intValue == null ? this.intValue : intValue.value, + listOfIntValue: + listOfIntValue == null ? this.listOfIntValue : listOfIntValue.value, + floatValue: floatValue == null ? this.floatValue : floatValue.value, + listOfFloatValue: listOfFloatValue == null + ? this.listOfFloatValue + : listOfFloatValue.value, + booleanValue: + booleanValue == null ? this.booleanValue : booleanValue.value, + listOfBooleanValue: listOfBooleanValue == null + ? this.listOfBooleanValue + : listOfBooleanValue.value, + awsDateValue: + awsDateValue == null ? this.awsDateValue : awsDateValue.value, + listOfAWSDateValue: listOfAWSDateValue == null + ? this.listOfAWSDateValue + : listOfAWSDateValue.value, + awsDateTimeValue: awsDateTimeValue == null + ? this.awsDateTimeValue + : awsDateTimeValue.value, + listOfAWSDateTimeValue: listOfAWSDateTimeValue == null + ? this.listOfAWSDateTimeValue + : listOfAWSDateTimeValue.value, + awsTimeValue: + awsTimeValue == null ? this.awsTimeValue : awsTimeValue.value, + listOfAWSTimeValue: listOfAWSTimeValue == null + ? this.listOfAWSTimeValue + : listOfAWSTimeValue.value, + awsTimestampValue: awsTimestampValue == null + ? this.awsTimestampValue + : awsTimestampValue.value, + listOfAWSTimestampValue: listOfAWSTimestampValue == null + ? this.listOfAWSTimestampValue + : listOfAWSTimestampValue.value, + awsEmailValue: + awsEmailValue == null ? this.awsEmailValue : awsEmailValue.value, + listOfAWSEmailValue: listOfAWSEmailValue == null + ? this.listOfAWSEmailValue + : listOfAWSEmailValue.value, + awsJsonValue: + awsJsonValue == null ? this.awsJsonValue : awsJsonValue.value, + listOfAWSJsonValue: listOfAWSJsonValue == null + ? this.listOfAWSJsonValue + : listOfAWSJsonValue.value, + awsPhoneValue: + awsPhoneValue == null ? this.awsPhoneValue : awsPhoneValue.value, + listOfAWSPhoneValue: listOfAWSPhoneValue == null + ? this.listOfAWSPhoneValue + : listOfAWSPhoneValue.value, + awsURLValue: awsURLValue == null ? this.awsURLValue : awsURLValue.value, + listOfAWSURLValue: listOfAWSURLValue == null + ? this.listOfAWSURLValue + : listOfAWSURLValue.value, + awsIPAddressValue: awsIPAddressValue == null + ? this.awsIPAddressValue + : awsIPAddressValue.value, + listOfAWSIPAddressValue: listOfAWSIPAddressValue == null + ? this.listOfAWSIPAddressValue + : listOfAWSIPAddressValue.value, + enumValue: enumValue == null ? this.enumValue : enumValue.value, + listOfEnumValue: listOfEnumValue == null + ? this.listOfEnumValue + : listOfEnumValue.value, + customTypeValue: customTypeValue == null + ? this.customTypeValue + : customTypeValue.value, + listOfCustomTypeValue: listOfCustomTypeValue == null + ? this.listOfCustomTypeValue + : listOfCustomTypeValue.value); + } + CustomTypeWithAppsyncScalarTypes.fromJson(Map json) : _stringValue = json['stringValue'], _listOfStringValue = json['listOfStringValue']?.cast(), @@ -572,28 +694,29 @@ class CustomTypeWithAppsyncScalarTypes { _booleanValue = json['booleanValue'], _listOfBooleanValue = json['listOfBooleanValue']?.cast(), _awsDateValue = json['awsDateValue'] != null - ? TemporalDate.fromString(json['awsDateValue']) + ? amplify_core.TemporalDate.fromString(json['awsDateValue']) : null, _listOfAWSDateValue = (json['listOfAWSDateValue'] as List?) - ?.map((e) => TemporalDate.fromString(e)) + ?.map((e) => amplify_core.TemporalDate.fromString(e)) .toList(), _awsDateTimeValue = json['awsDateTimeValue'] != null - ? TemporalDateTime.fromString(json['awsDateTimeValue']) + ? amplify_core.TemporalDateTime.fromString(json['awsDateTimeValue']) : null, _listOfAWSDateTimeValue = (json['listOfAWSDateTimeValue'] as List?) - ?.map((e) => TemporalDateTime.fromString(e)) + ?.map((e) => amplify_core.TemporalDateTime.fromString(e)) .toList(), _awsTimeValue = json['awsTimeValue'] != null - ? TemporalTime.fromString(json['awsTimeValue']) + ? amplify_core.TemporalTime.fromString(json['awsTimeValue']) : null, _listOfAWSTimeValue = (json['listOfAWSTimeValue'] as List?) - ?.map((e) => TemporalTime.fromString(e)) + ?.map((e) => amplify_core.TemporalTime.fromString(e)) .toList(), _awsTimestampValue = json['awsTimestampValue'] != null - ? TemporalTimestamp.fromSeconds(json['awsTimestampValue']) + ? amplify_core.TemporalTimestamp.fromSeconds( + json['awsTimestampValue']) : null, _listOfAWSTimestampValue = (json['listOfAWSTimestampValue'] as List?) - ?.map((e) => TemporalTimestamp.fromSeconds(e)) + ?.map((e) => amplify_core.TemporalTimestamp.fromSeconds(e)) .toList(), _awsEmailValue = json['awsEmailValue'], _listOfAWSEmailValue = json['listOfAWSEmailValue']?.cast(), @@ -606,22 +729,23 @@ class CustomTypeWithAppsyncScalarTypes { _awsIPAddressValue = json['awsIPAddressValue'], _listOfAWSIPAddressValue = json['listOfAWSIPAddressValue']?.cast(), - _enumValue = - enumFromString(json['enumValue'], EnumField.values), + _enumValue = amplify_core.enumFromString( + json['enumValue'], EnumField.values), _listOfEnumValue = json['listOfEnumValue'] is List ? (json['listOfEnumValue'] as List) - .map((e) => enumFromString(e, EnumField.values)!) + .map((e) => amplify_core.enumFromString( + e, EnumField.values)!) .toList() : null, - _customTypeValue = json['customTypeValue']?['serializedData'] != null - ? SimpleCustomType.fromJson(Map.from( - json['customTypeValue']['serializedData'])) + _customTypeValue = json['customTypeValue'] != null + ? SimpleCustomType.fromJson( + new Map.from(json['customTypeValue'])) : null, _listOfCustomTypeValue = json['listOfCustomTypeValue'] is List ? (json['listOfCustomTypeValue'] as List) .where((e) => e != null) - .map((e) => SimpleCustomType.fromJson( - Map.from(e['serializedData']))) + .map((e) => + SimpleCustomType.fromJson(new Map.from(e))) .toList() : null; @@ -656,199 +780,291 @@ class CustomTypeWithAppsyncScalarTypes { 'listOfAWSURLValue': _listOfAWSURLValue, 'awsIPAddressValue': _awsIPAddressValue, 'listOfAWSIPAddressValue': _listOfAWSIPAddressValue, - 'enumValue': enumToString(_enumValue), + 'enumValue': amplify_core.enumToString(_enumValue), 'listOfEnumValue': - _listOfEnumValue?.map((e) => enumToString(e)).toList(), + _listOfEnumValue?.map((e) => amplify_core.enumToString(e)).toList(), 'customTypeValue': _customTypeValue?.toJson(), 'listOfCustomTypeValue': _listOfCustomTypeValue ?.map((SimpleCustomType? e) => e?.toJson()) .toList() }; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + Map toMap() => { + 'stringValue': _stringValue, + 'listOfStringValue': _listOfStringValue, + 'intValue': _intValue, + 'listOfIntValue': _listOfIntValue, + 'floatValue': _floatValue, + 'listOfFloatValue': _listOfFloatValue, + 'booleanValue': _booleanValue, + 'listOfBooleanValue': _listOfBooleanValue, + 'awsDateValue': _awsDateValue, + 'listOfAWSDateValue': _listOfAWSDateValue, + 'awsDateTimeValue': _awsDateTimeValue, + 'listOfAWSDateTimeValue': _listOfAWSDateTimeValue, + 'awsTimeValue': _awsTimeValue, + 'listOfAWSTimeValue': _listOfAWSTimeValue, + 'awsTimestampValue': _awsTimestampValue, + 'listOfAWSTimestampValue': _listOfAWSTimestampValue, + 'awsEmailValue': _awsEmailValue, + 'listOfAWSEmailValue': _listOfAWSEmailValue, + 'awsJsonValue': _awsJsonValue, + 'listOfAWSJsonValue': _listOfAWSJsonValue, + 'awsPhoneValue': _awsPhoneValue, + 'listOfAWSPhoneValue': _listOfAWSPhoneValue, + 'awsURLValue': _awsURLValue, + 'listOfAWSURLValue': _listOfAWSURLValue, + 'awsIPAddressValue': _awsIPAddressValue, + 'listOfAWSIPAddressValue': _listOfAWSIPAddressValue, + 'enumValue': _enumValue, + 'listOfEnumValue': _listOfEnumValue, + 'customTypeValue': _customTypeValue, + 'listOfCustomTypeValue': _listOfCustomTypeValue + }; + + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "CustomTypeWithAppsyncScalarTypes"; modelSchemaDefinition.pluralName = "CustomTypeWithAppsyncScalarTypes"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'stringValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfStringValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'intValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfIntValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.int.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'floatValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.double))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfFloatValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.double.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'booleanValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.bool))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfBooleanValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.bool.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsDateValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.date))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSDateValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.date.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsDateTimeValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSDateTimeValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.dateTime.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsTimeValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.time))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSTimeValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.time.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsTimestampValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.timestamp))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSTimestampValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.timestamp.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsEmailValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSEmailValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsJsonValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSJsonValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsPhoneValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSPhoneValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsURLValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSURLValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'awsIPAddressValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfAWSIPAddressValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'enumValue', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.enumeration))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'listOfEnumValue', - isRequired: false, - isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.enumeration.name))); - - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'stringValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfStringValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'intValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.int))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfIntValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.int.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'floatValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.double))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfFloatValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.double.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'booleanValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.bool))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfBooleanValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.bool.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsDateValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.date))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSDateValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.date.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsDateTimeValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSDateTimeValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.dateTime.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsTimeValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.time))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSTimeValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.time.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsTimestampValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.timestamp))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSTimestampValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.timestamp.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsEmailValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSEmailValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsJsonValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSJsonValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsPhoneValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSPhoneValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsURLValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSURLValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'awsIPAddressValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfAWSIPAddressValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'enumValue', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.enumeration))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'listOfEnumValue', + isRequired: false, + isArray: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: + amplify_core.ModelFieldTypeEnum.enumeration.name))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'customTypeValue', isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.embedded, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embedded, ofCustomTypeName: 'SimpleCustomType'))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'listOfCustomTypeValue', isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embeddedCollection, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embeddedCollection, ofCustomTypeName: 'SimpleCustomType'))); }); } diff --git a/packages/api/amplify_api_dart/test/test_models/EnumField.dart b/packages/api/amplify_api_dart/test/test_models/EnumField.dart index 3c892817be..6c34a76ef5 100644 --- a/packages/api/amplify_api_dart/test/test_models/EnumField.dart +++ b/packages/api/amplify_api_dart/test/test_models/EnumField.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 diff --git a/packages/api/amplify_api_dart/test/test_models/ModelProvider.dart b/packages/api/amplify_api_dart/test/test_models/ModelProvider.dart index 8005534bc4..51b011b1f9 100644 --- a/packages/api/amplify_api_dart/test/test_models/ModelProvider.dart +++ b/packages/api/amplify_api_dart/test/test_models/ModelProvider.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,8 +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 'CpkIntIndexes.dart'; @@ -17,13 +28,13 @@ import 'CpkOneToOneBidirectionalChildExplicitCD.dart'; import 'CpkOneToOneBidirectionalChildImplicitCD.dart'; import 'CpkOneToOneBidirectionalParentCD.dart'; import 'CustomOwnerField.dart'; -import 'CustomTypeWithAppsyncScalarTypes.dart'; import 'ModelWithAppsyncScalarTypes.dart'; import 'ModelWithCustomType.dart'; import 'Post.dart'; import 'PostTags.dart'; -import 'SimpleCustomType.dart'; import 'Tag.dart'; +import 'CustomTypeWithAppsyncScalarTypes.dart'; +import 'SimpleCustomType.dart'; export 'Blog.dart'; export 'Comment.dart'; @@ -42,13 +53,11 @@ export 'PostTags.dart'; export 'SimpleCustomType.dart'; export 'Tag.dart'; -class ModelProvider implements ModelProviderInterface { +class ModelProvider implements amplify_core.ModelProviderInterface { @override - String version = "5bb609b6f4dc361bb6c2aaa3e1ee7560"; + String version = "83bf9177a73379eb13a3becbb8d0fb38"; @override - List modelSchemas = [ - // the schemas that are commented out are not needed to run - // the example App + List modelSchemas = [ Blog.schema, Comment.schema, CpkIntIndexes.schema, @@ -63,16 +72,16 @@ class ModelProvider implements ModelProviderInterface { PostTags.schema, Tag.schema ]; - static final ModelProvider _instance = ModelProvider(); @override - List customTypeSchemas = [ + List customTypeSchemas = [ CustomTypeWithAppsyncScalarTypes.schema, SimpleCustomType.schema ]; + 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; @@ -107,3 +116,9 @@ class ModelProvider implements ModelProviderInterface { } } } + +class ModelFieldValue { + const ModelFieldValue.value(this.value); + + final T value; +} diff --git a/packages/api/amplify_api_dart/test/test_models/ModelWithAppsyncScalarTypes.dart b/packages/api/amplify_api_dart/test/test_models/ModelWithAppsyncScalarTypes.dart index d4b096bbed..79cc247eef 100644 --- a/packages/api/amplify_api_dart/test/test_models/ModelWithAppsyncScalarTypes.dart +++ b/packages/api/amplify_api_dart/test/test_models/ModelWithAppsyncScalarTypes.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,14 +19,13 @@ // 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 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; -/// This is an auto generated class representing the ModelWithAppsyncScalarTypes type in your schema. -@immutable -class ModelWithAppsyncScalarTypes extends Model { - static const classType = _ModelWithAppsyncScalarTypesModelType(); +/** This is an auto generated class representing the ModelWithAppsyncScalarTypes type in your schema. */ +class ModelWithAppsyncScalarTypes extends amplify_core.Model { + static const classType = const _ModelWithAppsyncScalarTypesModelType(); final String id; final String? _stringValue; final String? _altStringValue; @@ -26,14 +37,14 @@ class ModelWithAppsyncScalarTypes extends Model { final List? _listOfFloatValue; final bool? _booleanValue; final List? _listOfBooleanValue; - final TemporalDate? _awsDateValue; - final List? _listOfAWSDateValue; - final TemporalTime? _awsTimeValue; - final List? _listOfAWSTimeValue; - final TemporalDateTime? _awsDateTimeValue; - final List? _listOfAWSDateTimeValue; - final TemporalTimestamp? _awsTimestampValue; - final List? _listOfAWSTimestampValue; + final amplify_core.TemporalDate? _awsDateValue; + final List? _listOfAWSDateValue; + final amplify_core.TemporalTime? _awsTimeValue; + final List? _listOfAWSTimeValue; + final amplify_core.TemporalDateTime? _awsDateTimeValue; + final List? _listOfAWSDateTimeValue; + final amplify_core.TemporalTimestamp? _awsTimestampValue; + final List? _listOfAWSTimestampValue; final String? _awsEmailValue; final List? _listOfAWSEmailValue; final String? _awsJsonValue; @@ -44,8 +55,8 @@ class ModelWithAppsyncScalarTypes extends Model { final List? _listOfAWSURLValue; final String? _awsIPAddressValue; final List? _listOfAWSIPAddressValue; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -99,35 +110,35 @@ class ModelWithAppsyncScalarTypes extends Model { return _listOfBooleanValue; } - TemporalDate? get awsDateValue { + amplify_core.TemporalDate? get awsDateValue { return _awsDateValue; } - List? get listOfAWSDateValue { + List? get listOfAWSDateValue { return _listOfAWSDateValue; } - TemporalTime? get awsTimeValue { + amplify_core.TemporalTime? get awsTimeValue { return _awsTimeValue; } - List? get listOfAWSTimeValue { + List? get listOfAWSTimeValue { return _listOfAWSTimeValue; } - TemporalDateTime? get awsDateTimeValue { + amplify_core.TemporalDateTime? get awsDateTimeValue { return _awsDateTimeValue; } - List? get listOfAWSDateTimeValue { + List? get listOfAWSDateTimeValue { return _listOfAWSDateTimeValue; } - TemporalTimestamp? get awsTimestampValue { + amplify_core.TemporalTimestamp? get awsTimestampValue { return _awsTimestampValue; } - List? get listOfAWSTimestampValue { + List? get listOfAWSTimestampValue { return _listOfAWSTimestampValue; } @@ -171,11 +182,11 @@ class ModelWithAppsyncScalarTypes extends Model { return _listOfAWSIPAddressValue; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -254,14 +265,14 @@ class ModelWithAppsyncScalarTypes extends Model { List? listOfFloatValue, bool? booleanValue, List? listOfBooleanValue, - TemporalDate? awsDateValue, - List? listOfAWSDateValue, - TemporalTime? awsTimeValue, - List? listOfAWSTimeValue, - TemporalDateTime? awsDateTimeValue, - List? listOfAWSDateTimeValue, - TemporalTimestamp? awsTimestampValue, - List? listOfAWSTimestampValue, + amplify_core.TemporalDate? awsDateValue, + List? listOfAWSDateValue, + amplify_core.TemporalTime? awsTimeValue, + List? listOfAWSTimeValue, + amplify_core.TemporalDateTime? awsDateTimeValue, + List? listOfAWSDateTimeValue, + amplify_core.TemporalTimestamp? awsTimestampValue, + List? listOfAWSTimestampValue, String? awsEmailValue, List? listOfAWSEmailValue, String? awsJsonValue, @@ -273,7 +284,7 @@ class ModelWithAppsyncScalarTypes extends Model { String? awsIPAddressValue, List? listOfAWSIPAddressValue}) { return ModelWithAppsyncScalarTypes._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, stringValue: stringValue, altStringValue: altStringValue, listOfStringValue: listOfStringValue != null @@ -294,19 +305,21 @@ class ModelWithAppsyncScalarTypes extends Model { : listOfBooleanValue, awsDateValue: awsDateValue, listOfAWSDateValue: listOfAWSDateValue != null - ? List.unmodifiable(listOfAWSDateValue) + ? List.unmodifiable(listOfAWSDateValue) : listOfAWSDateValue, awsTimeValue: awsTimeValue, listOfAWSTimeValue: listOfAWSTimeValue != null - ? List.unmodifiable(listOfAWSTimeValue) + ? List.unmodifiable(listOfAWSTimeValue) : listOfAWSTimeValue, awsDateTimeValue: awsDateTimeValue, listOfAWSDateTimeValue: listOfAWSDateTimeValue != null - ? List.unmodifiable(listOfAWSDateTimeValue) + ? List.unmodifiable( + listOfAWSDateTimeValue) : listOfAWSDateTimeValue, awsTimestampValue: awsTimestampValue, listOfAWSTimestampValue: listOfAWSTimestampValue != null - ? List.unmodifiable(listOfAWSTimestampValue) + ? List.unmodifiable( + listOfAWSTimestampValue) : listOfAWSTimestampValue, awsEmailValue: awsEmailValue, listOfAWSEmailValue: listOfAWSEmailValue != null @@ -387,7 +400,7 @@ class ModelWithAppsyncScalarTypes extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("ModelWithAppsyncScalarTypes {"); buffer.write("id=" + "$id" + ", "); @@ -500,14 +513,14 @@ class ModelWithAppsyncScalarTypes extends Model { List? listOfFloatValue, bool? booleanValue, List? listOfBooleanValue, - TemporalDate? awsDateValue, - List? listOfAWSDateValue, - TemporalTime? awsTimeValue, - List? listOfAWSTimeValue, - TemporalDateTime? awsDateTimeValue, - List? listOfAWSDateTimeValue, - TemporalTimestamp? awsTimestampValue, - List? listOfAWSTimestampValue, + amplify_core.TemporalDate? awsDateValue, + List? listOfAWSDateValue, + amplify_core.TemporalTime? awsTimeValue, + List? listOfAWSTimeValue, + amplify_core.TemporalDateTime? awsDateTimeValue, + List? listOfAWSDateTimeValue, + amplify_core.TemporalTimestamp? awsTimestampValue, + List? listOfAWSTimestampValue, String? awsEmailValue, List? listOfAWSEmailValue, String? awsJsonValue, @@ -553,6 +566,107 @@ class ModelWithAppsyncScalarTypes extends Model { listOfAWSIPAddressValue ?? this.listOfAWSIPAddressValue); } + ModelWithAppsyncScalarTypes copyWithModelFieldValues( + {ModelFieldValue? stringValue, + ModelFieldValue? altStringValue, + ModelFieldValue?>? listOfStringValue, + ModelFieldValue? intValue, + ModelFieldValue? altIntValue, + ModelFieldValue?>? listOfIntValue, + ModelFieldValue? floatValue, + ModelFieldValue?>? listOfFloatValue, + ModelFieldValue? booleanValue, + ModelFieldValue?>? listOfBooleanValue, + ModelFieldValue? awsDateValue, + ModelFieldValue?>? listOfAWSDateValue, + ModelFieldValue? awsTimeValue, + ModelFieldValue?>? listOfAWSTimeValue, + ModelFieldValue? awsDateTimeValue, + ModelFieldValue?>? + listOfAWSDateTimeValue, + ModelFieldValue? awsTimestampValue, + ModelFieldValue?>? + listOfAWSTimestampValue, + ModelFieldValue? awsEmailValue, + ModelFieldValue?>? listOfAWSEmailValue, + ModelFieldValue? awsJsonValue, + ModelFieldValue?>? listOfAWSJsonValue, + ModelFieldValue? awsPhoneValue, + ModelFieldValue?>? listOfAWSPhoneValue, + ModelFieldValue? awsURLValue, + ModelFieldValue?>? listOfAWSURLValue, + ModelFieldValue? awsIPAddressValue, + ModelFieldValue?>? listOfAWSIPAddressValue}) { + return ModelWithAppsyncScalarTypes._internal( + id: id, + stringValue: stringValue == null ? this.stringValue : stringValue.value, + altStringValue: + altStringValue == null ? this.altStringValue : altStringValue.value, + listOfStringValue: listOfStringValue == null + ? this.listOfStringValue + : listOfStringValue.value, + intValue: intValue == null ? this.intValue : intValue.value, + altIntValue: altIntValue == null ? this.altIntValue : altIntValue.value, + listOfIntValue: + listOfIntValue == null ? this.listOfIntValue : listOfIntValue.value, + floatValue: floatValue == null ? this.floatValue : floatValue.value, + listOfFloatValue: listOfFloatValue == null + ? this.listOfFloatValue + : listOfFloatValue.value, + booleanValue: + booleanValue == null ? this.booleanValue : booleanValue.value, + listOfBooleanValue: listOfBooleanValue == null + ? this.listOfBooleanValue + : listOfBooleanValue.value, + awsDateValue: + awsDateValue == null ? this.awsDateValue : awsDateValue.value, + listOfAWSDateValue: listOfAWSDateValue == null + ? this.listOfAWSDateValue + : listOfAWSDateValue.value, + awsTimeValue: + awsTimeValue == null ? this.awsTimeValue : awsTimeValue.value, + listOfAWSTimeValue: listOfAWSTimeValue == null + ? this.listOfAWSTimeValue + : listOfAWSTimeValue.value, + awsDateTimeValue: awsDateTimeValue == null + ? this.awsDateTimeValue + : awsDateTimeValue.value, + listOfAWSDateTimeValue: listOfAWSDateTimeValue == null + ? this.listOfAWSDateTimeValue + : listOfAWSDateTimeValue.value, + awsTimestampValue: awsTimestampValue == null + ? this.awsTimestampValue + : awsTimestampValue.value, + listOfAWSTimestampValue: listOfAWSTimestampValue == null + ? this.listOfAWSTimestampValue + : listOfAWSTimestampValue.value, + awsEmailValue: + awsEmailValue == null ? this.awsEmailValue : awsEmailValue.value, + listOfAWSEmailValue: listOfAWSEmailValue == null + ? this.listOfAWSEmailValue + : listOfAWSEmailValue.value, + awsJsonValue: + awsJsonValue == null ? this.awsJsonValue : awsJsonValue.value, + listOfAWSJsonValue: listOfAWSJsonValue == null + ? this.listOfAWSJsonValue + : listOfAWSJsonValue.value, + awsPhoneValue: + awsPhoneValue == null ? this.awsPhoneValue : awsPhoneValue.value, + listOfAWSPhoneValue: listOfAWSPhoneValue == null + ? this.listOfAWSPhoneValue + : listOfAWSPhoneValue.value, + awsURLValue: awsURLValue == null ? this.awsURLValue : awsURLValue.value, + listOfAWSURLValue: listOfAWSURLValue == null + ? this.listOfAWSURLValue + : listOfAWSURLValue.value, + awsIPAddressValue: awsIPAddressValue == null + ? this.awsIPAddressValue + : awsIPAddressValue.value, + listOfAWSIPAddressValue: listOfAWSIPAddressValue == null + ? this.listOfAWSIPAddressValue + : listOfAWSIPAddressValue.value); + } + ModelWithAppsyncScalarTypes.fromJson(Map json) : id = json['id'], _stringValue = json['stringValue'], @@ -570,28 +684,29 @@ class ModelWithAppsyncScalarTypes extends Model { _booleanValue = json['booleanValue'], _listOfBooleanValue = json['listOfBooleanValue']?.cast(), _awsDateValue = json['awsDateValue'] != null - ? TemporalDate.fromString(json['awsDateValue']) + ? amplify_core.TemporalDate.fromString(json['awsDateValue']) : null, _listOfAWSDateValue = (json['listOfAWSDateValue'] as List?) - ?.map((e) => TemporalDate.fromString(e)) + ?.map((e) => amplify_core.TemporalDate.fromString(e)) .toList(), _awsTimeValue = json['awsTimeValue'] != null - ? TemporalTime.fromString(json['awsTimeValue']) + ? amplify_core.TemporalTime.fromString(json['awsTimeValue']) : null, _listOfAWSTimeValue = (json['listOfAWSTimeValue'] as List?) - ?.map((e) => TemporalTime.fromString(e)) + ?.map((e) => amplify_core.TemporalTime.fromString(e)) .toList(), _awsDateTimeValue = json['awsDateTimeValue'] != null - ? TemporalDateTime.fromString(json['awsDateTimeValue']) + ? amplify_core.TemporalDateTime.fromString(json['awsDateTimeValue']) : null, _listOfAWSDateTimeValue = (json['listOfAWSDateTimeValue'] as List?) - ?.map((e) => TemporalDateTime.fromString(e)) + ?.map((e) => amplify_core.TemporalDateTime.fromString(e)) .toList(), _awsTimestampValue = json['awsTimestampValue'] != null - ? TemporalTimestamp.fromSeconds(json['awsTimestampValue']) + ? amplify_core.TemporalTimestamp.fromSeconds( + json['awsTimestampValue']) : null, _listOfAWSTimestampValue = (json['listOfAWSTimestampValue'] as List?) - ?.map((e) => TemporalTimestamp.fromSeconds(e)) + ?.map((e) => amplify_core.TemporalTimestamp.fromSeconds(e)) .toList(), _awsEmailValue = json['awsEmailValue'], _listOfAWSEmailValue = json['listOfAWSEmailValue']?.cast(), @@ -605,10 +720,10 @@ class ModelWithAppsyncScalarTypes extends Model { _listOfAWSIPAddressValue = json['listOfAWSIPAddressValue']?.cast(), _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() => { @@ -649,262 +764,339 @@ class ModelWithAppsyncScalarTypes extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier - MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField STRINGVALUE = QueryField(fieldName: "stringValue"); - static final QueryField ALTSTRINGVALUE = - QueryField(fieldName: "altStringValue"); - static final QueryField LISTOFSTRINGVALUE = - QueryField(fieldName: "listOfStringValue"); - static final QueryField INTVALUE = QueryField(fieldName: "intValue"); - static final QueryField ALTINTVALUE = QueryField(fieldName: "altIntValue"); - static final QueryField LISTOFINTVALUE = - QueryField(fieldName: "listOfIntValue"); - static final QueryField FLOATVALUE = QueryField(fieldName: "floatValue"); - static final QueryField LISTOFFLOATVALUE = - QueryField(fieldName: "listOfFloatValue"); - static final QueryField BOOLEANVALUE = QueryField(fieldName: "booleanValue"); - static final QueryField LISTOFBOOLEANVALUE = - QueryField(fieldName: "listOfBooleanValue"); - static final QueryField AWSDATEVALUE = QueryField(fieldName: "awsDateValue"); - static final QueryField LISTOFAWSDATEVALUE = - QueryField(fieldName: "listOfAWSDateValue"); - static final QueryField AWSTIMEVALUE = QueryField(fieldName: "awsTimeValue"); - static final QueryField LISTOFAWSTIMEVALUE = - QueryField(fieldName: "listOfAWSTimeValue"); - static final QueryField AWSDATETIMEVALUE = - QueryField(fieldName: "awsDateTimeValue"); - static final QueryField LISTOFAWSDATETIMEVALUE = - QueryField(fieldName: "listOfAWSDateTimeValue"); - static final QueryField AWSTIMESTAMPVALUE = - QueryField(fieldName: "awsTimestampValue"); - static final QueryField LISTOFAWSTIMESTAMPVALUE = - QueryField(fieldName: "listOfAWSTimestampValue"); - static final QueryField AWSEMAILVALUE = - QueryField(fieldName: "awsEmailValue"); - static final QueryField LISTOFAWSEMAILVALUE = - QueryField(fieldName: "listOfAWSEmailValue"); - static final QueryField AWSJSONVALUE = QueryField(fieldName: "awsJsonValue"); - static final QueryField LISTOFAWSJSONVALUE = - QueryField(fieldName: "listOfAWSJsonValue"); - static final QueryField AWSPHONEVALUE = - QueryField(fieldName: "awsPhoneValue"); - static final QueryField LISTOFAWSPHONEVALUE = - QueryField(fieldName: "listOfAWSPhoneValue"); - static final QueryField AWSURLVALUE = QueryField(fieldName: "awsURLValue"); - static final QueryField LISTOFAWSURLVALUE = - QueryField(fieldName: "listOfAWSURLValue"); - static final QueryField AWSIPADDRESSVALUE = - QueryField(fieldName: "awsIPAddressValue"); - static final QueryField LISTOFAWSIPADDRESSVALUE = - QueryField(fieldName: "listOfAWSIPAddressValue"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + Map toMap() => { + 'id': id, + 'stringValue': _stringValue, + 'altStringValue': _altStringValue, + 'listOfStringValue': _listOfStringValue, + 'intValue': _intValue, + 'altIntValue': _altIntValue, + 'listOfIntValue': _listOfIntValue, + 'floatValue': _floatValue, + 'listOfFloatValue': _listOfFloatValue, + 'booleanValue': _booleanValue, + 'listOfBooleanValue': _listOfBooleanValue, + 'awsDateValue': _awsDateValue, + 'listOfAWSDateValue': _listOfAWSDateValue, + 'awsTimeValue': _awsTimeValue, + 'listOfAWSTimeValue': _listOfAWSTimeValue, + 'awsDateTimeValue': _awsDateTimeValue, + 'listOfAWSDateTimeValue': _listOfAWSDateTimeValue, + 'awsTimestampValue': _awsTimestampValue, + 'listOfAWSTimestampValue': _listOfAWSTimestampValue, + 'awsEmailValue': _awsEmailValue, + 'listOfAWSEmailValue': _listOfAWSEmailValue, + 'awsJsonValue': _awsJsonValue, + 'listOfAWSJsonValue': _listOfAWSJsonValue, + 'awsPhoneValue': _awsPhoneValue, + 'listOfAWSPhoneValue': _listOfAWSPhoneValue, + 'awsURLValue': _awsURLValue, + 'listOfAWSURLValue': _listOfAWSURLValue, + 'awsIPAddressValue': _awsIPAddressValue, + 'listOfAWSIPAddressValue': _listOfAWSIPAddressValue, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + static final amplify_core + .QueryModelIdentifier + MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier< + ModelWithAppsyncScalarTypesModelIdentifier>(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final STRINGVALUE = amplify_core.QueryField(fieldName: "stringValue"); + static final ALTSTRINGVALUE = + amplify_core.QueryField(fieldName: "altStringValue"); + static final LISTOFSTRINGVALUE = + amplify_core.QueryField(fieldName: "listOfStringValue"); + static final INTVALUE = amplify_core.QueryField(fieldName: "intValue"); + static final ALTINTVALUE = amplify_core.QueryField(fieldName: "altIntValue"); + static final LISTOFINTVALUE = + amplify_core.QueryField(fieldName: "listOfIntValue"); + static final FLOATVALUE = amplify_core.QueryField(fieldName: "floatValue"); + static final LISTOFFLOATVALUE = + amplify_core.QueryField(fieldName: "listOfFloatValue"); + static final BOOLEANVALUE = + amplify_core.QueryField(fieldName: "booleanValue"); + static final LISTOFBOOLEANVALUE = + amplify_core.QueryField(fieldName: "listOfBooleanValue"); + static final AWSDATEVALUE = + amplify_core.QueryField(fieldName: "awsDateValue"); + static final LISTOFAWSDATEVALUE = + amplify_core.QueryField(fieldName: "listOfAWSDateValue"); + static final AWSTIMEVALUE = + amplify_core.QueryField(fieldName: "awsTimeValue"); + static final LISTOFAWSTIMEVALUE = + amplify_core.QueryField(fieldName: "listOfAWSTimeValue"); + static final AWSDATETIMEVALUE = + amplify_core.QueryField(fieldName: "awsDateTimeValue"); + static final LISTOFAWSDATETIMEVALUE = + amplify_core.QueryField(fieldName: "listOfAWSDateTimeValue"); + static final AWSTIMESTAMPVALUE = + amplify_core.QueryField(fieldName: "awsTimestampValue"); + static final LISTOFAWSTIMESTAMPVALUE = + amplify_core.QueryField(fieldName: "listOfAWSTimestampValue"); + static final AWSEMAILVALUE = + amplify_core.QueryField(fieldName: "awsEmailValue"); + static final LISTOFAWSEMAILVALUE = + amplify_core.QueryField(fieldName: "listOfAWSEmailValue"); + static final AWSJSONVALUE = + amplify_core.QueryField(fieldName: "awsJsonValue"); + static final LISTOFAWSJSONVALUE = + amplify_core.QueryField(fieldName: "listOfAWSJsonValue"); + static final AWSPHONEVALUE = + amplify_core.QueryField(fieldName: "awsPhoneValue"); + static final LISTOFAWSPHONEVALUE = + amplify_core.QueryField(fieldName: "listOfAWSPhoneValue"); + static final AWSURLVALUE = amplify_core.QueryField(fieldName: "awsURLValue"); + static final LISTOFAWSURLVALUE = + amplify_core.QueryField(fieldName: "listOfAWSURLValue"); + static final AWSIPADDRESSVALUE = + amplify_core.QueryField(fieldName: "awsIPAddressValue"); + static final LISTOFAWSIPADDRESSVALUE = + amplify_core.QueryField(fieldName: "listOfAWSIPAddressValue"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "ModelWithAppsyncScalarTypes"; modelSchemaDefinition.pluralName = "ModelWithAppsyncScalarTypes"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.STRINGVALUE, 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: ModelWithAppsyncScalarTypes.ALTSTRINGVALUE, 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: ModelWithAppsyncScalarTypes.LISTOFSTRINGVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.INTVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.ALTINTVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFINTVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.int.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.int.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.FLOATVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.double))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.double))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFFLOATVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.double.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.double.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.BOOLEANVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.bool))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.bool))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFBOOLEANVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.bool.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.bool.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSDATEVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.date))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.date))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFAWSDATEVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.date.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.date.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSTIMEVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.time))); + ofType: + amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.time))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFAWSTIMEVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.time.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.time.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSDATETIMEVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFAWSDATETIMEVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.dateTime.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.dateTime.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSTIMESTAMPVALUE, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.timestamp))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.timestamp))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.LISTOFAWSTIMESTAMPVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.timestamp.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.timestamp.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSEMAILVALUE, 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: ModelWithAppsyncScalarTypes.LISTOFAWSEMAILVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSJSONVALUE, 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: ModelWithAppsyncScalarTypes.LISTOFAWSJSONVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSPHONEVALUE, 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: ModelWithAppsyncScalarTypes.LISTOFAWSPHONEVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSURLVALUE, 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: ModelWithAppsyncScalarTypes.LISTOFAWSURLVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ModelWithAppsyncScalarTypes.AWSIPADDRESSVALUE, 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: ModelWithAppsyncScalarTypes.LISTOFAWSIPADDRESSVALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - 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.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + 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 _ModelWithAppsyncScalarTypesModelType - extends ModelType { + extends amplify_core.ModelType { const _ModelWithAppsyncScalarTypesModelType(); @override ModelWithAppsyncScalarTypes fromJson(Map jsonData) { return ModelWithAppsyncScalarTypes.fromJson(jsonData); } + + @override + String modelName() { + return 'ModelWithAppsyncScalarTypes'; + } } -/// This is an auto generated class representing the model identifier -/// of [ModelWithAppsyncScalarTypes] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [ModelWithAppsyncScalarTypes] in your schema. + */ class ModelWithAppsyncScalarTypesModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of ModelWithAppsyncScalarTypesModelIdentifier using [id] the primary key. + /** Create an instance of ModelWithAppsyncScalarTypesModelIdentifier using [id] the primary key. */ const ModelWithAppsyncScalarTypesModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/ModelWithCustomType.dart b/packages/api/amplify_api_dart/test/test_models/ModelWithCustomType.dart index a2debc1197..f918c59a6b 100644 --- a/packages/api/amplify_api_dart/test/test_models/ModelWithCustomType.dart +++ b/packages/api/amplify_api_dart/test/test_models/ModelWithCustomType.dart @@ -1,27 +1,36 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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; +import 'package:collection/collection.dart'; -/// This is an auto generated class representing the ModelWithCustomType type in your schema. -@immutable -class ModelWithCustomType extends Model { - static const classType = _ModelWithCustomTypeModelType(); +/** This is an auto generated class representing the ModelWithCustomType type in your schema. */ +class ModelWithCustomType extends amplify_core.Model { + static const classType = const _ModelWithCustomTypeModelType(); final String id; final CustomTypeWithAppsyncScalarTypes? _customTypeValue; final List? _listOfCustomTypeValue; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -43,11 +52,11 @@ class ModelWithCustomType extends Model { return _listOfCustomTypeValue; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -67,7 +76,7 @@ class ModelWithCustomType extends Model { CustomTypeWithAppsyncScalarTypes? customTypeValue, List? listOfCustomTypeValue}) { return ModelWithCustomType._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, customTypeValue: customTypeValue, listOfCustomTypeValue: listOfCustomTypeValue != null ? List.unmodifiable( @@ -94,7 +103,7 @@ class ModelWithCustomType extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("ModelWithCustomType {"); buffer.write("id=" + "$id" + ", "); @@ -126,25 +135,38 @@ class ModelWithCustomType extends Model { listOfCustomTypeValue ?? this.listOfCustomTypeValue); } + ModelWithCustomType copyWithModelFieldValues( + {ModelFieldValue? customTypeValue, + ModelFieldValue?>? + listOfCustomTypeValue}) { + return ModelWithCustomType._internal( + id: id, + customTypeValue: customTypeValue == null + ? this.customTypeValue + : customTypeValue.value, + listOfCustomTypeValue: listOfCustomTypeValue == null + ? this.listOfCustomTypeValue + : listOfCustomTypeValue.value); + } + ModelWithCustomType.fromJson(Map json) : id = json['id'], - _customTypeValue = json['customTypeValue']?['serializedData'] != null + _customTypeValue = json['customTypeValue'] != null ? CustomTypeWithAppsyncScalarTypes.fromJson( - Map.from( - json['customTypeValue']['serializedData'])) + new Map.from(json['customTypeValue'])) : null, _listOfCustomTypeValue = json['listOfCustomTypeValue'] is List ? (json['listOfCustomTypeValue'] as List) .where((e) => e != null) .map((e) => CustomTypeWithAppsyncScalarTypes.fromJson( - Map.from(e['serializedData']))) + new Map.from(e))) .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() => { @@ -157,65 +179,87 @@ class ModelWithCustomType extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier + Map toMap() => { + 'id': id, + 'customTypeValue': _customTypeValue, + 'listOfCustomTypeValue': _listOfCustomTypeValue, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + static final amplify_core + .QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField CUSTOMTYPEVALUE = - QueryField(fieldName: "customTypeValue"); - static final QueryField LISTOFCUSTOMTYPEVALUE = - QueryField(fieldName: "listOfCustomTypeValue"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final CUSTOMTYPEVALUE = + amplify_core.QueryField(fieldName: "customTypeValue"); + static final LISTOFCUSTOMTYPEVALUE = + amplify_core.QueryField(fieldName: "listOfCustomTypeValue"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "ModelWithCustomType"; modelSchemaDefinition.pluralName = "ModelWithCustomTypes"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'customTypeValue', isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.embedded, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embedded, ofCustomTypeName: 'CustomTypeWithAppsyncScalarTypes'))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'listOfCustomTypeValue', isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embeddedCollection, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embeddedCollection, ofCustomTypeName: 'CustomTypeWithAppsyncScalarTypes'))); - 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 _ModelWithCustomTypeModelType extends ModelType { +class _ModelWithCustomTypeModelType + extends amplify_core.ModelType { const _ModelWithCustomTypeModelType(); @override ModelWithCustomType fromJson(Map jsonData) { return ModelWithCustomType.fromJson(jsonData); } + + @override + String modelName() { + return 'ModelWithCustomType'; + } } -/// This is an auto generated class representing the model identifier -/// of [ModelWithCustomType] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [ModelWithCustomType] in your schema. + */ class ModelWithCustomTypeModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of ModelWithCustomTypeModelIdentifier using [id] the primary key. + /** Create an instance of ModelWithCustomTypeModelIdentifier using [id] the primary key. */ const ModelWithCustomTypeModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/Post.dart b/packages/api/amplify_api_dart/test/test_models/Post.dart index db82de59c0..2db6a54c08 100644 --- a/packages/api/amplify_api_dart/test/test_models/Post.dart +++ b/packages/api/amplify_api_dart/test/test_models/Post.dart @@ -1,31 +1,40 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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; +import 'package:collection/collection.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 TemporalDateTime? _created; + final amplify_core.TemporalDateTime? _created; final Blog? _blog; final List? _comments; final List? _tags; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -43,10 +52,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()); } @@ -56,16 +65,16 @@ 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()); } } - TemporalDateTime? get created { + amplify_core.TemporalDateTime? get created { return _created; } @@ -81,11 +90,11 @@ class Post extends Model { return _tags; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -112,12 +121,12 @@ class Post extends Model { {String? id, required String title, required int rating, - TemporalDateTime? created, + amplify_core.TemporalDateTime? created, Blog? blog, List? comments, List? tags}) { return Post._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, title: title, rating: rating, created: created, @@ -149,7 +158,7 @@ class Post extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Post {"); buffer.write("id=" + "$id" + ", "); @@ -172,7 +181,7 @@ class Post extends Model { Post copyWith( {String? title, int? rating, - TemporalDateTime? created, + amplify_core.TemporalDateTime? created, Blog? blog, List? comments, List? tags}) { @@ -186,36 +195,71 @@ class Post extends Model { tags: tags ?? this.tags); } + Post copyWithModelFieldValues( + {ModelFieldValue? title, + ModelFieldValue? rating, + ModelFieldValue? created, + ModelFieldValue? blog, + ModelFieldValue?>? comments, + ModelFieldValue?>? tags}) { + return Post._internal( + id: id, + title: title == null ? this.title : title.value, + rating: rating == null ? this.rating : rating.value, + created: created == null ? this.created : created.value, + blog: blog == null ? this.blog : blog.value, + comments: comments == null ? this.comments : comments.value, + tags: tags == null ? this.tags : tags.value); + } + Post.fromJson(Map json) : id = json['id'], _title = json['title'], _rating = (json['rating'] as num?)?.toInt(), _created = json['created'] != null - ? TemporalDateTime.fromString(json['created']) - : null, - _blog = json['blog']?['serializedData'] != null - ? Blog.fromJson( - Map.from(json['blog']['serializedData'])) + ? amplify_core.TemporalDateTime.fromString(json['created']) : null, - _comments = json['comments'] is List - ? (json['comments'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Comment.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, - _tags = json['tags'] is List - ? (json['tags'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => PostTags.fromJson( - Map.from(e['serializedData']))) - .toList() + _blog = json['blog'] != null + ? json['blog']['serializedData'] != null + ? Blog.fromJson(new Map.from( + json['blog']['serializedData'])) + : Blog.fromJson(new Map.from(json['blog'])) : null, + _comments = json['comments'] is Map + ? (json['comments']['items'] is List + ? (json['comments']['items'] as List) + .where((e) => e != null) + .map((e) => + Comment.fromJson(new Map.from(e))) + .toList() + : null) + : (json['comments'] is List + ? (json['comments'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => Comment.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), + _tags = json['tags'] is Map + ? (json['tags']['items'] is List + ? (json['tags']['items'] as List) + .where((e) => e != null) + .map((e) => + PostTags.fromJson(new Map.from(e))) + .toList() + : null) + : (json['tags'] is List + ? (json['tags'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => PostTags.fromJson( + 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() => { @@ -230,98 +274,127 @@ class Post extends Model { 'updatedAt': _updatedAt?.format() }; - 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 CREATED = QueryField(fieldName: "created"); - static final QueryField BLOG = QueryField( + Map toMap() => { + 'id': id, + 'title': _title, + 'rating': _rating, + 'created': _created, + 'blog': _blog, + 'comments': _comments, + 'tags': _tags, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + 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 CREATED = amplify_core.QueryField(fieldName: "created"); + static final BLOG = amplify_core.QueryField( fieldName: "blog", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, - ofModelName: (Blog).toString())); - 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).toString())); - static final QueryField TAGS = QueryField( + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Comment')); + static final TAGS = amplify_core.QueryField( fieldName: "tags", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, - ofModelName: (PostTags).toString())); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'PostTags')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Post"; modelSchemaDefinition.pluralName = "Posts"; 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.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Post.CREATED, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: Post.BLOG, isRequired: false, - targetNames: ["blogID"], - ofModelName: (Blog).toString())); + targetNames: ['blogID'], + ofModelName: 'Blog')); - modelSchemaDefinition.addField(ModelFieldDefinition.hasMany( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany( key: Post.COMMENTS, isRequired: false, - ofModelName: (Comment).toString(), + ofModelName: 'Comment', associatedKey: Comment.POST)); - modelSchemaDefinition.addField(ModelFieldDefinition.hasMany( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany( key: Post.TAGS, isRequired: false, - ofModelName: (PostTags).toString(), + ofModelName: 'PostTags', associatedKey: PostTags.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 Post fromJson(Map jsonData) { return Post.fromJson(jsonData); } + + @override + String modelName() { + return 'Post'; + } } -/// 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_dart/test/test_models/PostTags.dart b/packages/api/amplify_api_dart/test/test_models/PostTags.dart index 7d56efc2d1..f37279e59f 100644 --- a/packages/api/amplify_api_dart/test/test_models/PostTags.dart +++ b/packages/api/amplify_api_dart/test/test_models/PostTags.dart @@ -1,26 +1,35 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 PostTags type in your schema. -@immutable -class PostTags extends Model { - static const classType = _PostTagsModelType(); +/** This is an auto generated class representing the PostTags type in your schema. */ +class PostTags extends amplify_core.Model { + static const classType = const _PostTagsModelType(); final String id; final Post? _post; final Tag? _tag; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -38,10 +47,10 @@ class PostTags extends Model { try { return _post!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -51,20 +60,20 @@ class PostTags extends Model { try { return _tag!; } 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; } @@ -77,7 +86,9 @@ class PostTags extends Model { factory PostTags({String? id, required Post post, required Tag tag}) { return PostTags._internal( - id: id == null ? UUID.getUUID() : id, post: post, tag: tag); + id: id == null ? amplify_core.UUID.getUUID() : id, + post: post, + tag: tag); } bool equals(Object other) { @@ -98,7 +109,7 @@ class PostTags extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("PostTags {"); buffer.write("id=" + "$id" + ", "); @@ -119,21 +130,33 @@ class PostTags extends Model { id: id, post: post ?? this.post, tag: tag ?? this.tag); } + PostTags copyWithModelFieldValues( + {ModelFieldValue? post, ModelFieldValue? tag}) { + return PostTags._internal( + id: id, + post: post == null ? this.post : post.value, + tag: tag == null ? this.tag : tag.value); + } + PostTags.fromJson(Map json) : id = json['id'], - _post = json['post']?['serializedData'] != null - ? Post.fromJson( - Map.from(json['post']['serializedData'])) + _post = json['post'] != null + ? json['post']['serializedData'] != null + ? Post.fromJson(new Map.from( + json['post']['serializedData'])) + : Post.fromJson(new Map.from(json['post'])) : null, - _tag = json['tag']?['serializedData'] != null - ? Tag.fromJson( - Map.from(json['tag']['serializedData'])) + _tag = json['tag'] != null + ? json['tag']['serializedData'] != null + ? Tag.fromJson(new Map.from( + json['tag']['serializedData'])) + : Tag.fromJson(new Map.from(json['tag'])) : 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() => { @@ -144,71 +167,93 @@ class PostTags extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField POST = QueryField( + Map toMap() => { + 'id': id, + 'post': _post, + 'tag': _tag, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + 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).toString())); - static final QueryField TAG = QueryField( + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Post')); + static final TAG = amplify_core.QueryField( fieldName: "tag", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, - ofModelName: (Tag).toString())); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'Tag')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "PostTags"; modelSchemaDefinition.pluralName = "PostTags"; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["postId"], name: "byPost"), - ModelIndex(fields: const ["tagId"], name: "byTag") + amplify_core.ModelIndex(fields: const ["postId"], name: "byPost"), + amplify_core.ModelIndex(fields: const ["tagId"], name: "byTag") ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: PostTags.POST, isRequired: true, - targetNames: ["postId"], - ofModelName: (Post).toString())); + targetNames: ['postId'], + ofModelName: 'Post')); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: PostTags.TAG, isRequired: true, - targetNames: ["tagId"], - ofModelName: (Tag).toString())); - - 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))); + targetNames: ['tagId'], + ofModelName: 'Tag')); + + 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 _PostTagsModelType extends ModelType { +class _PostTagsModelType extends amplify_core.ModelType { const _PostTagsModelType(); @override PostTags fromJson(Map jsonData) { return PostTags.fromJson(jsonData); } + + @override + String modelName() { + return 'PostTags'; + } } -/// This is an auto generated class representing the model identifier -/// of [PostTags] in your schema. -@immutable -class PostTagsModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [PostTags] in your schema. + */ +class PostTagsModelIdentifier + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of PostTagsModelIdentifier using [id] the primary key. + /** Create an instance of PostTagsModelIdentifier using [id] the primary key. */ const PostTagsModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/SimpleCustomType.dart b/packages/api/amplify_api_dart/test/test_models/SimpleCustomType.dart index 836e26b21d..e85ad89b9c 100644 --- a/packages/api/amplify_api_dart/test/test_models/SimpleCustomType.dart +++ b/packages/api/amplify_api_dart/test/test_models/SimpleCustomType.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,11 +19,10 @@ // 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:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the SimpleCustomType type in your schema. -@immutable +/** This is an auto generated class representing the SimpleCustomType type in your schema. */ class SimpleCustomType { final String? _foo; @@ -19,10 +30,10 @@ class SimpleCustomType { try { return _foo!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -49,7 +60,7 @@ class SimpleCustomType { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("SimpleCustomType {"); buffer.write("foo=" + "$_foo"); @@ -62,18 +73,26 @@ class SimpleCustomType { return SimpleCustomType._internal(foo: foo ?? this.foo); } + SimpleCustomType copyWithModelFieldValues({ModelFieldValue? foo}) { + return SimpleCustomType._internal(foo: foo == null ? this.foo : foo.value); + } + SimpleCustomType.fromJson(Map json) : _foo = json['foo']; Map toJson() => {'foo': _foo}; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + Map toMap() => {'foo': _foo}; + + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "SimpleCustomType"; modelSchemaDefinition.pluralName = "SimpleCustomTypes"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'foo', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'foo', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); }); } diff --git a/packages/api/amplify_api_dart/test/test_models/Tag.dart b/packages/api/amplify_api_dart/test/test_models/Tag.dart index 1d0ad18bef..ae2168a7e7 100644 --- a/packages/api/amplify_api_dart/test/test_models/Tag.dart +++ b/packages/api/amplify_api_dart/test/test_models/Tag.dart @@ -1,27 +1,36 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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; +import 'package:collection/collection.dart'; -/// This is an auto generated class representing the Tag type in your schema. -@immutable -class Tag extends Model { - static const classType = _TagModelType(); +/** This is an auto generated class representing the Tag type in your schema. */ +class Tag extends amplify_core.Model { + static const classType = const _TagModelType(); final String id; final String? _label; final List? _posts; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -39,10 +48,10 @@ class Tag extends Model { try { return _label!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -52,11 +61,11 @@ class Tag extends Model { return _posts; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -69,7 +78,7 @@ class Tag extends Model { factory Tag({String? id, required String label, List? posts}) { return Tag._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, label: label, posts: posts != null ? List.unmodifiable(posts) : posts); } @@ -92,7 +101,7 @@ class Tag extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Tag {"); buffer.write("id=" + "$id" + ", "); @@ -112,21 +121,38 @@ class Tag extends Model { id: id, label: label ?? this.label, posts: posts ?? this.posts); } + Tag copyWithModelFieldValues( + {ModelFieldValue? label, + ModelFieldValue?>? posts}) { + return Tag._internal( + id: id, + label: label == null ? this.label : label.value, + posts: posts == null ? this.posts : posts.value); + } + Tag.fromJson(Map json) : id = json['id'], _label = json['label'], - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => PostTags.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, + _posts = json['posts'] is Map + ? (json['posts']['items'] is List + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => + PostTags.fromJson(new Map.from(e))) + .toList() + : null) + : (json['posts'] is List + ? (json['posts'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => PostTags.fromJson( + 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() => { @@ -137,62 +163,83 @@ class Tag extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField LABEL = QueryField(fieldName: "label"); - static final QueryField POSTS = QueryField( + Map toMap() => { + 'id': id, + 'label': _label, + 'posts': _posts, + 'createdAt': _createdAt, + 'updatedAt': _updatedAt + }; + + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final LABEL = amplify_core.QueryField(fieldName: "label"); + static final POSTS = amplify_core.QueryField( fieldName: "posts", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, - ofModelName: (PostTags).toString())); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, + ofModelName: 'PostTags')); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Tag"; modelSchemaDefinition.pluralName = "Tags"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Tag.LABEL, 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: Tag.POSTS, isRequired: false, - ofModelName: (PostTags).toString(), + ofModelName: 'PostTags', associatedKey: PostTags.TAG)); - 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 _TagModelType extends ModelType { +class _TagModelType extends amplify_core.ModelType { const _TagModelType(); @override Tag fromJson(Map jsonData) { return Tag.fromJson(jsonData); } + + @override + String modelName() { + return 'Tag'; + } } -/// This is an auto generated class representing the model identifier -/// of [Tag] in your schema. -@immutable -class TagModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Tag] in your schema. + */ +class TagModelIdentifier implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of TagModelIdentifier using [id] the primary key. + /** Create an instance of TagModelIdentifier using [id] the primary key. */ const TagModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/many_to_many/FirstMtmRelation.dart b/packages/api/amplify_api_dart/test/test_models/many_to_many/FirstMtmRelation.dart index 66d60bd795..f1b05c011c 100644 --- a/packages/api/amplify_api_dart/test/test_models/many_to_many/FirstMtmRelation.dart +++ b/packages/api/amplify_api_dart/test/test_models/many_to_many/FirstMtmRelation.dart @@ -1,26 +1,35 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 'MtmModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the FirstMtmRelation type in your schema. - -class FirstMtmRelation extends Model { - static const classType = _FirstMtmRelationModelType(); +/** This is an auto generated class representing the FirstMtmRelation type in your schema. */ +class FirstMtmRelation extends amplify_core.Model { + static const classType = const _FirstMtmRelationModelType(); final String id; final ManyToManyPrimary? _manyToManyPrimary; final ManyToManySecondary? _manyToManySecondary; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -38,10 +47,10 @@ class FirstMtmRelation extends Model { try { return _manyToManyPrimary!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -51,20 +60,20 @@ class FirstMtmRelation extends Model { try { return _manyToManySecondary!; } 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; } @@ -84,7 +93,7 @@ class FirstMtmRelation extends Model { required ManyToManyPrimary manyToManyPrimary, required ManyToManySecondary manyToManySecondary}) { return FirstMtmRelation._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, manyToManyPrimary: manyToManyPrimary, manyToManySecondary: manyToManySecondary); } @@ -107,7 +116,7 @@ class FirstMtmRelation extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("FirstMtmRelation {"); buffer.write("id=" + "$id" + ", "); @@ -138,23 +147,40 @@ class FirstMtmRelation extends Model { manyToManySecondary: manyToManySecondary ?? this.manyToManySecondary); } + FirstMtmRelation copyWithModelFieldValues( + {ModelFieldValue? manyToManyPrimary, + ModelFieldValue? manyToManySecondary}) { + return FirstMtmRelation._internal( + id: id, + manyToManyPrimary: manyToManyPrimary == null + ? this.manyToManyPrimary + : manyToManyPrimary.value, + manyToManySecondary: manyToManySecondary == null + ? this.manyToManySecondary + : manyToManySecondary.value); + } + FirstMtmRelation.fromJson(Map json) : id = json['id'], - _manyToManyPrimary = - json['manyToManyPrimary']?['serializedData'] != null - ? ManyToManyPrimary.fromJson(Map.from( + _manyToManyPrimary = json['manyToManyPrimary'] != null + ? json['manyToManyPrimary']['serializedData'] != null + ? ManyToManyPrimary.fromJson(new Map.from( json['manyToManyPrimary']['serializedData'])) - : null, - _manyToManySecondary = - json['manyToManySecondary']?['serializedData'] != null - ? ManyToManySecondary.fromJson(Map.from( + : ManyToManyPrimary.fromJson( + new Map.from(json['manyToManyPrimary'])) + : null, + _manyToManySecondary = json['manyToManySecondary'] != null + ? json['manyToManySecondary']['serializedData'] != null + ? ManyToManySecondary.fromJson(new Map.from( json['manyToManySecondary']['serializedData'])) - : null, + : ManyToManySecondary.fromJson( + new Map.from(json['manyToManySecondary'])) + : 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() => { @@ -173,60 +199,67 @@ class FirstMtmRelation extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier - MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField MANYTOMANYPRIMARY = QueryField( + static final amplify_core + .QueryModelIdentifier MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final MANYTOMANYPRIMARY = amplify_core.QueryField( fieldName: "manyToManyPrimary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'ManyToManyPrimary')); - static final QueryField MANYTOMANYSECONDARY = QueryField( + static final MANYTOMANYSECONDARY = amplify_core.QueryField( fieldName: "manyToManySecondary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'ManyToManySecondary')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "FirstMtmRelation"; modelSchemaDefinition.pluralName = "FirstMtmRelations"; modelSchemaDefinition.indexes = [ - ModelIndex( + amplify_core.ModelIndex( fields: const ["manyToManyPrimaryId"], name: "byManyToManyPrimary"), - ModelIndex( + amplify_core.ModelIndex( fields: const ["manyToManySecondaryId"], name: "byManyToManySecondary") ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: FirstMtmRelation.MANYTOMANYPRIMARY, isRequired: true, targetNames: ['manyToManyPrimaryId'], ofModelName: 'ManyToManyPrimary')); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: FirstMtmRelation.MANYTOMANYSECONDARY, isRequired: true, targetNames: ['manyToManySecondaryId'], ofModelName: 'ManyToManySecondary')); - 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 _FirstMtmRelationModelType extends ModelType { +class _FirstMtmRelationModelType + extends amplify_core.ModelType { const _FirstMtmRelationModelType(); @override @@ -240,14 +273,15 @@ class _FirstMtmRelationModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [FirstMtmRelation] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [FirstMtmRelation] in your schema. + */ class FirstMtmRelationModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of FirstMtmRelationModelIdentifier using [id] the primary key. + /** Create an instance of FirstMtmRelationModelIdentifier using [id] the primary key. */ const FirstMtmRelationModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManyPrimary.dart b/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManyPrimary.dart index 4499ed6163..04dfc3d52a 100644 --- a/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManyPrimary.dart +++ b/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManyPrimary.dart @@ -1,28 +1,37 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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 'MtmModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; +import 'package:collection/collection.dart'; -/// This is an auto generated class representing the ManyToManyPrimary type in your schema. -@immutable -class ManyToManyPrimary extends Model { - static const classType = _ManyToManyPrimaryModelType(); +/** This is an auto generated class representing the ManyToManyPrimary type in your schema. */ +class ManyToManyPrimary extends amplify_core.Model { + static const classType = const _ManyToManyPrimaryModelType(); final String id; final String? _name; final List? _firstMtmToSecondary; final List? _secondMtmToSecondary; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -40,10 +49,10 @@ class ManyToManyPrimary 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()); } @@ -57,11 +66,11 @@ class ManyToManyPrimary extends Model { return _secondMtmToSecondary; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -84,7 +93,7 @@ class ManyToManyPrimary extends Model { List? firstMtmToSecondary, List? secondMtmToSecondary}) { return ManyToManyPrimary._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, firstMtmToSecondary: firstMtmToSecondary != null ? List.unmodifiable(firstMtmToSecondary) @@ -115,7 +124,7 @@ class ManyToManyPrimary extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("ManyToManyPrimary {"); buffer.write("id=" + "$id" + ", "); @@ -142,28 +151,59 @@ class ManyToManyPrimary extends Model { secondMtmToSecondary ?? this.secondMtmToSecondary); } + ManyToManyPrimary copyWithModelFieldValues( + {ModelFieldValue? name, + ModelFieldValue?>? firstMtmToSecondary, + ModelFieldValue?>? secondMtmToSecondary}) { + return ManyToManyPrimary._internal( + id: id, + name: name == null ? this.name : name.value, + firstMtmToSecondary: firstMtmToSecondary == null + ? this.firstMtmToSecondary + : firstMtmToSecondary.value, + secondMtmToSecondary: secondMtmToSecondary == null + ? this.secondMtmToSecondary + : secondMtmToSecondary.value); + } + ManyToManyPrimary.fromJson(Map json) : id = json['id'], _name = json['name'], - _firstMtmToSecondary = json['firstMtmToSecondary'] is List - ? (json['firstMtmToSecondary'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => FirstMtmRelation.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, - _secondMtmToSecondary = json['secondMtmToSecondary'] is List - ? (json['secondMtmToSecondary'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => SecondMtmRelation.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, + _firstMtmToSecondary = json['firstMtmToSecondary'] is Map + ? (json['firstMtmToSecondary']['items'] is List + ? (json['firstMtmToSecondary']['items'] as List) + .where((e) => e != null) + .map((e) => FirstMtmRelation.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['firstMtmToSecondary'] is List + ? (json['firstMtmToSecondary'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => FirstMtmRelation.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), + _secondMtmToSecondary = json['secondMtmToSecondary'] is Map + ? (json['secondMtmToSecondary']['items'] is List + ? (json['secondMtmToSecondary']['items'] as List) + .where((e) => e != null) + .map((e) => SecondMtmRelation.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['secondMtmToSecondary'] is List + ? (json['secondMtmToSecondary'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => SecondMtmRelation.fromJson( + 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() => { @@ -188,58 +228,66 @@ class ManyToManyPrimary 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 FIRSTMTMTOSECONDARY = 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 FIRSTMTMTOSECONDARY = amplify_core.QueryField( fieldName: "firstMtmToSecondary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'FirstMtmRelation')); - static final QueryField SECONDMTMTOSECONDARY = QueryField( + static final SECONDMTMTOSECONDARY = amplify_core.QueryField( fieldName: "secondMtmToSecondary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'SecondMtmRelation')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "ManyToManyPrimary"; modelSchemaDefinition.pluralName = "ManyToManyPrimaries"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ManyToManyPrimary.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: ManyToManyPrimary.FIRSTMTMTOSECONDARY, isRequired: false, ofModelName: 'FirstMtmRelation', associatedKey: FirstMtmRelation.MANYTOMANYPRIMARY)); - modelSchemaDefinition.addField(ModelFieldDefinition.hasMany( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany( key: ManyToManyPrimary.SECONDMTMTOSECONDARY, isRequired: false, ofModelName: 'SecondMtmRelation', associatedKey: SecondMtmRelation.MANYTOMANYPRIMARY)); - 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 _ManyToManyPrimaryModelType extends ModelType { +class _ManyToManyPrimaryModelType + extends amplify_core.ModelType { const _ManyToManyPrimaryModelType(); @override @@ -253,14 +301,15 @@ class _ManyToManyPrimaryModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [ManyToManyPrimary] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [ManyToManyPrimary] in your schema. + */ class ManyToManyPrimaryModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of ManyToManyPrimaryModelIdentifier using [id] the primary key. + /** Create an instance of ManyToManyPrimaryModelIdentifier using [id] the primary key. */ const ManyToManyPrimaryModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManySecondary.dart b/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManySecondary.dart index 1e142f3fcf..3e62ac6b32 100644 --- a/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManySecondary.dart +++ b/packages/api/amplify_api_dart/test/test_models/many_to_many/ManyToManySecondary.dart @@ -1,28 +1,37 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - // 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 'MtmModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; +import 'package:collection/collection.dart'; -/// This is an auto generated class representing the ManyToManySecondary type in your schema. -@immutable -class ManyToManySecondary extends Model { - static const classType = _ManyToManySecondaryModelType(); +/** This is an auto generated class representing the ManyToManySecondary type in your schema. */ +class ManyToManySecondary extends amplify_core.Model { + static const classType = const _ManyToManySecondaryModelType(); final String id; final String? _name; final List? _firstMtmToPrimary; final List? _secondMtmToPrimary; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -40,10 +49,10 @@ class ManyToManySecondary 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()); } @@ -57,11 +66,11 @@ class ManyToManySecondary extends Model { return _secondMtmToPrimary; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -84,7 +93,7 @@ class ManyToManySecondary extends Model { List? firstMtmToPrimary, List? secondMtmToPrimary}) { return ManyToManySecondary._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, firstMtmToPrimary: firstMtmToPrimary != null ? List.unmodifiable(firstMtmToPrimary) @@ -115,7 +124,7 @@ class ManyToManySecondary extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("ManyToManySecondary {"); buffer.write("id=" + "$id" + ", "); @@ -141,28 +150,59 @@ class ManyToManySecondary extends Model { secondMtmToPrimary: secondMtmToPrimary ?? this.secondMtmToPrimary); } + ManyToManySecondary copyWithModelFieldValues( + {ModelFieldValue? name, + ModelFieldValue?>? firstMtmToPrimary, + ModelFieldValue?>? secondMtmToPrimary}) { + return ManyToManySecondary._internal( + id: id, + name: name == null ? this.name : name.value, + firstMtmToPrimary: firstMtmToPrimary == null + ? this.firstMtmToPrimary + : firstMtmToPrimary.value, + secondMtmToPrimary: secondMtmToPrimary == null + ? this.secondMtmToPrimary + : secondMtmToPrimary.value); + } + ManyToManySecondary.fromJson(Map json) : id = json['id'], _name = json['name'], - _firstMtmToPrimary = json['firstMtmToPrimary'] is List - ? (json['firstMtmToPrimary'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => FirstMtmRelation.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, - _secondMtmToPrimary = json['secondMtmToPrimary'] is List - ? (json['secondMtmToPrimary'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => SecondMtmRelation.fromJson( - Map.from(e['serializedData']))) - .toList() - : null, + _firstMtmToPrimary = json['firstMtmToPrimary'] is Map + ? (json['firstMtmToPrimary']['items'] is List + ? (json['firstMtmToPrimary']['items'] as List) + .where((e) => e != null) + .map((e) => FirstMtmRelation.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['firstMtmToPrimary'] is List + ? (json['firstMtmToPrimary'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => FirstMtmRelation.fromJson( + new Map.from(e?['serializedData']))) + .toList() + : null), + _secondMtmToPrimary = json['secondMtmToPrimary'] is Map + ? (json['secondMtmToPrimary']['items'] is List + ? (json['secondMtmToPrimary']['items'] as List) + .where((e) => e != null) + .map((e) => SecondMtmRelation.fromJson( + new Map.from(e))) + .toList() + : null) + : (json['secondMtmToPrimary'] is List + ? (json['secondMtmToPrimary'] as List) + .where((e) => e?['serializedData'] != null) + .map((e) => SecondMtmRelation.fromJson( + 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() => { @@ -187,58 +227,67 @@ class ManyToManySecondary extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier + static final amplify_core + .QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField FIRSTMTMTOPRIMARY = QueryField( + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final FIRSTMTMTOPRIMARY = amplify_core.QueryField( fieldName: "firstMtmToPrimary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'FirstMtmRelation')); - static final QueryField SECONDMTMTOPRIMARY = QueryField( + static final SECONDMTMTOPRIMARY = amplify_core.QueryField( fieldName: "secondMtmToPrimary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'SecondMtmRelation')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "ManyToManySecondary"; modelSchemaDefinition.pluralName = "ManyToManySecondaries"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: ManyToManySecondary.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: ManyToManySecondary.FIRSTMTMTOPRIMARY, isRequired: false, ofModelName: 'FirstMtmRelation', associatedKey: FirstMtmRelation.MANYTOMANYSECONDARY)); - modelSchemaDefinition.addField(ModelFieldDefinition.hasMany( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany( key: ManyToManySecondary.SECONDMTMTOPRIMARY, isRequired: false, ofModelName: 'SecondMtmRelation', associatedKey: SecondMtmRelation.MANYTOMANYSECONDARY)); - 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 _ManyToManySecondaryModelType extends ModelType { +class _ManyToManySecondaryModelType + extends amplify_core.ModelType { const _ManyToManySecondaryModelType(); @override @@ -252,14 +301,15 @@ class _ManyToManySecondaryModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [ManyToManySecondary] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [ManyToManySecondary] in your schema. + */ class ManyToManySecondaryModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of ManyToManySecondaryModelIdentifier using [id] the primary key. + /** Create an instance of ManyToManySecondaryModelIdentifier using [id] the primary key. */ const ManyToManySecondaryModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/many_to_many/MtmModelProvider.dart b/packages/api/amplify_api_dart/test/test_models/many_to_many/MtmModelProvider.dart index 8f5b58e2d7..81f8446f30 100644 --- a/packages/api/amplify_api_dart/test/test_models/many_to_many/MtmModelProvider.dart +++ b/packages/api/amplify_api_dart/test/test_models/many_to_many/MtmModelProvider.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,8 +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 'FirstMtmRelation.dart'; import 'ManyToManyPrimary.dart'; import 'ManyToManySecondary.dart'; @@ -19,22 +30,23 @@ export 'ManyToManyPrimary.dart'; export 'ManyToManySecondary.dart'; export 'SecondMtmRelation.dart'; -class MtmModelProvider implements ModelProviderInterface { +class MtmModelProvider implements amplify_core.ModelProviderInterface { @override - String version = "6c15e1d35037e37b184fd64a6321118f"; + String version = "25315a5e375e0bf823bb2d5924460181"; @override - List modelSchemas = [ + List modelSchemas = [ FirstMtmRelation.schema, ManyToManyPrimary.schema, - ManyToManySecondary.schema + ManyToManySecondary.schema, + SecondMtmRelation.schema ]; - static final MtmModelProvider _instance = MtmModelProvider(); @override - List customTypeSchemas = []; + List customTypeSchemas = []; + static final MtmModelProvider _instance = MtmModelProvider(); static MtmModelProvider get instance => _instance; - ModelType getModelTypeByModelName(String modelName) { + amplify_core.ModelType getModelTypeByModelName(String modelName) { switch (modelName) { case "FirstMtmRelation": return FirstMtmRelation.classType; @@ -42,6 +54,8 @@ class MtmModelProvider implements ModelProviderInterface { return ManyToManyPrimary.classType; case "ManyToManySecondary": return ManyToManySecondary.classType; + case "SecondMtmRelation": + return SecondMtmRelation.classType; default: throw Exception( "Failed to find model in model provider for model name: " + @@ -49,3 +63,9 @@ class MtmModelProvider implements ModelProviderInterface { } } } + +class ModelFieldValue { + const ModelFieldValue.value(this.value); + + final T value; +} diff --git a/packages/api/amplify_api_dart/test/test_models/many_to_many/SecondMtmRelation.dart b/packages/api/amplify_api_dart/test/test_models/many_to_many/SecondMtmRelation.dart index 8a5aef52fc..03d8f881c1 100644 --- a/packages/api/amplify_api_dart/test/test_models/many_to_many/SecondMtmRelation.dart +++ b/packages/api/amplify_api_dart/test/test_models/many_to_many/SecondMtmRelation.dart @@ -1,26 +1,35 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - // 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 'MtmModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the SecondMtmRelation type in your schema. -@immutable -class SecondMtmRelation extends Model { - static const classType = _SecondMtmRelationModelType(); +/** This is an auto generated class representing the SecondMtmRelation type in your schema. */ +class SecondMtmRelation extends amplify_core.Model { + static const classType = const _SecondMtmRelationModelType(); final String id; final ManyToManyPrimary? _manyToManyPrimary; final ManyToManySecondary? _manyToManySecondary; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -38,10 +47,10 @@ class SecondMtmRelation extends Model { try { return _manyToManyPrimary!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -51,20 +60,20 @@ class SecondMtmRelation extends Model { try { return _manyToManySecondary!; } 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; } @@ -84,7 +93,7 @@ class SecondMtmRelation extends Model { required ManyToManyPrimary manyToManyPrimary, required ManyToManySecondary manyToManySecondary}) { return SecondMtmRelation._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, manyToManyPrimary: manyToManyPrimary, manyToManySecondary: manyToManySecondary); } @@ -107,7 +116,7 @@ class SecondMtmRelation extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("SecondMtmRelation {"); buffer.write("id=" + "$id" + ", "); @@ -138,23 +147,40 @@ class SecondMtmRelation extends Model { manyToManySecondary: manyToManySecondary ?? this.manyToManySecondary); } + SecondMtmRelation copyWithModelFieldValues( + {ModelFieldValue? manyToManyPrimary, + ModelFieldValue? manyToManySecondary}) { + return SecondMtmRelation._internal( + id: id, + manyToManyPrimary: manyToManyPrimary == null + ? this.manyToManyPrimary + : manyToManyPrimary.value, + manyToManySecondary: manyToManySecondary == null + ? this.manyToManySecondary + : manyToManySecondary.value); + } + SecondMtmRelation.fromJson(Map json) : id = json['id'], - _manyToManyPrimary = - json['manyToManyPrimary']?['serializedData'] != null - ? ManyToManyPrimary.fromJson(Map.from( + _manyToManyPrimary = json['manyToManyPrimary'] != null + ? json['manyToManyPrimary']['serializedData'] != null + ? ManyToManyPrimary.fromJson(new Map.from( json['manyToManyPrimary']['serializedData'])) - : null, - _manyToManySecondary = - json['manyToManySecondary']?['serializedData'] != null - ? ManyToManySecondary.fromJson(Map.from( + : ManyToManyPrimary.fromJson( + new Map.from(json['manyToManyPrimary'])) + : null, + _manyToManySecondary = json['manyToManySecondary'] != null + ? json['manyToManySecondary']['serializedData'] != null + ? ManyToManySecondary.fromJson(new Map.from( json['manyToManySecondary']['serializedData'])) - : null, + : ManyToManySecondary.fromJson( + new Map.from(json['manyToManySecondary'])) + : 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() => { @@ -173,60 +199,67 @@ class SecondMtmRelation extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier - MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField MANYTOMANYPRIMARY = QueryField( + static final amplify_core + .QueryModelIdentifier MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final MANYTOMANYPRIMARY = amplify_core.QueryField( fieldName: "manyToManyPrimary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'ManyToManyPrimary')); - static final QueryField MANYTOMANYSECONDARY = QueryField( + static final MANYTOMANYSECONDARY = amplify_core.QueryField( fieldName: "manyToManySecondary", - fieldType: ModelFieldType(ModelFieldTypeEnum.model, + fieldType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.model, ofModelName: 'ManyToManySecondary')); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "SecondMtmRelation"; modelSchemaDefinition.pluralName = "SecondMtmRelations"; modelSchemaDefinition.indexes = [ - ModelIndex( + amplify_core.ModelIndex( fields: const ["manyToManyPrimaryId"], name: "byManyToManyPrimary"), - ModelIndex( + amplify_core.ModelIndex( fields: const ["manyToManySecondaryId"], name: "byManyToManySecondary") ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: SecondMtmRelation.MANYTOMANYPRIMARY, isRequired: true, targetNames: ['manyToManyPrimaryId'], ofModelName: 'ManyToManyPrimary')); - modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo( key: SecondMtmRelation.MANYTOMANYSECONDARY, isRequired: true, targetNames: ['manyToManySecondaryId'], ofModelName: 'ManyToManySecondary')); - 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 _SecondMtmRelationModelType extends ModelType { +class _SecondMtmRelationModelType + extends amplify_core.ModelType { const _SecondMtmRelationModelType(); @override @@ -240,14 +273,15 @@ class _SecondMtmRelationModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [SecondMtmRelation] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [SecondMtmRelation] in your schema. + */ class SecondMtmRelationModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of SecondMtmRelationModelIdentifier using [id] the primary key. + /** Create an instance of SecondMtmRelationModelIdentifier using [id] the primary key. */ const SecondMtmRelationModelIdentifier({required this.id}); @override diff --git a/packages/api/amplify_api_dart/test/test_models/schema.graphql b/packages/api/amplify_api_dart/test/test_models/schema.graphql index da9e8ac69e..c7f0ed5184 100644 --- a/packages/api/amplify_api_dart/test/test_models/schema.graphql +++ b/packages/api/amplify_api_dart/test/test_models/schema.graphql @@ -134,19 +134,21 @@ type CpkOneToOneBidirectionalChildExplicitCD @model { @belongsTo(fields: ["belongsToParentID", "belongsToParentName"]) } -type CpkIntIndexes @model @auth(rules: [{allow: owner}]) { - name: String! @primaryKey(sortKeyFields: ["fieldA", "fieldB"]), - fieldA: Int!, - fieldB: Int!, +type CpkIntIndexes @model @auth(rules: [{ allow: owner }]) { + name: String! @primaryKey(sortKeyFields: ["fieldA", "fieldB"]) + fieldA: Int! + fieldB: Int! } -type CpkIntPrimaryKey @model @auth(rules: [{allow: owner}]) { - intAsId: Int! @primaryKey(sortKeyFields: ["fieldA", "fieldB"]), - fieldA: Int!, - fieldB: Int!, +type CpkIntPrimaryKey @model @auth(rules: [{ allow: owner }]) { + intAsId: Int! @primaryKey(sortKeyFields: ["fieldA", "fieldB"]) + fieldA: Int! + fieldB: Int! } -type CustomOwnerField @model @auth(rules: [{ allow: private }, { allow: owner, ownerField: "owners" }]) { +type CustomOwnerField + @model + @auth(rules: [{ allow: private }, { allow: owner, ownerField: "owners" }]) { id: ID! name: String! owners: [String] diff --git a/packages/api/amplify_api_dart/test/test_models/utils.dart b/packages/api/amplify_api_dart/test/test_models/utils.dart new file mode 100644 index 0000000000..ef3289f23d --- /dev/null +++ b/packages/api/amplify_api_dart/test/test_models/utils.dart @@ -0,0 +1,9 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +String describeEnum(Object enumEntry) { + final String description = enumEntry.toString(); + final int indexOfDot = description.indexOf('.'); + assert(indexOfDot != -1 && indexOfDot < description.length - 1); + return description.substring(indexOfDot + 1); +} diff --git a/packages/test/amplify_test/lib/test_models/Address.dart b/packages/test/amplify_test/lib/test_models/Address.dart index a00de00ef9..6b90cdaea7 100644 --- a/packages/test/amplify_test/lib/test_models/Address.dart +++ b/packages/test/amplify_test/lib/test_models/Address.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,11 +19,10 @@ // 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:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the Address type in your schema. -@immutable +/** This is an auto generated class representing the Address type in your schema. */ class Address { final String? _line1; final String? _line2; @@ -23,10 +34,10 @@ class Address { try { return _line1!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -40,10 +51,10 @@ class Address { try { return _city!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -53,10 +64,10 @@ class Address { try { return _state!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -66,10 +77,10 @@ class Address { try { return _postalCode!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -121,7 +132,7 @@ class Address { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Address {"); buffer.write("line1=" + "$_line1" + ", "); @@ -148,6 +159,20 @@ class Address { postalCode: postalCode ?? this.postalCode); } + Address copyWithModelFieldValues( + {ModelFieldValue? line1, + ModelFieldValue? line2, + ModelFieldValue? city, + ModelFieldValue? state, + ModelFieldValue? postalCode}) { + return Address._internal( + line1: line1 == null ? this.line1 : line1.value, + line2: line2 == null ? this.line2 : line2.value, + city: city == null ? this.city : city.value, + state: state == null ? this.state : state.value, + postalCode: postalCode == null ? this.postalCode : postalCode.value); + } + Address.fromJson(Map json) : _line1 = json['line1'], _line2 = json['line2'], @@ -171,34 +196,44 @@ class Address { 'postalCode': _postalCode }; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Address"; modelSchemaDefinition.pluralName = "Addresses"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'line1', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'line2', - isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'city', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'state', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'postalCode', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'line1', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'line2', + isRequired: false, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'city', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'state', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'postalCode', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); }); } diff --git a/packages/test/amplify_test/lib/test_models/Blog.dart b/packages/test/amplify_test/lib/test_models/Blog.dart index 6d9d75e4d6..68047c420c 100644 --- a/packages/test/amplify_test/lib/test_models/Blog.dart +++ b/packages/test/amplify_test/lib/test_models/Blog.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -8,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:meta/meta.dart'; -/// This is an auto generated class representing the Blog type in your schema. -@immutable -class Blog extends Model { - static const classType = _BlogModelType(); +/** This is an auto generated class representing the Blog type in your schema. */ +class Blog extends amplify_core.Model { + static const classType = const _BlogModelType(); final String id; final String? _name; - final TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _createdAt; final S3Object? _file; final List? _files; final List? _posts; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -40,16 +50,16 @@ 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()); } } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } @@ -65,7 +75,7 @@ class Blog extends Model { return _posts; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -87,12 +97,12 @@ class Blog extends Model { factory Blog( {String? id, required String name, - TemporalDateTime? createdAt, + amplify_core.TemporalDateTime? createdAt, S3Object? file, List? files, List? posts}) { return Blog._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, createdAt: createdAt, file: file, @@ -121,7 +131,7 @@ class Blog extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Blog {"); buffer.write("id=" + "$id" + ", "); @@ -141,7 +151,7 @@ class Blog extends Model { Blog copyWith( {String? name, - TemporalDateTime? createdAt, + amplify_core.TemporalDateTime? createdAt, S3Object? file, List? files, List? posts}) { @@ -154,32 +164,44 @@ class Blog extends Model { posts: posts ?? this.posts); } + Blog copyWithModelFieldValues( + {ModelFieldValue? name, + ModelFieldValue? createdAt, + ModelFieldValue? file, + ModelFieldValue?>? files, + ModelFieldValue?>? posts}) { + return Blog._internal( + id: id, + name: name == null ? this.name : name.value, + createdAt: createdAt == null ? this.createdAt : createdAt.value, + file: file == null ? this.file : file.value, + files: files == null ? this.files : files.value, + posts: posts == null ? this.posts : posts.value); + } + Blog.fromJson(Map json) : id = json['id'], _name = json['name'], _createdAt = json['createdAt'] != null - ? TemporalDateTime.fromString(json['createdAt']) + ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null, - _file = json['file']?['serializedData'] != null - ? S3Object.fromJson( - Map.from(json['file']['serializedData'])) + _file = json['file'] != null + ? S3Object.fromJson(new Map.from(json['file'])) : null, _files = json['files'] is List ? (json['files'] as List) .where((e) => e != null) - .map((e) => S3Object.fromJson( - Map.from(e['serializedData']))) + .map((e) => S3Object.fromJson(new Map.from(e))) .toList() : null, - _posts = json['posts'] is List - ? (json['posts'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Post.fromJson( - Map.from(e['serializedData']))) + _posts = json['posts'] != null + ? (json['posts']['items'] as List) + .where((e) => e != null) + .map((e) => Post.fromJson(new Map.from(e))) .toList() : null, _updatedAt = json['updatedAt'] != null - ? TemporalDateTime.fromString(json['updatedAt']) + ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { @@ -202,65 +224,74 @@ 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 CREATEDAT = QueryField(fieldName: "createdAt"); - static final QueryField FILE = QueryField(fieldName: "file"); - static final QueryField FILES = QueryField(fieldName: "files"); - 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 CREATEDAT = amplify_core.QueryField(fieldName: "createdAt"); + static final FILE = amplify_core.QueryField(fieldName: "file"); + static final FILES = amplify_core.QueryField(fieldName: "files"); + 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.indexes = [ - ModelIndex(fields: const ["id"], name: null) + amplify_core.ModelIndex(fields: const ["id"], name: null) ]; - 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.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Blog.CREATEDAT, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'file', isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.embedded, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embedded, ofCustomTypeName: 'S3Object'))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'files', isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embeddedCollection, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embeddedCollection, ofCustomTypeName: 'S3Object'))); - 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: 'updatedAt', - isRequired: false, - isReadOnly: true, - ofType: ModelFieldType(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 @@ -274,13 +305,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/test/amplify_test/lib/test_models/Comment.dart b/packages/test/amplify_test/lib/test_models/Comment.dart index 4adb1e8153..979617e018 100644 --- a/packages/test/amplify_test/lib/test_models/Comment.dart +++ b/packages/test/amplify_test/lib/test_models/Comment.dart @@ -1,29 +1,38 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; - -// 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, implicit_dynamic_parameter, implicit_dynamic_map_literal, implicit_dynamic_type +// 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 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 - _CommentModelType getInstanceType() => classType; + getInstanceType() => classType; @Deprecated( '[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') @@ -42,28 +51,23 @@ 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; } - factory Comment({String? id, Post? post, required String content}) { - return Comment._internal( - id: id == null ? UUID.getUUID() : id, post: post, content: content); - } - const Comment._internal( {required this.id, post, required content, createdAt, updatedAt}) : _post = post, @@ -71,6 +75,13 @@ class Comment extends Model { _createdAt = createdAt, _updatedAt = updatedAt; + factory Comment({String? id, Post? post, required String content}) { + return Comment._internal( + id: id == null ? amplify_core.UUID.getUUID() : id, + post: post, + content: content); + } + bool equals(Object other) { return this == other; } @@ -89,18 +100,18 @@ class Comment extends Model { @override String toString() { - var buffer = StringBuffer(); - - buffer.write('Comment {'); - buffer.write('id=' + '$id' + ', '); - buffer.write('post=' + (_post != null ? _post!.toString() : 'null') + ', '); - buffer.write('content=' + '$_content' + ', '); - buffer.write('createdAt=' + - (_createdAt != null ? _createdAt!.format() : 'null') + - ', '); + var buffer = new StringBuffer(); + + buffer.write("Comment {"); + buffer.write("id=" + "$id" + ", "); + buffer.write("post=" + (_post != null ? _post!.toString() : "null") + ", "); + buffer.write("content=" + "$_content" + ", "); + buffer.write("createdAt=" + + (_createdAt != null ? _createdAt!.format() : "null") + + ", "); buffer.write( - 'updatedAt=' + (_updatedAt != null ? _updatedAt!.format() : 'null')); - buffer.write('}'); + "updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); + buffer.write("}"); return buffer.toString(); } @@ -110,18 +121,25 @@ 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'])) + _post = json['post'] != null + ? Post.fromJson(new Map.from(json['post'])) : 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() => { @@ -132,8 +150,6 @@ class Comment extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier MODEL_IDENTIFIER = QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: 'comment.id'); Map toMap() => { 'id': id, 'post': _post, @@ -142,47 +158,59 @@ class Comment extends Model { 'updatedAt': _updatedAt }; - 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) { - modelSchemaDefinition.name = 'Comment'; - modelSchemaDefinition.pluralName = 'Comments'; + 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.indexes = [ - ModelIndex(fields: const ['postID', 'content'], name: 'byPost') + amplify_core.ModelIndex( + fields: const ["postID", "content"], 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 @@ -196,13 +224,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/test/amplify_test/lib/test_models/Contact.dart b/packages/test/amplify_test/lib/test_models/Contact.dart index 4da8db2b78..a6b84e2b02 100644 --- a/packages/test/amplify_test/lib/test_models/Contact.dart +++ b/packages/test/amplify_test/lib/test_models/Contact.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -8,12 +20,10 @@ // 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:meta/meta.dart'; -/// This is an auto generated class representing the Contact type in your schema. -@immutable +/** This is an auto generated class representing the Contact type in your schema. */ class Contact { final String? _email; final Phone? _phone; @@ -23,10 +33,10 @@ class Contact { try { return _email!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -36,10 +46,10 @@ class Contact { try { return _phone!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -85,7 +95,7 @@ class Contact { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Contact {"); buffer.write("email=" + "$_email" + ", "); @@ -106,17 +116,27 @@ class Contact { mailingAddresses: mailingAddresses ?? this.mailingAddresses); } + Contact copyWithModelFieldValues( + {ModelFieldValue? email, + ModelFieldValue? phone, + ModelFieldValue?>? mailingAddresses}) { + return Contact._internal( + email: email == null ? this.email : email.value, + phone: phone == null ? this.phone : phone.value, + mailingAddresses: mailingAddresses == null + ? this.mailingAddresses + : mailingAddresses.value); + } + Contact.fromJson(Map json) : _email = json['email'], - _phone = json['phone']?['serializedData'] != null - ? Phone.fromJson( - Map.from(json['phone']['serializedData'])) + _phone = json['phone'] != null + ? Phone.fromJson(new Map.from(json['phone'])) : null, _mailingAddresses = json['mailingAddresses'] is List ? (json['mailingAddresses'] as List) .where((e) => e != null) - .map((e) => Address.fromJson( - Map.from(e['serializedData']))) + .map((e) => Address.fromJson(new Map.from(e))) .toList() : null; @@ -130,27 +150,31 @@ class Contact { Map toMap() => {'email': _email, 'phone': _phone, 'mailingAddresses': _mailingAddresses}; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Contact"; modelSchemaDefinition.pluralName = "Contacts"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'email', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'email', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'phone', isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embedded, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embedded, ofCustomTypeName: 'Phone'))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'mailingAddresses', isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embeddedCollection, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embeddedCollection, ofCustomTypeName: 'Address'))); }); } diff --git a/packages/test/amplify_test/lib/test_models/FileMeta.dart b/packages/test/amplify_test/lib/test_models/FileMeta.dart index fec60dc0e2..c22c6ab452 100644 --- a/packages/test/amplify_test/lib/test_models/FileMeta.dart +++ b/packages/test/amplify_test/lib/test_models/FileMeta.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,11 +19,10 @@ // 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:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the FileMeta type in your schema. -@immutable +/** This is an auto generated class representing the FileMeta type in your schema. */ class FileMeta { final String? _name; @@ -19,10 +30,10 @@ class FileMeta { 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()); } @@ -49,7 +60,7 @@ class FileMeta { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("FileMeta {"); buffer.write("name=" + "$_name"); @@ -62,20 +73,26 @@ class FileMeta { return FileMeta._internal(name: name ?? this.name); } + FileMeta copyWithModelFieldValues({ModelFieldValue? name}) { + return FileMeta._internal(name: name == null ? this.name : name.value); + } + FileMeta.fromJson(Map json) : _name = json['name']; Map toJson() => {'name': _name}; Map toMap() => {'name': _name}; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "FileMeta"; modelSchemaDefinition.pluralName = "FileMetas"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'name', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'name', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); }); } diff --git a/packages/test/amplify_test/lib/test_models/Inventory.dart b/packages/test/amplify_test/lib/test_models/Inventory.dart index dbb9edc310..89a19dc2f6 100644 --- a/packages/test/amplify_test/lib/test_models/Inventory.dart +++ b/packages/test/amplify_test/lib/test_models/Inventory.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,19 +19,18 @@ // 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:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the Inventory type in your schema. -@immutable -class Inventory extends Model { - static const classType = _InventoryModelType(); +/** This is an auto generated class representing the Inventory type in your schema. */ +class Inventory extends amplify_core.Model { + static const classType = const _InventoryModelType(); final String? _productID; final String? _name; final String? _warehouseID; final String? _region; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -37,10 +48,10 @@ class Inventory extends Model { warehouseID: _warehouseID!, region: _region!); } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -50,10 +61,10 @@ class Inventory extends Model { try { return _productID!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -63,10 +74,10 @@ class Inventory 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()); } @@ -76,10 +87,10 @@ class Inventory extends Model { try { return _warehouseID!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -89,20 +100,20 @@ class Inventory extends Model { try { return _region!; } 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; } @@ -151,7 +162,7 @@ class Inventory extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Inventory {"); buffer.write("productID=" + "$_productID" + ", "); @@ -176,16 +187,24 @@ class Inventory extends Model { region: region); } + Inventory copyWithModelFieldValues() { + return Inventory._internal( + productID: productID, + name: name, + warehouseID: warehouseID, + region: region); + } + Inventory.fromJson(Map json) : _productID = json['productID'], _name = json['name'], _warehouseID = json['warehouseID'], _region = json['region'], _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() => { @@ -206,58 +225,67 @@ class Inventory extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField PRODUCTID = QueryField(fieldName: "productID"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField WAREHOUSEID = QueryField(fieldName: "warehouseID"); - static final QueryField REGION = QueryField(fieldName: "region"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final PRODUCTID = amplify_core.QueryField(fieldName: "productID"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final WAREHOUSEID = amplify_core.QueryField(fieldName: "warehouseID"); + static final REGION = amplify_core.QueryField(fieldName: "region"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Inventory"; modelSchemaDefinition.pluralName = "Inventories"; modelSchemaDefinition.indexes = [ - ModelIndex( + amplify_core.ModelIndex( fields: const ["productID", "name", "warehouseID", "region"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Inventory.PRODUCTID, 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: Inventory.NAME, 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: Inventory.WAREHOUSEID, 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: Inventory.REGION, 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 _InventoryModelType extends ModelType { +class _InventoryModelType extends amplify_core.ModelType { const _InventoryModelType(); @override @@ -271,17 +299,21 @@ class _InventoryModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Inventory] in your schema. -@immutable -class InventoryModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Inventory] in your schema. + */ +class InventoryModelIdentifier + implements amplify_core.ModelIdentifier { final String productID; final String name; final String warehouseID; final String region; - /// Create an instance of InventoryModelIdentifier using [productID] the primary key. - /// And [name], [warehouseID], [region] the sort keys. + /** + * Create an instance of InventoryModelIdentifier using [productID] the primary key. + * And [name], [warehouseID], [region] the sort keys. + */ const InventoryModelIdentifier( {required this.productID, required this.name, diff --git a/packages/test/amplify_test/lib/test_models/ModelProvider.dart b/packages/test/amplify_test/lib/test_models/ModelProvider.dart index 171af17300..7fe2935835 100644 --- a/packages/test/amplify_test/lib/test_models/ModelProvider.dart +++ b/packages/test/amplify_test/lib/test_models/ModelProvider.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,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 'Inventory.dart'; @@ -38,11 +50,11 @@ export 'S3Object.dart'; export 'StringListTypeModel.dart'; export 'Warehouse.dart'; -class ModelProvider implements ModelProviderInterface { +class ModelProvider implements amplify_core.ModelProviderInterface { @override String version = "6c0a4ed8a5e5e532d6e91fe74ed634ea"; @override - List modelSchemas = [ + List modelSchemas = [ Blog.schema, Comment.schema, Inventory.schema, @@ -53,19 +65,19 @@ class ModelProvider implements ModelProviderInterface { StringListTypeModel.schema, Warehouse.schema ]; - static final ModelProvider _instance = ModelProvider(); @override - List customTypeSchemas = [ + List customTypeSchemas = [ Address.schema, Contact.schema, FileMeta.schema, Phone.schema, S3Object.schema ]; + 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; @@ -92,3 +104,9 @@ class ModelProvider implements ModelProviderInterface { } } } + +class ModelFieldValue { + const ModelFieldValue.value(this.value); + + final T value; +} diff --git a/packages/test/amplify_test/lib/test_models/Person.dart b/packages/test/amplify_test/lib/test_models/Person.dart index 32ba2f443c..c6191dcb17 100644 --- a/packages/test/amplify_test/lib/test_models/Person.dart +++ b/packages/test/amplify_test/lib/test_models/Person.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -8,20 +20,18 @@ // 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:meta/meta.dart'; -/// This is an auto generated class representing the Person type in your schema. -@immutable -class Person extends Model { - static const classType = _PersonModelType(); +/** This is an auto generated class representing the Person type in your schema. */ +class Person extends amplify_core.Model { + static const classType = const _PersonModelType(); final String id; final String? _name; final List
? _propertiesAddresses; final Contact? _contact; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -39,10 +49,10 @@ class Person 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()); } @@ -56,20 +66,20 @@ class Person extends Model { try { return _contact!; } 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; } @@ -92,7 +102,7 @@ class Person extends Model { List
? propertiesAddresses, required Contact contact}) { return Person._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, name: name, propertiesAddresses: propertiesAddresses != null ? List
.unmodifiable(propertiesAddresses) @@ -120,7 +130,7 @@ class Person extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Person {"); buffer.write("id=" + "$id" + ", "); @@ -151,25 +161,36 @@ class Person extends Model { contact: contact ?? this.contact); } + Person copyWithModelFieldValues( + {ModelFieldValue? name, + ModelFieldValue?>? propertiesAddresses, + ModelFieldValue? contact}) { + return Person._internal( + id: id, + name: name == null ? this.name : name.value, + propertiesAddresses: propertiesAddresses == null + ? this.propertiesAddresses + : propertiesAddresses.value, + contact: contact == null ? this.contact : contact.value); + } + Person.fromJson(Map json) : id = json['id'], _name = json['name'], _propertiesAddresses = json['propertiesAddresses'] is List ? (json['propertiesAddresses'] as List) .where((e) => e != null) - .map((e) => Address.fromJson( - Map.from(e['serializedData']))) + .map((e) => Address.fromJson(new Map.from(e))) .toList() : null, - _contact = json['contact']?['serializedData'] != null - ? Contact.fromJson( - Map.from(json['contact']['serializedData'])) + _contact = json['contact'] != null + ? Contact.fromJson(new Map.from(json['contact'])) : 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() => { @@ -191,53 +212,61 @@ class Person 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 PROPERTIESADDRESSES = - QueryField(fieldName: "propertiesAddresses"); - static final QueryField CONTACT = QueryField(fieldName: "contact"); - 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 final PROPERTIESADDRESSES = + amplify_core.QueryField(fieldName: "propertiesAddresses"); + static final CONTACT = amplify_core.QueryField(fieldName: "contact"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Person"; modelSchemaDefinition.pluralName = "People"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Person.NAME, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'propertiesAddresses', isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embeddedCollection, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embeddedCollection, ofCustomTypeName: 'Address'))); - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'contact', isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.embedded, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embedded, ofCustomTypeName: 'Contact'))); - 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 _PersonModelType extends ModelType { +class _PersonModelType extends amplify_core.ModelType { const _PersonModelType(); @override @@ -251,13 +280,14 @@ class _PersonModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Person] in your schema. -@immutable -class PersonModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Person] in your schema. + */ +class PersonModelIdentifier implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of PersonModelIdentifier using [id] the primary key. + /** Create an instance of PersonModelIdentifier using [id] the primary key. */ const PersonModelIdentifier({required this.id}); @override diff --git a/packages/test/amplify_test/lib/test_models/Phone.dart b/packages/test/amplify_test/lib/test_models/Phone.dart index e7770e8c00..0881d57d82 100644 --- a/packages/test/amplify_test/lib/test_models/Phone.dart +++ b/packages/test/amplify_test/lib/test_models/Phone.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,11 +19,10 @@ // 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:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the Phone type in your schema. -@immutable +/** This is an auto generated class representing the Phone type in your schema. */ class Phone { final String? _country; final String? _number; @@ -20,10 +31,10 @@ class Phone { try { return _country!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -33,10 +44,10 @@ class Phone { try { return _number!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -67,7 +78,7 @@ class Phone { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Phone {"); buffer.write("country=" + "$_country" + ", "); @@ -82,6 +93,13 @@ class Phone { country: country ?? this.country, number: number ?? this.number); } + Phone copyWithModelFieldValues( + {ModelFieldValue? country, ModelFieldValue? number}) { + return Phone._internal( + country: country == null ? this.country : country.value, + number: number == null ? this.number : number.value); + } + Phone.fromJson(Map json) : _country = json['country'], _number = json['number']; @@ -90,19 +108,23 @@ class Phone { Map toMap() => {'country': _country, 'number': _number}; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Phone"; modelSchemaDefinition.pluralName = "Phones"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'country', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'number', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'country', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'number', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); }); } diff --git a/packages/test/amplify_test/lib/test_models/Post.dart b/packages/test/amplify_test/lib/test_models/Post.dart index 184a7c0930..72b63a8d7b 100644 --- a/packages/test/amplify_test/lib/test_models/Post.dart +++ b/packages/test/amplify_test/lib/test_models/Post.dart @@ -1,34 +1,43 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 -import 'package:amplify_core/amplify_core.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; - -// 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, implicit_dynamic_parameter, implicit_dynamic_map_literal, implicit_dynamic_type +// 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; +import 'package:collection/collection.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 TemporalDateTime? _created; + final amplify_core.TemporalDateTime? _created; final int? _likeCount; final Blog? _blog; final List? _comments; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override - _PostModelType getInstanceType() => classType; + getInstanceType() => classType; @Deprecated( '[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') @@ -43,10 +52,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()); } @@ -56,16 +65,16 @@ 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()); } } - TemporalDateTime? get created { + amplify_core.TemporalDateTime? get created { return _created; } @@ -81,24 +90,43 @@ 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; } + const Post._internal( + {required this.id, + required title, + required rating, + created, + likeCount, + blog, + comments, + createdAt, + updatedAt}) + : _title = title, + _rating = rating, + _created = created, + _likeCount = likeCount, + _blog = blog, + _comments = comments, + _createdAt = createdAt, + _updatedAt = updatedAt; + factory Post( {String? id, required String title, required int rating, - TemporalDateTime? created, + amplify_core.TemporalDateTime? created, int? likeCount, 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, created: created, @@ -129,25 +157,6 @@ class Post extends Model { _createdAt = createdAt, _updatedAt = updatedAt; - const Post._internal( - {required this.id, - required title, - required rating, - created, - likeCount, - blog, - comments, - createdAt, - updatedAt}) - : _title = title, - _rating = rating, - _created = created, - _likeCount = likeCount, - _blog = blog, - _comments = comments, - _createdAt = createdAt, - _updatedAt = updatedAt; - bool equals(Object other) { return this == other; } @@ -170,25 +179,25 @@ class Post extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); - buffer.write('Post {'); - buffer.write('id=' + '$id' + ', '); - buffer.write('title=' + '$_title' + ', '); + buffer.write("Post {"); + buffer.write("id=" + "$id" + ", "); + buffer.write("title=" + "$_title" + ", "); buffer.write( - 'rating=' + (_rating != null ? _rating!.toString() : 'null') + ', '); + "rating=" + (_rating != null ? _rating!.toString() : "null") + ", "); buffer.write( - 'created=' + (_created != null ? _created!.format() : 'null') + ', '); - buffer.write('likeCount=' + - (_likeCount != null ? _likeCount!.toString() : 'null') + - ', '); - buffer.write('blog=' + (_blog != null ? _blog!.toString() : 'null') + ', '); - buffer.write('createdAt=' + - (_createdAt != null ? _createdAt!.format() : 'null') + - ', '); + "created=" + (_created != null ? _created!.format() : "null") + ", "); + buffer.write("likeCount=" + + (_likeCount != null ? _likeCount!.toString() : "null") + + ", "); + buffer.write("blog=" + (_blog != null ? _blog!.toString() : "null") + ", "); + buffer.write("createdAt=" + + (_createdAt != null ? _createdAt!.format() : "null") + + ", "); buffer.write( - 'updatedAt=' + (_updatedAt != null ? _updatedAt!.format() : 'null')); - buffer.write('}'); + "updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); + buffer.write("}"); return buffer.toString(); } @@ -196,7 +205,7 @@ class Post extends Model { Post copyWith( {String? title, int? rating, - TemporalDateTime? created, + amplify_core.TemporalDateTime? created, int? likeCount, Blog? blog, List? comments}) { @@ -210,30 +219,45 @@ class Post extends Model { comments: comments ?? this.comments); } + Post copyWithModelFieldValues( + {ModelFieldValue? title, + ModelFieldValue? rating, + ModelFieldValue? created, + ModelFieldValue? likeCount, + ModelFieldValue? blog, + ModelFieldValue?>? comments}) { + return Post._internal( + id: id, + title: title == null ? this.title : title.value, + rating: rating == null ? this.rating : rating.value, + created: created == null ? this.created : created.value, + likeCount: likeCount == null ? this.likeCount : likeCount.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(), _created = json['created'] != null - ? TemporalDateTime.fromString(json['created']) + ? amplify_core.TemporalDateTime.fromString(json['created']) : null, _likeCount = (json['likeCount'] as num?)?.toInt(), - _blog = json['blog']?['serializedData'] != null - ? Blog.fromJson( - Map.from(json['blog']['serializedData'])) + _blog = json['blog'] != null + ? Blog.fromJson(new Map.from(json['blog'])) : null, - _comments = json['comments'] is List - ? (json['comments'] as List) - .where((e) => e?['serializedData'] != null) - .map((e) => Comment.fromJson( - Map.from(e['serializedData']))) + _comments = json['comments'] != null + ? (json['comments']['items'] as List) + .where((e) => e != null) + .map((e) => Comment.fromJson(new Map.from(e))) .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() => { @@ -248,12 +272,6 @@ class Post extends Model { 'updatedAt': _updatedAt?.format() }; - static final QueryModelIdentifier MODEL_IDENTIFIER = QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: 'post.id'); - static final QueryField TITLE = QueryField(fieldName: 'title'); - static final QueryField RATING = QueryField(fieldName: 'rating'); - static final QueryField CREATED = QueryField(fieldName: 'created'); - static final QueryField LIKECOUNT = QueryField(fieldName: 'likeCount'); Map toMap() => { 'id': id, 'title': _title, @@ -266,71 +284,90 @@ class Post extends Model { 'updatedAt': _updatedAt }; - 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 CREATED = amplify_core.QueryField(fieldName: "created"); + static final LIKECOUNT = amplify_core.QueryField(fieldName: "likeCount"); + 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) { - modelSchemaDefinition.name = 'Post'; - modelSchemaDefinition.pluralName = 'Posts'; + 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.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.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Post.CREATED, isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.dateTime))); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Post.LIKECOUNT, isRequired: false, - 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 @@ -344,13 +381,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/test/amplify_test/lib/test_models/PostWithAuthRules.dart b/packages/test/amplify_test/lib/test_models/PostWithAuthRules.dart index 09afc5b687..39f7696bf1 100644 --- a/packages/test/amplify_test/lib/test_models/PostWithAuthRules.dart +++ b/packages/test/amplify_test/lib/test_models/PostWithAuthRules.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,18 +19,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 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the PostWithAuthRules type in your schema. -@immutable -class PostWithAuthRules extends Model { - static const classType = _PostWithAuthRulesModelType(); +/** This is an auto generated class representing the PostWithAuthRules type in your schema. */ +class PostWithAuthRules extends amplify_core.Model { + static const classType = const _PostWithAuthRulesModelType(); final String id; final String? _title; final String? _owner; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -36,10 +47,10 @@ class PostWithAuthRules 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()); } @@ -49,11 +60,11 @@ class PostWithAuthRules extends Model { return _owner; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -67,7 +78,9 @@ class PostWithAuthRules extends Model { factory PostWithAuthRules( {String? id, required String title, String? owner}) { return PostWithAuthRules._internal( - id: id == null ? UUID.getUUID() : id, title: title, owner: owner); + id: id == null ? amplify_core.UUID.getUUID() : id, + title: title, + owner: owner); } bool equals(Object other) { @@ -88,7 +101,7 @@ class PostWithAuthRules extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("PostWithAuthRules {"); buffer.write("id=" + "$id" + ", "); @@ -109,15 +122,23 @@ class PostWithAuthRules extends Model { id: id, title: title ?? this.title, owner: owner ?? this.owner); } + PostWithAuthRules copyWithModelFieldValues( + {ModelFieldValue? title, ModelFieldValue? owner}) { + return PostWithAuthRules._internal( + id: id, + title: title == null ? this.title : title.value, + owner: owner == null ? this.owner : owner.value); + } + PostWithAuthRules.fromJson(Map json) : id = json['id'], _title = json['title'], _owner = json['owner'], _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() => { @@ -136,58 +157,65 @@ class PostWithAuthRules 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 OWNER = QueryField(fieldName: "owner"); - 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 TITLE = amplify_core.QueryField(fieldName: "title"); + static final OWNER = amplify_core.QueryField(fieldName: "owner"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "PostWithAuthRules"; modelSchemaDefinition.pluralName = "PostWithAuthRules"; 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: PostWithAuthRules.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: PostWithAuthRules.OWNER, isRequired: false, - 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 _PostWithAuthRulesModelType extends ModelType { +class _PostWithAuthRulesModelType + extends amplify_core.ModelType { const _PostWithAuthRulesModelType(); @override @@ -201,14 +229,15 @@ class _PostWithAuthRulesModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [PostWithAuthRules] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [PostWithAuthRules] in your schema. + */ class PostWithAuthRulesModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of PostWithAuthRulesModelIdentifier using [id] the primary key. + /** Create an instance of PostWithAuthRulesModelIdentifier using [id] the primary key. */ const PostWithAuthRulesModelIdentifier({required this.id}); @override diff --git a/packages/test/amplify_test/lib/test_models/Product.dart b/packages/test/amplify_test/lib/test_models/Product.dart index da4344e3b8..1bfe190ae7 100644 --- a/packages/test/amplify_test/lib/test_models/Product.dart +++ b/packages/test/amplify_test/lib/test_models/Product.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,18 +19,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 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the Product type in your schema. -@immutable -class Product extends Model { - static const classType = _ProductModelType(); +/** This is an auto generated class representing the Product type in your schema. */ +class Product extends amplify_core.Model { + static const classType = const _ProductModelType(); final String? _productID; final String? _name; final int? _amount; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -32,10 +43,10 @@ class Product extends Model { try { return ProductModelIdentifier(productID: _productID!); } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -45,10 +56,10 @@ class Product extends Model { try { return _productID!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -58,10 +69,10 @@ class Product 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()); } @@ -71,20 +82,20 @@ class Product extends Model { try { return _amount!; } 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; } @@ -123,7 +134,7 @@ class Product extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Product {"); buffer.write("productID=" + "$_productID" + ", "); @@ -147,15 +158,23 @@ class Product extends Model { amount: amount ?? this.amount); } + Product copyWithModelFieldValues( + {ModelFieldValue? name, ModelFieldValue? amount}) { + return Product._internal( + productID: productID, + name: name == null ? this.name : name.value, + amount: amount == null ? this.amount : amount.value); + } + Product.fromJson(Map json) : _productID = json['productID'], _name = json['name'], _amount = (json['amount'] as num?)?.toInt(), _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() => { @@ -174,50 +193,58 @@ class Product extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField PRODUCTID = QueryField(fieldName: "productID"); - static final QueryField NAME = QueryField(fieldName: "name"); - static final QueryField AMOUNT = QueryField(fieldName: "amount"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static final amplify_core.QueryModelIdentifier + MODEL_IDENTIFIER = + amplify_core.QueryModelIdentifier(); + static final PRODUCTID = amplify_core.QueryField(fieldName: "productID"); + static final NAME = amplify_core.QueryField(fieldName: "name"); + static final AMOUNT = amplify_core.QueryField(fieldName: "amount"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Product"; modelSchemaDefinition.pluralName = "Products"; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["productID"], name: null) + amplify_core.ModelIndex(fields: const ["productID"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Product.PRODUCTID, 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: Product.NAME, 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: Product.AMOUNT, isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.int))); - - 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.int))); + + 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 _ProductModelType extends ModelType { +class _ProductModelType extends amplify_core.ModelType { const _ProductModelType(); @override @@ -231,13 +258,14 @@ class _ProductModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Product] in your schema. -@immutable -class ProductModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Product] in your schema. + */ +class ProductModelIdentifier implements amplify_core.ModelIdentifier { final String productID; - /// Create an instance of ProductModelIdentifier using [productID] the primary key. + /** Create an instance of ProductModelIdentifier using [productID] the primary key. */ const ProductModelIdentifier({required this.productID}); @override diff --git a/packages/test/amplify_test/lib/test_models/S3Object.dart b/packages/test/amplify_test/lib/test_models/S3Object.dart index 1a92a747a0..cd472fc5b3 100644 --- a/packages/test/amplify_test/lib/test_models/S3Object.dart +++ b/packages/test/amplify_test/lib/test_models/S3Object.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -8,11 +20,9 @@ // 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:meta/meta.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the S3Object type in your schema. -@immutable +/** This is an auto generated class representing the S3Object type in your schema. */ class S3Object { final String? _bucket; final String? _region; @@ -23,10 +33,10 @@ class S3Object { try { return _bucket!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -36,10 +46,10 @@ class S3Object { try { return _region!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -49,10 +59,10 @@ class S3Object { try { return _key!; } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -97,7 +107,7 @@ class S3Object { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("S3Object {"); buffer.write("bucket=" + "$_bucket" + ", "); @@ -118,13 +128,24 @@ class S3Object { meta: meta ?? this.meta); } + S3Object copyWithModelFieldValues( + {ModelFieldValue? bucket, + ModelFieldValue? region, + ModelFieldValue? key, + ModelFieldValue? meta}) { + return S3Object._internal( + bucket: bucket == null ? this.bucket : bucket.value, + region: region == null ? this.region : region.value, + key: key == null ? this.key : key.value, + meta: meta == null ? this.meta : meta.value); + } + S3Object.fromJson(Map json) : _bucket = json['bucket'], _region = json['region'], _key = json['key'], - _meta = json['meta']?['serializedData'] != null - ? FileMeta.fromJson( - Map.from(json['meta']['serializedData'])) + _meta = json['meta'] != null + ? FileMeta.fromJson(new Map.from(json['meta'])) : null; Map toJson() => { @@ -137,30 +158,37 @@ class S3Object { Map toMap() => {'bucket': _bucket, 'region': _region, 'key': _key, 'meta': _meta}; - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "S3Object"; modelSchemaDefinition.pluralName = "S3Objects"; - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'bucket', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'region', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.customTypeField( - fieldName: 'key', - isRequired: true, - ofType: ModelFieldType(ModelFieldTypeEnum.string))); - - modelSchemaDefinition.addField(ModelFieldDefinition.embedded( + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'bucket', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'region', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField( + amplify_core.ModelFieldDefinition.customTypeField( + fieldName: 'key', + isRequired: true, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.string))); + + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.embedded( fieldName: 'meta', isRequired: false, - ofType: ModelFieldType(ModelFieldTypeEnum.embedded, + ofType: amplify_core.ModelFieldType( + amplify_core.ModelFieldTypeEnum.embedded, ofCustomTypeName: 'FileMeta'))); }); } diff --git a/packages/test/amplify_test/lib/test_models/StringListTypeModel.dart b/packages/test/amplify_test/lib/test_models/StringListTypeModel.dart index ebc99e189c..d0bc019ae1 100644 --- a/packages/test/amplify_test/lib/test_models/StringListTypeModel.dart +++ b/packages/test/amplify_test/lib/test_models/StringListTypeModel.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,18 +19,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 'package:amplify_core/amplify_core.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; -/// This is an auto generated class representing the StringListTypeModel type in your schema. -@immutable -class StringListTypeModel extends Model { - static const classType = _StringListTypeModelModelType(); +/** This is an auto generated class representing the StringListTypeModel type in your schema. */ +class StringListTypeModel extends amplify_core.Model { + static const classType = const _StringListTypeModelModelType(); final String id; final List? _value; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -36,11 +47,11 @@ class StringListTypeModel extends Model { return _value; } - TemporalDateTime? get createdAt { + amplify_core.TemporalDateTime? get createdAt { return _createdAt; } - TemporalDateTime? get updatedAt { + amplify_core.TemporalDateTime? get updatedAt { return _updatedAt; } @@ -52,7 +63,7 @@ class StringListTypeModel extends Model { factory StringListTypeModel({String? id, List? value}) { return StringListTypeModel._internal( - id: id == null ? UUID.getUUID() : id, + id: id == null ? amplify_core.UUID.getUUID() : id, value: value != null ? List.unmodifiable(value) : value); } @@ -73,7 +84,7 @@ class StringListTypeModel extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("StringListTypeModel {"); buffer.write("id=" + "$id" + ", "); @@ -93,14 +104,20 @@ class StringListTypeModel extends Model { return StringListTypeModel._internal(id: id, value: value ?? this.value); } + StringListTypeModel copyWithModelFieldValues( + {ModelFieldValue?>? value}) { + return StringListTypeModel._internal( + id: id, value: value == null ? this.value : value.value); + } + StringListTypeModel.fromJson(Map json) : id = json['id'], _value = json['value']?.cast(), _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() => { @@ -117,40 +134,47 @@ class StringListTypeModel extends Model { 'updatedAt': _updatedAt }; - static final QueryModelIdentifier + static final amplify_core + .QueryModelIdentifier MODEL_IDENTIFIER = - QueryModelIdentifier(); - static final QueryField ID = QueryField(fieldName: "id"); - static final QueryField VALUE = QueryField(fieldName: "value"); - static var schema = - Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + amplify_core.QueryModelIdentifier(); + static final ID = amplify_core.QueryField(fieldName: "id"); + static final VALUE = amplify_core.QueryField(fieldName: "value"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "StringListTypeModel"; modelSchemaDefinition.pluralName = "StringListTypeModels"; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: StringListTypeModel.VALUE, isRequired: false, isArray: true, - ofType: ModelFieldType(ModelFieldTypeEnum.collection, - ofModelName: ModelFieldTypeEnum.string.name))); - - 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.collection, + ofModelName: amplify_core.ModelFieldTypeEnum.string.name))); + + 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 _StringListTypeModelModelType extends ModelType { +class _StringListTypeModelModelType + extends amplify_core.ModelType { const _StringListTypeModelModelType(); @override @@ -164,14 +188,15 @@ class _StringListTypeModelModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [StringListTypeModel] in your schema. -@immutable +/** + * This is an auto generated class representing the model identifier + * of [StringListTypeModel] in your schema. + */ class StringListTypeModelModelIdentifier - implements ModelIdentifier { + implements amplify_core.ModelIdentifier { final String id; - /// Create an instance of StringListTypeModelModelIdentifier using [id] the primary key. + /** Create an instance of StringListTypeModelModelIdentifier using [id] the primary key. */ const StringListTypeModelModelIdentifier({required this.id}); @override diff --git a/packages/test/amplify_test/lib/test_models/Warehouse.dart b/packages/test/amplify_test/lib/test_models/Warehouse.dart index 6ef232e0f2..96422e03ab 100644 --- a/packages/test/amplify_test/lib/test_models/Warehouse.dart +++ b/packages/test/amplify_test/lib/test_models/Warehouse.dart @@ -1,5 +1,17 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ // 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 @@ -7,18 +19,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 'package:amplify_core/amplify_core.dart'; -import 'package:meta/meta.dart'; +import 'ModelProvider.dart'; +import 'package:amplify_core/amplify_core.dart' as amplify_core; -/// This is an auto generated class representing the Warehouse type in your schema. -@immutable -class Warehouse extends Model { - static const classType = _WarehouseModelType(); +/** This is an auto generated class representing the Warehouse type in your schema. */ +class Warehouse extends amplify_core.Model { + static const classType = const _WarehouseModelType(); final String id; final String? _name; final String? _region; - final TemporalDateTime? _createdAt; - final TemporalDateTime? _updatedAt; + final amplify_core.TemporalDateTime? _createdAt; + final amplify_core.TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @@ -32,10 +43,10 @@ class Warehouse extends Model { try { return WarehouseModelIdentifier(id: id, name: _name!, region: _region!); } catch (e) { - throw AmplifyCodeGenModelException( - AmplifyExceptionMessages + throw amplify_core.AmplifyCodeGenModelException( + amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, - recoverySuggestion: AmplifyExceptionMessages + recoverySuggestion: amplify_core.AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } @@ -45,10 +56,10 @@ class Warehouse 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()); } @@ -58,20 +69,20 @@ class Warehouse extends Model { try { return _region!; } 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; } @@ -85,7 +96,9 @@ class Warehouse extends Model { factory Warehouse( {String? id, required String name, required String region}) { return Warehouse._internal( - id: id == null ? UUID.getUUID() : id, name: name, region: region); + id: id == null ? amplify_core.UUID.getUUID() : id, + name: name, + region: region); } bool equals(Object other) { @@ -106,7 +119,7 @@ class Warehouse extends Model { @override String toString() { - var buffer = StringBuffer(); + var buffer = new StringBuffer(); buffer.write("Warehouse {"); buffer.write("id=" + "$id" + ", "); @@ -126,15 +139,19 @@ class Warehouse extends Model { return Warehouse._internal(id: id, name: name, region: region); } + Warehouse copyWithModelFieldValues() { + return Warehouse._internal(id: id, name: name, region: region); + } + Warehouse.fromJson(Map json) : id = json['id'], _name = json['name'], _region = json['region'], _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() => { @@ -153,47 +170,55 @@ class Warehouse 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 REGION = QueryField(fieldName: "region"); - 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 final REGION = amplify_core.QueryField(fieldName: "region"); + static var schema = amplify_core.Model.defineSchema( + define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Warehouse"; modelSchemaDefinition.pluralName = "Warehouses"; modelSchemaDefinition.indexes = [ - ModelIndex(fields: const ["id", "name", "region"], name: null) + amplify_core.ModelIndex( + fields: const ["id", "name", "region"], name: null) ]; - modelSchemaDefinition.addField(ModelFieldDefinition.id()); + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id()); - modelSchemaDefinition.addField(ModelFieldDefinition.field( + modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field( key: Warehouse.NAME, 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: Warehouse.REGION, 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 _WarehouseModelType extends ModelType { +class _WarehouseModelType extends amplify_core.ModelType { const _WarehouseModelType(); @override @@ -207,16 +232,20 @@ class _WarehouseModelType extends ModelType { } } -/// This is an auto generated class representing the model identifier -/// of [Warehouse] in your schema. -@immutable -class WarehouseModelIdentifier implements ModelIdentifier { +/** + * This is an auto generated class representing the model identifier + * of [Warehouse] in your schema. + */ +class WarehouseModelIdentifier + implements amplify_core.ModelIdentifier { final String id; final String name; final String region; - /// Create an instance of WarehouseModelIdentifier using [id] the primary key. - /// And [name], [region] the sort keys. + /** + * Create an instance of WarehouseModelIdentifier using [id] the primary key. + * And [name], [region] the sort keys. + */ const WarehouseModelIdentifier( {required this.id, required this.name, required this.region});