123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- ////////////////////////////////////////////////////////////////////////////
- //
- // Copyright 2016 Realm Inc.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License 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.
- //
- ////////////////////////////////////////////////////////////////////////////
- #import <Realm/RLMConstants.h>
- /// A token originating from the Realm Object Server.
- typedef NSString* RLMServerToken;
- NS_ASSUME_NONNULL_BEGIN
- /// A user info key for use with `RLMSyncErrorClientResetError`.
- extern NSString *const kRLMSyncPathOfRealmBackupCopyKey;
- /// A user info key for use with `RLMSyncErrorClientResetError`.
- extern NSString *const kRLMSyncInitiateClientResetBlockKey;
- /**
- The error domain string for all SDK errors related to errors reported
- by the synchronization manager error handler, as well as general sync
- errors that don't fall into any of the other categories.
- */
- extern NSString *const RLMSyncErrorDomain;
- /**
- The error domain string for all SDK errors related to the authentication
- endpoint.
- */
- extern NSString *const RLMSyncAuthErrorDomain;
- /**
- The error domain string for all SDK errors related to the permissions
- system and APIs.
- */
- extern NSString *const RLMSyncPermissionErrorDomain;
- /**
- An error related to a problem that might be reported by the synchronization manager
- error handler, or a callback on a sync-related API that performs asynchronous work.
- */
- typedef RLM_ERROR_ENUM(NSInteger, RLMSyncError, RLMSyncErrorDomain) {
- /**
- An error that indicates that the response received from the
- authentication server was malformed.
-
- @warning This error is deprecated, and has been replaced by
- `RLMSyncAuthErrorBadResponse`.
- */
- RLMSyncErrorBadResponse __deprecated_msg("This error has been replaced by 'RLMSyncAuthErrorBadResponse'") = 1,
- /// An error that indicates a problem with the session (a specific Realm opened for sync).
- RLMSyncErrorClientSessionError = 4,
- /// An error that indicates a problem with a specific user.
- RLMSyncErrorClientUserError = 5,
- /**
- An error that indicates an internal, unrecoverable problem
- with the underlying synchronization engine.
- */
- RLMSyncErrorClientInternalError = 6,
- /**
- An error that indicates the Realm needs to be reset.
- A synced Realm may need to be reset because the Realm Object Server encountered an
- error and had to be restored from a backup. If the backup copy of the remote Realm
- is of an earlier version than the local copy of the Realm, the server will ask the
- client to reset the Realm.
- The reset process is as follows: the local copy of the Realm is copied into a recovery
- directory for safekeeping, and then deleted from the original location. The next time
- the Realm for that URL is opened, the Realm will automatically be re-downloaded from the
- Realm Object Server, and can be used as normal.
- Data written to the Realm after the local copy of the Realm diverged from the backup
- remote copy will be present in the local recovery copy of the Realm file. The
- re-downloaded Realm will initially contain only the data present at the time the Realm
- was backed up on the server.
- The client reset process can be initiated in one of two ways. The block provided in the
- `userInfo` dictionary under `kRLMSyncInitiateClientResetBlockKey` can be called to
- initiate the reset process. This block can be called any time after the error is
- received, but should only be called if and when your app closes and invalidates every
- instance of the offending Realm on all threads (note that autorelease pools may make this
- difficult to guarantee).
- If the block is not called, the client reset process will be automatically carried out
- the next time the app is launched and the `RLMSyncManager` singleton is accessed.
- The value for the `kRLMSyncPathOfRealmBackupCopyKey` key in the `userInfo` dictionary
- describes the path of the recovered copy of the Realm. This copy will not actually be
- created until the client reset process is initiated.
- @see `-[NSError rlmSync_clientResetBlock]`, `-[NSError rlmSync_clientResetBackedUpRealmPath]`
- */
- RLMSyncErrorClientResetError = 7,
- /**
- An error that indicates an authentication error occurred.
- The `kRLMSyncUnderlyingErrorKey` key in the user info dictionary will contain the
- underlying error, which is guaranteed to be under the `RLMSyncAuthErrorDomain`
- error domain.
- */
- RLMSyncErrorUnderlyingAuthError = 8,
- };
- /// An error which is related to authentication to a Realm Object Server.
- typedef RLM_ERROR_ENUM(NSInteger, RLMSyncAuthError, RLMSyncAuthErrorDomain) {
- /// An error that indicates that the response received from the authentication server was malformed.
- RLMSyncAuthErrorBadResponse = 1,
- /// An error that indicates that the supplied Realm path was invalid, or could not be resolved by the authentication
- /// server.
- RLMSyncAuthErrorBadRemoteRealmPath = 2,
- /// An error that indicates that the response received from the authentication server was an HTTP error code. The
- /// `userInfo` dictionary contains the actual error code value.
- RLMSyncAuthErrorHTTPStatusCodeError = 3,
- /// An error that indicates a problem with the session (a specific Realm opened for sync).
- RLMSyncAuthErrorClientSessionError = 4,
- /// An error that indicates that the provided credentials are invalid.
- RLMSyncAuthErrorInvalidCredential = 611,
- /// An error that indicates that the user with provided credentials does not exist.
- RLMSyncAuthErrorUserDoesNotExist = 612,
- /// An error that indicates that the user cannot be registered as it exists already.
- RLMSyncAuthErrorUserAlreadyExists = 613,
- };
- /**
- An error related to the permissions subsystem.
- */
- typedef RLM_ERROR_ENUM(NSInteger, RLMSyncPermissionError, RLMSyncPermissionErrorDomain) {
- /**
- An error that indicates a permission change operation failed. The `userInfo`
- dictionary contains the underlying error code and a message (if any).
- */
- RLMSyncPermissionErrorChangeFailed = 1,
- /**
- An error that indicates that attempting to retrieve permissions failed.
- */
- RLMSyncPermissionErrorGetFailed = 2,
- };
- /// An enum representing the different states a sync management object can take.
- typedef NS_ENUM(NSUInteger, RLMSyncManagementObjectStatus) {
- /// The management object has not yet been processed by the object server.
- RLMSyncManagementObjectStatusNotProcessed,
- /// The operations encoded in the management object have been successfully
- /// performed by the object server.
- RLMSyncManagementObjectStatusSuccess,
- /**
- The operations encoded in the management object were not successfully
- performed by the object server.
- Refer to the `statusCode` and `statusMessage` properties for more details
- about the error.
- */
- RLMSyncManagementObjectStatusError,
- };
- NS_ASSUME_NONNULL_END
|