Skip to content

Commit 3223fed

Browse files
committed
PR comment and move AnyModel unit tests
1 parent 4280acd commit 3223fed

23 files changed

+48
-26
lines changed

Amplify.xcodeproj/project.pbxproj

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
212CE70F23E9E991007D8E71 /* ModelDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212CE70A23E9E991007D8E71 /* ModelDecorator.swift */; };
4949
212CE71123E9EA6A007D8E71 /* ModelField+GraphQL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212CE71023E9EA6A007D8E71 /* ModelField+GraphQL.swift */; };
5050
212CE71323E9F2ED007D8E71 /* DirectiveNameDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212CE71223E9F2ED007D8E71 /* DirectiveNameDecorator.swift */; };
51-
213481D9242AFA62001966DE /* AnyModelTester.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213481D8242AFA62001966DE /* AnyModelTester.swift */; };
5251
21409C552384C55D000A53C9 /* LabelType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21409C542384C55D000A53C9 /* LabelType.swift */; };
5352
21409C5A2384C57D000A53C9 /* GraphQLMutationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21409C572384C57D000A53C9 /* GraphQLMutationType.swift */; };
5453
21409C5B2384C57D000A53C9 /* GraphQLQueryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21409C582384C57D000A53C9 /* GraphQLQueryType.swift */; };
@@ -116,6 +115,8 @@
116115
21AD424D249BF0E50016FE95 /* AnyModel+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE78223862DDB0097E4F1 /* AnyModel+Schema.swift */; };
117116
21AD424E249BF0E90016FE95 /* AnyModel+Subscript.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE77E2386274A0097E4F1 /* AnyModel+Subscript.swift */; };
118117
21AD424F249BF0EC0016FE95 /* Model+AnyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE77A2386271A0097E4F1 /* Model+AnyModel.swift */; };
118+
21AD425A249C0D910016FE95 /* AnyModelTester.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213481D8242AFA62001966DE /* AnyModelTester.swift */; };
119+
21AD425B249C0DBE0016FE95 /* AnyModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE772238621320097E4F1 /* AnyModelTests.swift */; };
119120
21C395B3245729EC00597EA2 /* AppSyncErrorType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21C395B2245729EC00597EA2 /* AppSyncErrorType.swift */; };
120121
21D79FDA237617C60057D00D /* SubscriptionEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21D79FD9237617C60057D00D /* SubscriptionEvent.swift */; };
121122
21D79FE32377F4120057D00D /* SubscriptionConnectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21D79FE22377F4120057D00D /* SubscriptionConnectionState.swift */; };
@@ -412,7 +413,6 @@
412413
FA6BC87F235F5DAE0001A882 /* APICategoryInterceptorBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6BC87E235F5DAE0001A882 /* APICategoryInterceptorBehavior.swift */; };
413414
FA76A2D12342B1A600B91ADB /* StorageCategory+HubPayloadEventName.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA76A2D02342B1A600B91ADB /* StorageCategory+HubPayloadEventName.swift */; };
414415
FA76A2D32342B47100B91ADB /* HubPayloadEventName.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA76A2D22342B47100B91ADB /* HubPayloadEventName.swift */; };
415-
FA8EE773238621320097E4F1 /* AnyModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE772238621320097E4F1 /* AnyModelTests.swift */; };
416416
FA8EE779238627040097E4F1 /* Model+ModelName.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE778238627040097E4F1 /* Model+ModelName.swift */; };
417417
FA8EE77D238627350097E4F1 /* Model+Subscript.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE77C238627350097E4F1 /* Model+Subscript.swift */; };
418418
FA8EE781238628490097E4F1 /* Persistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8EE780238628490097E4F1 /* Persistable.swift */; };
@@ -1495,6 +1495,7 @@
14951495
2129BE2223948085006363A1 /* Model */ = {
14961496
isa = PBXGroup;
14971497
children = (
1498+
21AD4259249C0D7C0016FE95 /* AnyModel */,
14981499
21A3FDAD24630D4200E76120 /* Decorator */,
14991500
2129BE262394828A006363A1 /* GraphQLDocument */,
15001501
2129BE302394828B006363A1 /* GraphQLRequest */,
@@ -1592,7 +1593,6 @@
15921593
213481D7242AFA58001966DE /* Support */ = {
15931594
isa = PBXGroup;
15941595
children = (
1595-
213481D8242AFA62001966DE /* AnyModelTester.swift */,
15961596
);
15971597
path = Support;
15981598
sourceTree = "<group>";
@@ -1690,6 +1690,15 @@
16901690
path = Internal;
16911691
sourceTree = "<group>";
16921692
};
1693+
21AD4259249C0D7C0016FE95 /* AnyModel */ = {
1694+
isa = PBXGroup;
1695+
children = (
1696+
FA8EE772238621320097E4F1 /* AnyModelTests.swift */,
1697+
213481D8242AFA62001966DE /* AnyModelTester.swift */,
1698+
);
1699+
path = AnyModel;
1700+
sourceTree = "<group>";
1701+
};
16931702
21C395B4245729F100597EA2 /* API */ = {
16941703
isa = PBXGroup;
16951704
children = (
@@ -3072,7 +3081,6 @@
30723081
FAD3937B23820CE200463F5E /* DataStore */ = {
30733082
isa = PBXGroup;
30743083
children = (
3075-
FA8EE772238621320097E4F1 /* AnyModelTests.swift */,
30763084
FAD3937923820CDB00463F5E /* DataStoreCategoryClientAPITests.swift */,
30773085
FAD3937C23820D0200463F5E /* DataStoreCategoryConfigurationTests.swift */,
30783086
FAE414602399A6A500CE94C2 /* ModelRegistryTests.swift */,
@@ -4032,8 +4040,10 @@
40324040
219A888723EB89C200BBC5F2 /* GraphQLRequestAnyModelWithSyncTests.swift in Sources */,
40334041
2183A56423EA4A7F00232880 /* GraphQLGetQueryTests.swift in Sources */,
40344042
6BBECD7423ADA9D100C8DFBE /* AmplifyAWSServiceConfigurationTests.swift in Sources */,
4043+
21AD425A249C0D910016FE95 /* AnyModelTester.swift in Sources */,
40354044
2129BE3C2394828B006363A1 /* GraphQLRequestModelTests.swift in Sources */,
40364045
2183A56523EA4A8400232880 /* GraphQLListQueryTests.swift in Sources */,
4046+
21AD425B249C0DBE0016FE95 /* AnyModelTests.swift in Sources */,
40374047
D83C5160248964780091548E /* ModelGraphQLTests.swift in Sources */,
40384048
);
40394049
runOnlyForDeploymentPostprocessing = 0;
@@ -4405,7 +4415,6 @@
44054415
FACF520923298C1200646E10 /* AtomicDictionaryTests.swift in Sources */,
44064416
FA4B38AB238482B100E20DAB /* DefaultLoggingPluginTests.swift in Sources */,
44074417
FA6BC869235F52740001A882 /* APICategoryClientGraphQLTests.swift in Sources */,
4408-
FA8EE773238621320097E4F1 /* AnyModelTests.swift in Sources */,
44094418
FACD264C2386E8F10068FBE6 /* JSONValue+SubscriptTests.swift in Sources */,
44104419
FACD264D2386E8F10068FBE6 /* JSONValue+KeyPathTests.swift in Sources */,
44114420
FA9FB782232AA26500C04D32 /* DefaultHubPluginCustomChannelTests.swift in Sources */,
@@ -4432,7 +4441,6 @@
44324441
B4F3E9F824314E2B00F23296 /* AuthCategoryConfigurationTests.swift in Sources */,
44334442
FAC2356E227A056600424678 /* AnalyticsCategoryClientAPITests.swift in Sources */,
44344443
B4BD6B3323708C0000A1F0A7 /* PredictionsCategoryClientAPITests.swift in Sources */,
4435-
213481D9242AFA62001966DE /* AnyModelTester.swift in Sources */,
44364444
FA47B8382350C58B0031A0E3 /* AutoUnsubscribeHubListenToOperationTests.swift in Sources */,
44374445
FAC23574227A056B00424678 /* ConfigurationTests.swift in Sources */,
44384446
B9DCA263240F217C00075E22 /* AnyEncodableTests.swift in Sources */,

Amplify/Categories/DataStore/Model/Internal/Embedded.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import Foundation
99

1010
// MARK: - Embeddable
1111

12-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1312
/// A `Embeddable` type can be used in a `Model` as an embedded type. All types embedded in a `Model` as an
1413
/// `embedded(type:)` or `embeddedCollection(of:)` must comform to the `Embeddable` protocol except for Swift's Basic
1514
/// types embedded as a collection. A collection of String can be embedded in the `Model` as
16-
/// `embeddedCollection(of: String.self)` without needing to conform to Embeddable.
15+
/// `embeddedCollection(of: String.self)` without needing to conform to Embeddable.
16+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
17+
/// by host applications. The behavior of this may change without warning.
1718
public protocol Embeddable: Codable {
1819

1920
/// A reference to the `ModelSchema` associated with this embedded type.

Amplify/Categories/DataStore/Model/Internal/Model+Array.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
extension Array where Element: Model {
1211

1312
public func unique() throws -> Element? {

Amplify/Categories/DataStore/Model/Internal/Model+Codable.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
/// Adds JSON serialization behavior to all types that conform to the `Model` protocol.
1211
extension Model where Self: Codable {
1312

Amplify/Categories/DataStore/Model/Internal/Model+DateFormatting.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
10+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
11+
/// by host applications. The behavior of this may change without warning.
1112
public struct ModelDateFormatting {
1213

1314
public static let decodingStrategy: JSONDecoder.DateDecodingStrategy = {

Amplify/Categories/DataStore/Model/Internal/Model+Enum.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
/// Protocol that represents a `Codable` Enum that can be persisted and easily
1211
/// integrate with remote APIs since it must have a raw `String` value.
1312
///
@@ -22,6 +21,8 @@ import Foundation
2221
/// case published
2322
/// }
2423
/// ```
24+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
25+
/// by host applications. The behavior of this may change without warning.
2526
public protocol EnumPersistable: Codable {
2627

2728
var rawValue: String { get }

Amplify/Categories/DataStore/Model/Internal/Model+ModelName.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
98
extension Model {
109
public static var modelName: String {
1110
return String(describing: self)

Amplify/Categories/DataStore/Model/Internal/Model+Subscript.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
98
/// Implement dynamic access to properties of a `Model`.
109
///
1110
/// ```swift

Amplify/Categories/DataStore/Model/Internal/Model.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import Foundation
99

1010
// MARK: - Model
1111

12-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1312
/// All persistent models should conform to the Model protocol.
13+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
14+
/// by host applications. The behavior of this may change without warning.
1415
public protocol Model: Codable {
1516

1617
/// Alias of Model identifier (i.e. primary key)

Amplify/Categories/DataStore/Model/Internal/ModelRegistry+Syncable.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
98
public extension ModelRegistry {
109
static var hasSyncableModels: Bool {
1110
if #available(iOS 13.0, *) {

Amplify/Categories/DataStore/Model/Internal/ModelRegistry.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
10+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
11+
/// by host applications. The behavior of this may change without warning.
1112
public struct ModelRegistry {
1213
private static let concurrencyQueue = DispatchQueue(label: "com.amazonaws.ModelRegistry.concurrency",
1314
target: DispatchQueue.global())

Amplify/Categories/DataStore/Model/Internal/Persistable.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import Foundation
1818
/// - `Temporal.Date`
1919
/// - `Temporal.DateTime`
2020
/// - `Temporal.Time`
21+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
22+
/// by host applications. The behavior of this may change without warning.
2123
public protocol Persistable {}
2224

2325
extension Bool: Persistable {}

Amplify/Categories/DataStore/Model/Internal/Schema/AuthRule.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public enum ModelOperation {
2121

2222
public typealias AuthRules = [AuthRule]
2323

24-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
24+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
25+
/// by host applications. The behavior of this may change without warning.
2526
public struct AuthRule {
2627
public let allow: AuthStrategy
2728
public let ownerField: String?

Amplify/Categories/DataStore/Model/Internal/Schema/Model+Schema.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
extension Model {
1211

1312
public static var schema: ModelSchema {

Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
/// Defines the association type between two models. The type of association is
1211
/// important when defining how to store and query them. Each association have
1312
/// its own rules depending on the storage mechanism.
@@ -85,6 +84,8 @@ import Foundation
8584
/// }
8685
/// ```
8786
///
87+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
88+
/// by host applications. The behavior of this may change without warning.
8889
public enum ModelAssociation {
8990
case hasMany(associatedWith: CodingKey?)
9091
case hasOne(associatedWith: CodingKey?)

Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+Attributes.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
98
/// Convenience getters for attributes
109
public extension ModelSchema {
1110

Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+Definition.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
import Foundation
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
/// Defines the type of a `Model` field.
11+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
12+
/// by host applications. The behavior of this may change without warning.
1213
public enum ModelFieldType {
1314

1415
case string
@@ -72,6 +73,8 @@ public enum ModelFieldType {
7273
}
7374
}
7475

76+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
77+
/// by host applications. The behavior of this may change without warning.
7578
public enum ModelFieldNullability {
7679
case optional
7780
case required
@@ -86,6 +89,8 @@ public enum ModelFieldNullability {
8689
}
8790
}
8891

92+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
93+
/// by host applications. The behavior of this may change without warning.
8994
public struct ModelSchemaDefinition {
9095

9196
internal let name: String
@@ -125,6 +130,8 @@ public struct ModelSchemaDefinition {
125130
}
126131
}
127132

133+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
134+
/// by host applications. The behavior of this may change without warning.
128135
public enum ModelFieldDefinition {
129136

130137
case field(name: String,

Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public enum ModelFieldAttribute {
1818
case primaryKey
1919
}
2020

21-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
21+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
22+
/// by host applications. The behavior of this may change without warning.
2223
public struct ModelField {
2324

2425
public let name: String
@@ -52,7 +53,8 @@ public struct ModelField {
5253

5354
public typealias ModelFields = [String: ModelField]
5455

55-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
56+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
57+
/// by host applications. The behavior of this may change without warning.
5658
public struct ModelSchema {
5759

5860
public let name: String

Amplify/Categories/DataStore/Model/Internal/Schema/ModelValueConverter.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import Foundation
99

1010
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1111
/// Establishes how `Model` fields should be converted to and from different targets (e.g. SQL and GraphQL).
12+
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
13+
/// by host applications. The behavior of this may change without warning.
1214
public protocol ModelValueConverter {
1315

1416
/// The base type on the source (i.e. the `Model` property type)

AmplifyPlugins/Core/AWSPluginsCore/Model/AnyModel/Model+AnyModel.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Amplify
99

10-
/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
1110
public extension Model {
1211
func eraseToAnyModel() throws -> AnyModel {
1312
AnyModel(self)

AmplifyTests/CategoryTests/DataStore/Support/AnyModelTester.swift renamed to AmplifyPlugins/Core/AWSPluginsCoreTests/Model/AnyModel/AnyModelTester.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Amplify
9+
import AWSPluginsCore
910
import Foundation
1011

1112
struct AnyModelTester: Model {

AmplifyTests/CategoryTests/DataStore/AnyModelTests.swift renamed to AmplifyPlugins/Core/AWSPluginsCoreTests/Model/AnyModel/AnyModelTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Amplify
9+
import AWSPluginsCore
910
import XCTest
1011

1112
class AnyModelTests: XCTestCase {

AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Storage/SQLite/Statement+Model.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct StatementResult<M: Model>: Decodable {
2121

2222
let elements: [M]
2323

24-
public static func from(dictionary: ModelValues) throws -> Self {
24+
static func from(dictionary: ModelValues) throws -> Self {
2525
let data = try JSONSerialization.data(withJSONObject: dictionary)
2626
let decoder = JSONDecoder()
2727
decoder.dateDecodingStrategy = ModelDateFormatting.decodingStrategy

0 commit comments

Comments
 (0)