3 #import <CloudKit/CloudKit.h>
4 #import <Foundation/Foundation.h>
6 #import "keychain/ckks/CKKSNearFutureScheduler.h"
7 #import "keychain/ckks/CKKSReachabilityTracker.h"
8 #import "keychain/ckks/CKKSResultOperation.h"
9 #import "keychain/ckks/CKKSCloudKitClassDependencies.h"
11 NS_ASSUME_NONNULL_BEGIN
13 @interface CKKSZoneModifyOperations
: NSObject
14 @property CKKSResultOperation
* zoneModificationOperation
;
15 @property CKKSResultOperation
* zoneSubscriptionOperation
;
17 @
property (readonly
) NSMutableArray
<CKRecordZone
*>* zonesToCreate
;
18 @
property (readonly
) NSMutableArray
<CKRecordZoneSubscription
*>* subscriptionsToSubscribe
;
19 @
property (readonly
) NSMutableArray
<CKRecordZoneID
*>* zoneIDsToDelete
;
21 - (instancetype
)init NS_UNAVAILABLE
;
23 // After the operations run, these properties will be filled in:
24 // Note that your zone may or may not succeed even if the whole operation fails
25 @
property (nullable
) NSArray
<CKRecordZone
*>* savedRecordZones
;
26 @
property (nullable
) NSArray
<CKRecordZoneID
*>* deletedRecordZoneIDs
;
27 // The error from the zone modifcation, if any, will be on the zoneModificationOperation
29 @
property (nullable
) NSArray
<CKSubscription
*>* savedSubscriptions
;
30 @
property (nullable
) NSArray
<NSString
*>* deletedSubscriptionIDs
;
31 // The error from the zone subscription, if any, will be on the zoneSubscriptionOperation
35 @interface CKKSZoneModifier
: NSObject
36 @
property (readonly
) CKKSReachabilityTracker
* reachabilityTracker
;
37 @
property (readonly
) CKKSCloudKitClassDependencies
* cloudKitClassDependencies
;
38 @
property (readonly
) CKContainer
* container
;
39 @
property (readonly
) CKDatabase
* database
;
41 // Block on this to schedule operations for directly after a CloudKit retryAfter delay expires
42 @
property (readonly
) CKKSNearFutureScheduler
* cloudkitRetryAfter
;
44 // Send every CK error here: it will update the cloudkitRetryAfter scheduler
45 - (void)inspectErrorForRetryAfter
:(NSError
*)ckerror
;
47 - (instancetype
)init NS_UNAVAILABLE
;
48 - (instancetype
)initWithContainer
:(CKContainer
*)container
49 reachabilityTracker
:(CKKSReachabilityTracker
*)reachabilityTracker
50 cloudkitDependencies
:(CKKSCloudKitClassDependencies
*)_cloudKitClassDependencies
;
52 - (CKKSZoneModifyOperations
*)createZone
:(CKRecordZone
*)zone
;
54 // Note that on a zone delete, we do not run the subscription operation
55 // It may or may not run, depending on if any other zone creations have been requested
56 - (CKKSZoneModifyOperations
*)deleteZone
:(CKRecordZoneID
*)zoneID
;