Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Amplify/Categories/DataStore/Model/Internal/Embedded.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import Foundation
/// `embedded(type:)` or `embeddedCollection(of:)` must comform to the `Embeddable` protocol except for Swift's Basic
/// types embedded as a collection. A collection of String can be embedded in the `Model` as
/// `embeddedCollection(of: String.self)` without needing to conform to Embeddable.
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
///
public protocol Embeddable: Codable {

/// A reference to the `ModelSchema` associated with this embedded type.
Expand Down
10 changes: 6 additions & 4 deletions Amplify/Categories/DataStore/Model/Internal/Model+Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import Foundation

extension Array where Element: Model {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public func unique() throws -> Element? {
guard (0 ... 1).contains(count) else {
throw DataStoreError.nonUniqueResult(model: Element.modelName, count: count)
Expand All @@ -21,8 +22,9 @@ extension Array where Element: Model {

extension Array where Element == Model {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public func unique() throws -> Element? {
guard (0 ... 1).contains(count) else {
let firstModelName = self[0].modelName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ extension Model where Self: Codable {
/// - Returns: an instance of the concrete type conforming to `Model`
/// - Throws: `DecodingError.dataCorrupted` in case data is not a valid JSON or any
/// other decoding specific error that `JSONDecoder.decode()` might throw.
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public static func from(json: String,
decoder: JSONDecoder? = nil) throws -> Self {
let resolvedDecoder: JSONDecoder
Expand All @@ -48,8 +49,9 @@ extension Model where Self: Codable {
/// - Returns: an instance of the concrete type conforming to `Model`
/// - Throws: `DecodingError.dataCorrupted` in case data is not a valid JSON or any
/// other decoding specific error that `JSONDecoder.decode()` might throw.
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public static func from(dictionary: [String: Any]) throws -> Self {
let data = try JSONSerialization.data(withJSONObject: dictionary)
let decoder = JSONDecoder(dateDecodingStrategy: ModelDateFormatting.decodingStrategy)
Expand All @@ -62,8 +64,9 @@ extension Model where Self: Codable {
/// custom date formatter that encodes ISO8601 dates with fractional seconds
/// - Returns: the JSON representation of the `Model`
/// - seealso: https://developer.apple.com/documentation/foundation/jsonencoder/2895034-encode
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public func toJSON(encoder: JSONEncoder? = nil) throws -> String {
let resolvedEncoder: JSONEncoder
if let encoder = encoder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import Foundation

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public struct ModelDateFormatting {

public static let decodingStrategy: JSONDecoder.DateDecodingStrategy = {
Expand All @@ -34,8 +35,9 @@ public struct ModelDateFormatting {

public extension JSONDecoder {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
convenience init(dateDecodingStrategy: JSONDecoder.DateDecodingStrategy) {
self.init()
self.dateDecodingStrategy = dateDecodingStrategy
Expand All @@ -44,8 +46,9 @@ public extension JSONDecoder {

public extension JSONEncoder {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
convenience init(dateEncodingStrategy: JSONEncoder.DateEncodingStrategy) {
self.init()
self.dateEncodingStrategy = dateEncodingStrategy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
/// ```
extension Model {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public subscript(_ key: String) -> Any?? {

if let jsonModel = self as? JSONValueHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

public extension ModelRegistry {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
static var hasSyncableModels: Bool {
if #available(iOS 13.0, *) {
return modelSchemas.contains { !$0.isSystem }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ struct PersistableHelper {
/// - lhs: a reference to a Persistable object
/// - rhs: another reference
/// - Returns: `true` in case both values are equal or `false` otherwise
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public static func isEqual(_ lhs: Persistable?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import Foundation

extension Model {

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public static var schema: ModelSchema {
// TODO load schema from JSON when this it not overridden by specific models
ModelSchema(name: modelName, fields: [:])
}

/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used directly
/// by host applications. The behavior of this may change without warning. Though it is not used by host application making any change
/// to these `public` types should be backward compatible, otherwise it will be a breaking change.
public var schema: ModelSchema {
type(of: self).schema
}
Expand Down
Loading