Protocols

The following protocols are available globally.

Embeddable

  • A Embeddable type can be used in a Model as an embedded type. All types embedded in a Model as an 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 & 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.
    See more

    Declaration

    Swift

    public protocol Embeddable : Decodable, Encodable

Model

  • All persistent models should conform to the Model protocol.

    See more

    Declaration

    Swift

    public protocol Model : Decodable, Encodable
  • Protocol that represents a Codable Enum that can be persisted and easily integrate with remote APIs since it must have a raw String value.

    That means only enums without associated values can be used as model properties.

    • Example:
    public enum PostStatus: String, EnumPersistable {
        case draft
        case published
    }
    

    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.
    See more

    Declaration

    Swift

    public protocol EnumPersistable : Decodable, Encodable
  • ModelListDecoder provides decoding and list functionality.

    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.
    See more

    Declaration

    Swift

    public protocol ModelListDecoder
  • Empty protocol used as a marker to detect when the type is a List

    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.

    Declaration

    Swift

    public protocol ModelListMarker
  • 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.
    See more

    Declaration

    Swift

    public protocol ModelListProvider
  • Types that conform to the Persistable protocol represent values that can be persisted in a database.

    Core Types that conform to this protocol:

    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.

    Declaration

    Swift

    public protocol Persistable
  • Establishes how Model fields should be converted to and from different targets (e.g. SQL and GraphQL).

    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.
    See more

    Declaration

    Swift

    public protocol ModelValueConverter
  • A type that holds internal data in json format

    Internally a JSONValueHolder will have the data stored as a json map. Properties of the type can be retrieved using the function jsonValue(for:) passing in the key of the property.

    Example:

        struct DynamicModel: JSONValueHolder {
            let values: [String: Any]
    
            public func jsonValue(for key: String) -> Any??  {
                return values[key]
            }
         }
    
    See more

    Declaration

    Swift

    public protocol JSONValueHolder
  • AnyModelIdentifierFormat

    Declaration

    Swift

    public protocol AnyModelIdentifierFormat
  • Defines requirements for a model to be identifiable with a unique identifier that can be either a single field or a combination of fields

    See more

    Declaration

    Swift

    public protocol ModelIdentifiable
  • Defines a ModelIdentifier requirements.

    See more

    Declaration

    Swift

    public protocol ModelIdentifierProtocol
  • Supports addition and subtraction of Temporal.Date and Temporal.DateTime with DateUnit

    See more

    Declaration

    Swift

    public protocol DateUnitOperable
  • The TemporalSpec protocol defines an ISO-8601 formatted Date value. Types that conform to this protocol are responsible for providing the parsing and formatting logic with the correct granularity.

    See more

    Declaration

    Swift

    public protocol TemporalSpec
  • Defines a common format for a TemporalSpec unit used in operations. It is a tuple of Calendar.Component, such as .year, and an integer value. Those two are later used in date operations such “4 hours from now” and “2 months ago”.

    See more

    Declaration

    Swift

    @available(*, deprecated, message: "This protocol will be removed in the future.")
    public protocol TemporalUnit
  • Supports addition and subtraction of Temporal.Time and Temporal.DateTime with TimeUnit

    See more

    Declaration

    Swift

    public protocol TimeUnitOperable
  • Declaration

    Swift

    public protocol Evaluable
  • The ModelKey protocol is used to decorate Swift standard’s CodingKey enum with query functions and operators that are used to build query conditions.

    let post = Post.keys
    
    Amplify.DataStore.query(Post.self, where: {
        post.title.contains("[Amplify]")
        .and(post.content.ne(nil))
    })
    

    Using Operators:

    The operators on a ModelKey reference are defined so queries can also be written with Swift operators as well:

    let post = Post.keys
    
    Amplify.DataStore.query(Post.self, where: {
        post.title ~= "[Amplify]" &&
        post.content != nil
    })
    

    Declaration

    Swift

    public protocol ModelKey : QueryFieldOperation, CaseIterable, CodingKey
  • QueryFieldOperation provides functions that creates predicates based on a field name. These functions are matchers that get executed at a later point by specific implementations of the Model filtering logic (e.g. SQL or GraphQL queries).

    Seealso

    QueryField

    Seealso

    ModelKey
    See more

    Declaration

    Swift

    public protocol QueryFieldOperation
  • Protocol that indicates concrete types conforming to it can be used a predicate member.

    Declaration

    Swift

    public protocol QueryPredicate : Evaluable
  • Behavior of the Geo category that clients will use

    See more

    Declaration

    Swift

    public protocol GeoCategoryBehavior
  • Geo category plugin

    See more

    Declaration

    Swift

    public protocol GeoCategoryPlugin : GeoCategoryBehavior, Plugin
  • Behavior of the Hub category that clients will use

    See more

    Declaration

    Swift

    public protocol HubCategoryBehavior
  • Declaration

    Swift

    public protocol HubCategoryPlugin : HubCategoryBehavior, Plugin
  • Declaration

    Swift

    public protocol HubPayloadEventNameable
  • Defines a log convenience property, and provides a default implementation that returns a Logger for a category name of String(describing: self)

    See more

    Declaration

    Swift

    public protocol DefaultLogger
  • Declaration

    Swift

    public protocol LoggingCategoryClientBehavior
  • Declaration

    Swift

    public protocol Logger
  • The behavior that all LoggingPlugins provide

    See more

    Declaration

    Swift

    public protocol LoggingCategoryPlugin : LoggingCategoryClientBehavior, Plugin
  • protocol describing identified text in an image

    See more

    Declaration

    Swift

    public protocol IdentifiedText
  • Declaration

    Swift

    public protocol PredictionsIdentifyOperation: AmplifyOperation<
        PredictionsIdentifyRequest,
        IdentifyResult,
        PredictionsError
    >
  • Declaration

    Swift

    public protocol PredictionsInterpretOperation: AmplifyOperation<
        PredictionsInterpretRequest,
        InterpretResult,
        PredictionsError
    >
  • Declaration

    Swift

    public protocol PredictionsSpeechToTextOperation: AmplifyOperation<PredictionsSpeechToTextRequest,
    SpeechToTextResult, PredictionsError>
  • Declaration

    Swift

    public protocol PredictionsTextToSpeechOperation: AmplifyOperation<
        PredictionsTextToSpeechRequest,
        TextToSpeechResult,
        PredictionsError
    >
  • Declaration

    Swift

    public protocol PredictionsTranslateTextOperation: AmplifyOperation<PredictionsTranslateTextRequest,
    TranslateTextResult, PredictionsError>
  • Behavior of the Predictions category that clients will use

    See more

    Declaration

    Swift

    public protocol PredictionsCategoryBehavior
  • Declaration

    Swift

    public protocol PredictionsCategoryPlugin : Plugin, PredictionsCategoryBehavior
  • Declaration

    Swift

    public protocol ConvertResult
  • Declaration

    Swift

    public protocol IdentifyResult
  • Declaration

    Swift

    public protocol StorageDownloadDataOperation: AmplifyInProcessReportingOperation<
        StorageDownloadDataRequest,
        Progress,
        Data,
        StorageError
    >
  • This operation encapsulates work to download an object from cloud storage to local storage.

    Event descriptions

    • InProcess: Progress - representing the progress of the download. This event will be emitted as controlled by the underlying NSURLSession behavior, but could be multiple times per second. Apps should not rely on Progress to be 1.0 to determine a completed operation
    • Completed: Void - Receipt of a .completed event indicates the download is complete and the file has been successfully stored to the local URL supplied in the original StorageDownloadFileRequest
    • Error: StorageError - Emitted if the download encounters an error.

    Declaration

    Swift

    public protocol StorageDownloadFileOperation: AmplifyInProcessReportingOperation<
        StorageDownloadFileRequest,
        Progress,
        Void,
        StorageError
    >
  • Declaration

    Swift

    public protocol StorageGetURLOperation : AmplifyOperation<StorageGetURLRequest, URL, StorageError>
  • Declaration

    Swift

    public protocol StorageListOperation : AmplifyOperation<StorageListRequest, StorageListResult, StorageError>
  • Declaration

    Swift

    public protocol StorageRemoveOperation : AmplifyOperation<StorageRemoveRequest, String, StorageError>
  • Declaration

    Swift

    public protocol StorageUploadDataOperation: AmplifyInProcessReportingOperation<
        StorageUploadDataRequest,
        Progress,
        String,
        StorageError
    >
  • Declaration

    Swift

    public protocol StorageUploadFileOperation: AmplifyInProcessReportingOperation<
        StorageUploadFileRequest,
        Progress,
        String,
        StorageError
    >
  • Behavior of the Storage category that clients will use

    See more

    Declaration

    Swift

    public protocol StorageCategoryBehavior
  • Declaration

    Swift

    public protocol StorageCategoryPlugin : Plugin, StorageCategoryBehavior
  • An Amplify Category stores certain global states, holds references to plugins for the category, and routes method requests to those plugins appropriately.

    See more

    Declaration

    Swift

    public protocol Category : AnyObject, CategoryTypeable, DefaultLogger
  • The Amplify category with which the conforming type is associated. Categories, Plugins, ClientBehaviors, etc must all share the same CategoryType

    See more

    Declaration

    Swift

    public protocol CategoryTypeable
  • A CategoryConfiguration must contain a plugins field used to configure plugins for that category

    See more

    Declaration

    Swift

    public protocol CategoryConfiguration : Decodable, Encodable
  • Note that although this protocol is public, the reset method is intended only for internal use, and should not be invoked by host applications.

    See more

    Declaration

    Swift

    public protocol Resettable
  • CategoryPlugins implement the behavior defined by the category. The Plugin protocol defines behavior common to all plugins, but each category will also define client API behavior and optionally, plugin API behavior to describe the contract to which the plugin must conform.

    See more

    Declaration

    Swift

    public protocol Plugin : CategoryTypeable, Resettable
  • The conforming type can be initialized with a Plugin. Allows for construction of concrete, type-erasing wrappers to store heterogenous collections of Plugins in a category.

    Throws

    PluginError.mismatchedPlugin if the instance is associated with the wrong category
    See more

    Declaration

    Swift

    public protocol PluginInitializable
  • Amplify’s philosophy is to expose friendly error messages to the customer that assist with debugging. Therefore, failable APIs are declared to return error results with Amplify errors, which require recovery suggestions and error messages.

    See more

    Declaration

    Swift

    public protocol AmplifyError : CustomDebugStringConvertible, Error
  • Describes the parameters that are passed during the creation of an AmplifyOperation

    See more

    Declaration

    Swift

    public protocol AmplifyOperationRequest
  • The conforming type supports canceling an in-process operation. The exact semantics of “canceling” are not defined in the protocol. Specifically, there is no guarantee that a cancel results in immediate cessation of activity.

    See more

    Declaration

    Swift

    public protocol Cancellable
  • The conforming type supports pausing and resuming of an in-process operation. The exact semantics of “pausing” and “resuming” are not defined in the protocol. Specifically, there is no guarantee that a pause results in an immediate suspention of activity, and no guarantee that resume will result in an immediate resumption of activity.

    See more

    Declaration

    Swift

    public protocol Resumable
  • Implement this protocol to support versioning in your plugin

    See more

    Declaration

    Swift

    public protocol AmplifyVersionable
  • A protocol describing the behaviors of a Developer Menu

    See more

    Declaration

    Swift

    public protocol DevMenuBehavior
  • A protocol which provides a UI context over which views can be presented

    See more

    Declaration

    Swift

    @available(iOS 13.0, *)
    public protocol DevMenuPresentationContextProvider : AnyObject
  • Implement this protocol to get notified of the trigger events recognized by a TriggerRecognizer

    See more

    Declaration

    Swift

    public protocol TriggerDelegate : AnyObject
  • A protocol to be implemented for recognizing user interaction events which notifies a TriggerDelegate if it has one

    See more

    Declaration

    Swift

    public protocol TriggerRecognizer
  • Declaration

    Swift

    public protocol AuthInvalidateCredentialBehavior