//
//  DOWebRevision.h
//  DOCore
//
//  Created by Ben Dolman on 7/15/14.
//
//

#import <DOCore/DOWebObject.h>

@class DOJournalEntryFile;
@class DOWebEntry;
@class DOUUID;

extern NSString *const DOWebRevisionTypeCreate;
extern NSString *const DOWebRevisionTypeUpdate;
extern NSString *const DOWebRevisionTypeMerge;
extern NSString *const DOWebRevisionTypeDelete;

@interface DOWebRevision : DOWebObject

@property (nonatomic, copy) DOUUID *entryID;
@property (nonatomic, copy) NSNumber *revisionID;
@property (nonatomic, copy) NSString *userID;
@property (nonatomic, copy) NSString *deviceID;
@property (nonatomic, copy) NSString *type;
@property (nonatomic, strong) NSDate *editDate;
@property (nonatomic, strong) NSDate *saveDate;
@property (nonatomic, copy) NSArray *revisionHistory;
@property (nonatomic, copy) NSString *version;
@property (nonatomic, strong) DOWebEntry *entry;

/**
 * Determines the revision history ordering compared to another revision.
 *
 * Returns:
 *   NSOrderedAscending - otherRevision is a descendant (newer)
 *   NSOrderedDescending - otherRevision is an ancestor (older)
 *   NSOrderedSame - Same head revisions.
 */
- (NSComparisonResult)compare:(DOWebRevision *)otherRevision;

- (id)initWithEntryFile:(DOJournalEntryFile *)entryFile;

- (BOOL)isUpdate;
- (BOOL)isCreate;
- (BOOL)isMerge;
- (BOOL)isDelete;

@end

extern NSString * const DOWebRevisionUnarchiveFromOriginalTransformerName;

@interface DOWebRevision (Original)

- (instancetype)initWithOriginalDictionary:(NSDictionary *)originalDictionary error:(NSError **)error;

@property (nonatomic, strong, readonly) NSDictionary *originalDictionary;

@end
