Skip to content

Commit 4dbda1d

Browse files
Chore: Remove deprecated apis (#4780)
* chore: remove deprecated AWSHttpMethodHelper * chore: remove deprecated AWSResult.type * chore: remove deprecated StateMachineEvent.cast() * chore: remove deprecated ModelAssociation.targetName
1 parent 8a44180 commit 4dbda1d

File tree

14 files changed

+9
-1024
lines changed

14 files changed

+9
-1024
lines changed

packages/amplify_core/lib/src/state_machine/event.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ abstract base class StateMachineEvent<EventType extends Object,
1919
/// The event's discrete type, expressed as an enum.
2020
EventType get type;
2121

22-
/// Casts this to an event of type [E].
23-
@Deprecated('Use pattern matching instead')
24-
E cast<E extends StateMachineEvent<EventType, StateType>>() => this as E;
25-
2622
/// Checks the precondition, given [currentState].
2723
///
2824
/// Returns a [PreconditionException] if the check fails, otherwise `null`.

packages/amplify_core/lib/src/types/models/model_association.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,26 @@ class ModelAssociation with AWSEquatable<ModelAssociation>, AWSSerializable {
1515

1616
const ModelAssociation({
1717
required this.associationType,
18-
@Deprecated(
19-
'Please use the latest version of Amplify CLI to regenerate models',
20-
)
21-
this.targetName,
2218
this.targetNames,
2319
this.associatedName,
2420
this.associatedType,
2521
});
26-
final ModelAssociationEnum associationType;
2722

28-
@Deprecated(
29-
'Please use the latest version of Amplify CLI to regenerate models',
30-
)
31-
final String? targetName; // used in belongsTo
23+
final ModelAssociationEnum associationType;
3224
final List<String>? targetNames; // used in belongsTo
3325
final String? associatedName; // used in hasMany/hasOne
3426
final String? associatedType;
3527

3628
@override
3729
List<Object?> get props => [
3830
associationType,
39-
// ignore: deprecated_member_use_from_same_package
40-
targetName,
4131
targetNames,
4232
associatedName,
4333
associatedType,
4434
];
4535

4636
ModelAssociation copyWith({
4737
ModelAssociationEnum? associationType,
48-
String? targetName,
4938
List<String>? targetNames,
5039
String? associatedName,
5140
String? associatedType,
@@ -61,8 +50,6 @@ class ModelAssociation with AWSEquatable<ModelAssociation>, AWSSerializable {
6150
Map<String, dynamic> toMap() {
6251
final map = {
6352
'associationType': associationType.name,
64-
// ignore: deprecated_member_use_from_same_package
65-
'targetName': targetName,
6653
'targetNames': targetNames,
6754
'associatedName': associatedName,
6855
'associatedType': associatedType,

packages/amplify_core/lib/src/types/models/model_field_definition.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ class ModelFieldDefinition {
167167
ModelFieldType(ModelFieldTypeEnum.model, ofModelName: ofModelName),
168168
association: ModelAssociation(
169169
associationType: ModelAssociationEnum.BelongsTo,
170-
// Allow support for old schemas
171-
// ignore: deprecated_member_use_from_same_package
172-
targetName: targetName,
173170
targetNames: targetNames,
174171
associatedName: associatedName,
175172
associatedType: associatedType,

packages/amplify_datastore_plugin_interface/test/amplify_modelschema_test.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ void main() {
9393
isRequired: false,
9494
isArray: false,
9595
association: ModelAssociation(
96-
associationType: ModelAssociationEnum.BelongsTo,
97-
// ignore: deprecated_member_use
98-
targetName: "postID")));
96+
associationType: ModelAssociationEnum.BelongsTo,
97+
)));
9998

10099
expect(
101100
commentSchema.fields!["content"],
@@ -150,9 +149,8 @@ void main() {
150149
isRequired: false,
151150
isArray: false,
152151
association: ModelAssociation(
153-
associationType: ModelAssociationEnum.BelongsTo,
154-
// ignore: deprecated_member_use
155-
targetName: "blogID")));
152+
associationType: ModelAssociationEnum.BelongsTo,
153+
)));
156154
});
157155

158156
test('PostAuthComplex codegen model generates modelschema with proper fields',

packages/api/amplify_api_dart/lib/src/graphql/factories/graphql_request_factory.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ class GraphQLRequestFactory {
8686
// deserializing response because model will use ID nested in `parentSelectionSet`.
8787
// However, including the ID in selection set allows subscriptions that
8888
// filter by these ID to be triggered by these mutations.
89-
var belongsToKeys = belongsTo.association?.targetNames;
90-
if (belongsToKeys == null &&
91-
belongsTo.association?.targetName != null) {
92-
belongsToKeys = [belongsTo.association!.targetName as String];
93-
}
89+
final belongsToKeys = belongsTo.association?.targetNames;
9490
if (belongsToKeys != null) {
9591
fields.addAll(belongsToKeys);
9692
}
@@ -295,8 +291,7 @@ class GraphQLRequestFactory {
295291
// e.g. { 'name': { 'eq': 'foo }}
296292
if (queryPredicate is QueryPredicateOperation) {
297293
final association = schema.fields?[queryPredicate.field]?.association;
298-
final associatedTargetName =
299-
association?.targetNames?.first ?? association?.targetName;
294+
final associatedTargetName = association?.targetNames?.first;
300295
var fieldName = queryPredicate.field;
301296
if (queryPredicate.field ==
302297
'${_lowerCaseFirstCharacter(schema.name)}.$_defaultIdFieldName') {
@@ -388,13 +383,11 @@ class GraphQLRequestFactory {
388383
// Traverse parent schema to get expected JSON strings and remove from JSON.
389384
// A parent with complex identifier may have multiple keys.
390385
var belongsToKeys = belongsTo.association?.targetNames;
391-
final legacyTargetName =
392-
belongsTo.association?.targetName; // pre-CPK codegen
393-
if (belongsToKeys == null && legacyTargetName == null) {
386+
if (belongsToKeys == null) {
394387
// no way to resolve key to write to JSON
395388
continue;
396389
}
397-
belongsToKeys = belongsToKeys ?? [legacyTargetName as String];
390+
belongsToKeys = belongsToKeys;
398391
var i = 0; // needed to track corresponding index field name
399392
for (final belongsToKey in belongsToKeys) {
400393
final parentIdFieldName =

packages/api/amplify_api_dart/test/graphql_helpers_legacy_schema_test.dart

Lines changed: 0 additions & 211 deletions
This file was deleted.

0 commit comments

Comments
 (0)