commit
4a378f8737
@ -0,0 +1,262 @@ |
|||||||
|
// |
||||||
|
// User.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 21/02/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
enum UserRight: Int, Codable { |
||||||
|
case none = 0 |
||||||
|
case edition = 1 |
||||||
|
case creation = 2 |
||||||
|
} |
||||||
|
|
||||||
|
@Observable |
||||||
|
class CustomUser: BaseCustomUser, UserBase { |
||||||
|
|
||||||
|
// static func resourceName() -> String { "users" } |
||||||
|
// static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] } |
||||||
|
// static func filterByStoreIdentifier() -> Bool { return false } |
||||||
|
// static var relationshipNames: [String] = [] |
||||||
|
// |
||||||
|
// public var id: String = Store.randomId() |
||||||
|
// var lastUpdate: Date |
||||||
|
// public var username: String |
||||||
|
// public var email: String |
||||||
|
// var clubs: [String] = [] |
||||||
|
// var umpireCode: String? |
||||||
|
// var licenceId: String? |
||||||
|
// var firstName: String |
||||||
|
// var lastName: String |
||||||
|
// var phone: String? |
||||||
|
// var country: String? |
||||||
|
// |
||||||
|
// var summonsMessageBody : String? = nil |
||||||
|
// var summonsMessageSignature: String? = nil |
||||||
|
// var summonsAvailablePaymentMethods: String? = nil |
||||||
|
// var summonsDisplayFormat: Bool = false |
||||||
|
// var summonsDisplayEntryFee: Bool = false |
||||||
|
// var summonsUseFullCustomMessage: Bool = false |
||||||
|
// var matchFormatsDefaultDuration: [MatchFormat: Int]? = nil |
||||||
|
// var bracketMatchFormatPreference: MatchFormat? |
||||||
|
// var groupStageMatchFormatPreference: MatchFormat? |
||||||
|
// var loserBracketMatchFormatPreference: MatchFormat? |
||||||
|
// var loserBracketMode: LoserBracketMode = .automatic |
||||||
|
// |
||||||
|
// var deviceId: String? |
||||||
|
|
||||||
|
init(username: String, email: String, firstName: String, lastName: String, phone: String?, country: String?, loserBracketMode: LoserBracketMode = .automatic) { |
||||||
|
super.init(username: username, email: email, firstName: firstName, lastName: lastName, phone: phone, country: country, loserBracketMode: loserBracketMode) |
||||||
|
|
||||||
|
|
||||||
|
// self.lastUpdate = Date() |
||||||
|
// self.username = username |
||||||
|
// self.firstName = firstName |
||||||
|
// self.lastName = lastName |
||||||
|
// self.email = email |
||||||
|
// self.phone = phone |
||||||
|
// self.country = country |
||||||
|
// self.loserBracketMode = loserBracketMode |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
public func uuid() throws -> UUID { |
||||||
|
if let uuid = UUID(uuidString: self.id) { |
||||||
|
return uuid |
||||||
|
} |
||||||
|
throw UUIDError.cantConvertString(string: self.id) |
||||||
|
} |
||||||
|
|
||||||
|
func currentPlayerData() -> ImportedPlayer? { |
||||||
|
guard let licenceId else { return nil } |
||||||
|
let federalContext = PersistenceController.shared.localContainer.viewContext |
||||||
|
let fetchRequest = ImportedPlayer.fetchRequest() |
||||||
|
let predicate = NSPredicate(format: "license == %@", licenceId) |
||||||
|
fetchRequest.predicate = predicate |
||||||
|
return try? federalContext.fetch(fetchRequest).first |
||||||
|
} |
||||||
|
|
||||||
|
func defaultSignature() -> String { |
||||||
|
return "Sportivement,\n\(firstName) \(lastName), votre JAP." |
||||||
|
} |
||||||
|
|
||||||
|
func fullName() -> String? { |
||||||
|
guard firstName.isEmpty == false && lastName.isEmpty == false else { |
||||||
|
return nil |
||||||
|
} |
||||||
|
return "\(firstName) \(lastName)" |
||||||
|
} |
||||||
|
|
||||||
|
func hasTenupClubs() -> Bool { |
||||||
|
self.clubsObjects().filter({ $0.code != nil }).isEmpty == false |
||||||
|
} |
||||||
|
|
||||||
|
func hasFavoriteClubsAndCreatedClubs() -> Bool { |
||||||
|
clubsObjects(includeCreated: true).isEmpty == false |
||||||
|
} |
||||||
|
|
||||||
|
func setUserClub(_ userClub: Club) { |
||||||
|
self.clubs.insert(userClub.id, at: 0) |
||||||
|
} |
||||||
|
|
||||||
|
func clubsObjects(includeCreated: Bool = false) -> [Club] { |
||||||
|
return DataStore.shared.clubs.filter({ (includeCreated && $0.creator == id) || clubs.contains($0.id) }) |
||||||
|
} |
||||||
|
|
||||||
|
func createdClubsObjectsNotFavorite() -> [Club] { |
||||||
|
return DataStore.shared.clubs.filter({ ($0.creator == id) && clubs.contains($0.id) == false }) |
||||||
|
} |
||||||
|
|
||||||
|
func saveMatchFormatsDefaultDuration(_ matchFormat: MatchFormat, estimatedDuration: Int) { |
||||||
|
if estimatedDuration == matchFormat.defaultEstimatedDuration { |
||||||
|
matchFormatsDefaultDuration?.removeValue(forKey: matchFormat) |
||||||
|
} else { |
||||||
|
matchFormatsDefaultDuration = matchFormatsDefaultDuration ?? [MatchFormat: Int]() |
||||||
|
matchFormatsDefaultDuration?[matchFormat] = estimatedDuration |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
func addClub(_ club: Club) { |
||||||
|
if !self.clubs.contains(where: { $0.id == club.id }) { |
||||||
|
self.clubs.append(club.id) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// enum CodingKeys: String, CodingKey { |
||||||
|
// case _id = "id" |
||||||
|
// case _lastUpdate = "lastUpdate" |
||||||
|
// case _username = "username" |
||||||
|
// case _email = "email" |
||||||
|
// case _clubs = "clubs" |
||||||
|
// case _umpireCode = "umpireCode" |
||||||
|
// case _licenceId = "licenceId" |
||||||
|
// case _firstName = "firstName" |
||||||
|
// case _lastName = "lastName" |
||||||
|
// case _phone = "phone" |
||||||
|
// case _country = "country" |
||||||
|
// case _summonsMessageBody = "summonsMessageBody" |
||||||
|
// case _summonsMessageSignature = "summonsMessageSignature" |
||||||
|
// case _summonsAvailablePaymentMethods = "summonsAvailablePaymentMethods" |
||||||
|
// case _summonsDisplayFormat = "summonsDisplayFormat" |
||||||
|
// case _summonsDisplayEntryFee = "summonsDisplayEntryFee" |
||||||
|
// case _summonsUseFullCustomMessage = "summonsUseFullCustomMessage" |
||||||
|
// case _matchFormatsDefaultDuration = "matchFormatsDefaultDuration" |
||||||
|
// case _bracketMatchFormatPreference = "bracketMatchFormatPreference" |
||||||
|
// case _groupStageMatchFormatPreference = "groupStageMatchFormatPreference" |
||||||
|
// case _loserBracketMatchFormatPreference = "loserBracketMatchFormatPreference" |
||||||
|
// case _deviceId = "deviceId" |
||||||
|
// case _loserBracketMode = "loserBracketMode" |
||||||
|
// } |
||||||
|
// |
||||||
|
// public required init(from decoder: Decoder) throws { |
||||||
|
// let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
// |
||||||
|
// // Required properties |
||||||
|
// id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
// lastUpdate = try container.decodeIfPresent(Date.self, forKey: ._lastUpdate) ?? Date() |
||||||
|
// username = try container.decode(String.self, forKey: ._username) |
||||||
|
// email = try container.decode(String.self, forKey: ._email) |
||||||
|
// firstName = try container.decode(String.self, forKey: ._firstName) |
||||||
|
// lastName = try container.decode(String.self, forKey: ._lastName) |
||||||
|
// |
||||||
|
// // Optional properties |
||||||
|
// clubs = try container.decodeIfPresent([String].self, forKey: ._clubs) ?? [] |
||||||
|
// umpireCode = try container.decodeIfPresent(String.self, forKey: ._umpireCode) |
||||||
|
// licenceId = try container.decodeIfPresent(String.self, forKey: ._licenceId) |
||||||
|
// phone = try container.decodeIfPresent(String.self, forKey: ._phone) |
||||||
|
// country = try container.decodeIfPresent(String.self, forKey: ._country) |
||||||
|
// |
||||||
|
// // Summons-related properties |
||||||
|
// summonsMessageBody = try container.decodeIfPresent(String.self, forKey: ._summonsMessageBody) |
||||||
|
// summonsMessageSignature = try container.decodeIfPresent(String.self, forKey: ._summonsMessageSignature) |
||||||
|
// summonsAvailablePaymentMethods = try container.decodeIfPresent(String.self, forKey: ._summonsAvailablePaymentMethods) |
||||||
|
// summonsDisplayFormat = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayFormat) ?? false |
||||||
|
// summonsDisplayEntryFee = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayEntryFee) ?? false |
||||||
|
// summonsUseFullCustomMessage = try container.decodeIfPresent(Bool.self, forKey: ._summonsUseFullCustomMessage) ?? false |
||||||
|
// |
||||||
|
// // Match-related properties |
||||||
|
// matchFormatsDefaultDuration = try container.decodeIfPresent([MatchFormat: Int].self, forKey: ._matchFormatsDefaultDuration) |
||||||
|
// bracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._bracketMatchFormatPreference) |
||||||
|
// groupStageMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._groupStageMatchFormatPreference) |
||||||
|
// loserBracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._loserBracketMatchFormatPreference) |
||||||
|
// loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic |
||||||
|
// } |
||||||
|
// |
||||||
|
// func encode(to encoder: Encoder) throws { |
||||||
|
// var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
// |
||||||
|
// try container.encode(id, forKey: ._id) |
||||||
|
// try container.encode(lastUpdate, forKey: ._lastUpdate) |
||||||
|
// try container.encode(username, forKey: ._username) |
||||||
|
// try container.encode(email, forKey: ._email) |
||||||
|
// try container.encode(clubs, forKey: ._clubs) |
||||||
|
// |
||||||
|
// try container.encode(umpireCode, forKey: ._umpireCode) |
||||||
|
// try container.encode(licenceId, forKey: ._licenceId) |
||||||
|
// try container.encode(firstName, forKey: ._firstName) |
||||||
|
// try container.encode(lastName, forKey: ._lastName) |
||||||
|
// try container.encode(phone, forKey: ._phone) |
||||||
|
// try container.encode(country, forKey: ._country) |
||||||
|
// try container.encode(summonsMessageBody, forKey: ._summonsMessageBody) |
||||||
|
// try container.encode(summonsMessageSignature, forKey: ._summonsMessageSignature) |
||||||
|
// try container.encode(summonsAvailablePaymentMethods, forKey: ._summonsAvailablePaymentMethods) |
||||||
|
// try container.encode(summonsDisplayFormat, forKey: ._summonsDisplayFormat) |
||||||
|
// try container.encode(summonsDisplayEntryFee, forKey: ._summonsDisplayEntryFee) |
||||||
|
// try container.encode(summonsUseFullCustomMessage, forKey: ._summonsUseFullCustomMessage) |
||||||
|
// |
||||||
|
// try container.encode(matchFormatsDefaultDuration, forKey: ._matchFormatsDefaultDuration) |
||||||
|
// try container.encode(bracketMatchFormatPreference, forKey: ._bracketMatchFormatPreference) |
||||||
|
// try container.encode(groupStageMatchFormatPreference, forKey: ._groupStageMatchFormatPreference) |
||||||
|
// try container.encode(loserBracketMatchFormatPreference, forKey: ._loserBracketMatchFormatPreference) |
||||||
|
// try container.encode(deviceId, forKey: ._deviceId) |
||||||
|
// |
||||||
|
// try container.encode(loserBracketMode, forKey: ._loserBracketMode) |
||||||
|
// } |
||||||
|
|
||||||
|
static func placeHolder() -> CustomUser { |
||||||
|
return CustomUser(username: "", email: "", firstName: "", lastName: "", phone: nil, country: nil) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
class UserCreationForm: CustomUser, UserPasswordBase { |
||||||
|
|
||||||
|
init(user: CustomUser, username: String, password: String, firstName: String, lastName: String, email: String, phone: String?, country: String?) { |
||||||
|
self.password = password |
||||||
|
super.init(username: username, email: email, firstName: firstName, lastName: lastName, phone: phone, country: country) |
||||||
|
|
||||||
|
self.summonsMessageBody = user.summonsMessageBody |
||||||
|
self.summonsMessageSignature = user.summonsMessageSignature |
||||||
|
self.summonsAvailablePaymentMethods = user.summonsAvailablePaymentMethods |
||||||
|
self.summonsDisplayFormat = user.summonsDisplayFormat |
||||||
|
self.summonsDisplayEntryFee = user.summonsDisplayEntryFee |
||||||
|
self.summonsUseFullCustomMessage = user.summonsUseFullCustomMessage |
||||||
|
self.matchFormatsDefaultDuration = user.matchFormatsDefaultDuration |
||||||
|
self.bracketMatchFormatPreference = user.bracketMatchFormatPreference |
||||||
|
self.groupStageMatchFormatPreference = user.groupStageMatchFormatPreference |
||||||
|
self.loserBracketMatchFormatPreference = user.loserBracketMatchFormatPreference |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
fatalError("init(from:) has not been implemented") |
||||||
|
} |
||||||
|
|
||||||
|
public var password: String |
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey { |
||||||
|
case password |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
try super.encode(to: encoder) |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.password, forKey: .password) |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,146 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseClub: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "clubs" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var creator: String? = nil |
||||||
|
var name: String = "" |
||||||
|
var acronym: String = "" |
||||||
|
var phone: String? = nil |
||||||
|
var code: String? = nil |
||||||
|
var address: String? = nil |
||||||
|
var city: String? = nil |
||||||
|
var zipCode: String? = nil |
||||||
|
var latitude: Double? = nil |
||||||
|
var longitude: Double? = nil |
||||||
|
var courtCount: Int = 2 |
||||||
|
var broadcastCode: String? = nil |
||||||
|
var timezone: String? = TimeZone.current.identifier |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
creator: String? = nil, |
||||||
|
name: String = "", |
||||||
|
acronym: String = "", |
||||||
|
phone: String? = nil, |
||||||
|
code: String? = nil, |
||||||
|
address: String? = nil, |
||||||
|
city: String? = nil, |
||||||
|
zipCode: String? = nil, |
||||||
|
latitude: Double? = nil, |
||||||
|
longitude: Double? = nil, |
||||||
|
courtCount: Int = 2, |
||||||
|
broadcastCode: String? = nil, |
||||||
|
timezone: String? = TimeZone.current.identifier |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.creator = creator |
||||||
|
self.name = name |
||||||
|
self.acronym = acronym |
||||||
|
self.phone = phone |
||||||
|
self.code = code |
||||||
|
self.address = address |
||||||
|
self.city = city |
||||||
|
self.zipCode = zipCode |
||||||
|
self.latitude = latitude |
||||||
|
self.longitude = longitude |
||||||
|
self.courtCount = courtCount |
||||||
|
self.broadcastCode = broadcastCode |
||||||
|
self.timezone = timezone |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _creator = "creator" |
||||||
|
case _name = "name" |
||||||
|
case _acronym = "acronym" |
||||||
|
case _phone = "phone" |
||||||
|
case _code = "code" |
||||||
|
case _address = "address" |
||||||
|
case _city = "city" |
||||||
|
case _zipCode = "zipCode" |
||||||
|
case _latitude = "latitude" |
||||||
|
case _longitude = "longitude" |
||||||
|
case _courtCount = "courtCount" |
||||||
|
case _broadcastCode = "broadcastCode" |
||||||
|
case _timezone = "timezone" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.creator = try container.decodeIfPresent(String.self, forKey: ._creator) ?? nil |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? "" |
||||||
|
self.acronym = try container.decodeIfPresent(String.self, forKey: ._acronym) ?? "" |
||||||
|
self.phone = try container.decodeIfPresent(String.self, forKey: ._phone) ?? nil |
||||||
|
self.code = try container.decodeIfPresent(String.self, forKey: ._code) ?? nil |
||||||
|
self.address = try container.decodeIfPresent(String.self, forKey: ._address) ?? nil |
||||||
|
self.city = try container.decodeIfPresent(String.self, forKey: ._city) ?? nil |
||||||
|
self.zipCode = try container.decodeIfPresent(String.self, forKey: ._zipCode) ?? nil |
||||||
|
self.latitude = try container.decodeIfPresent(Double.self, forKey: ._latitude) ?? nil |
||||||
|
self.longitude = try container.decodeIfPresent(Double.self, forKey: ._longitude) ?? nil |
||||||
|
self.courtCount = try container.decodeIfPresent(Int.self, forKey: ._courtCount) ?? 2 |
||||||
|
self.broadcastCode = try container.decodeIfPresent(String.self, forKey: ._broadcastCode) ?? nil |
||||||
|
self.timezone = try container.decodeIfPresent(String.self, forKey: ._timezone) ?? TimeZone.current.identifier |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.creator, forKey: ._creator) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.acronym, forKey: ._acronym) |
||||||
|
try container.encode(self.phone, forKey: ._phone) |
||||||
|
try container.encode(self.code, forKey: ._code) |
||||||
|
try container.encode(self.address, forKey: ._address) |
||||||
|
try container.encode(self.city, forKey: ._city) |
||||||
|
try container.encode(self.zipCode, forKey: ._zipCode) |
||||||
|
try container.encode(self.latitude, forKey: ._latitude) |
||||||
|
try container.encode(self.longitude, forKey: ._longitude) |
||||||
|
try container.encode(self.courtCount, forKey: ._courtCount) |
||||||
|
try container.encode(self.broadcastCode, forKey: ._broadcastCode) |
||||||
|
try container.encode(self.timezone, forKey: ._timezone) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func creatorValue() -> CustomUser? { |
||||||
|
guard let creator = self.creator else { return nil } |
||||||
|
return Store.main.findById(creator) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let club = other as? BaseClub else { return } |
||||||
|
self.id = club.id |
||||||
|
self.creator = club.creator |
||||||
|
self.name = club.name |
||||||
|
self.acronym = club.acronym |
||||||
|
self.phone = club.phone |
||||||
|
self.code = club.code |
||||||
|
self.address = club.address |
||||||
|
self.city = club.city |
||||||
|
self.zipCode = club.zipCode |
||||||
|
self.latitude = club.latitude |
||||||
|
self.longitude = club.longitude |
||||||
|
self.courtCount = club.courtCount |
||||||
|
self.broadcastCode = club.broadcastCode |
||||||
|
self.timezone = club.timezone |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: CustomUser.self, keyPath: \BaseClub.creator), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,89 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseCourt: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "courts" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var index: Int = 0 |
||||||
|
var club: String = "" |
||||||
|
var name: String? = nil |
||||||
|
var exitAllowed: Bool = false |
||||||
|
var indoor: Bool = false |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
index: Int = 0, |
||||||
|
club: String = "", |
||||||
|
name: String? = nil, |
||||||
|
exitAllowed: Bool = false, |
||||||
|
indoor: Bool = false |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.index = index |
||||||
|
self.club = club |
||||||
|
self.name = name |
||||||
|
self.exitAllowed = exitAllowed |
||||||
|
self.indoor = indoor |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _index = "index" |
||||||
|
case _club = "club" |
||||||
|
case _name = "name" |
||||||
|
case _exitAllowed = "exitAllowed" |
||||||
|
case _indoor = "indoor" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.index = try container.decodeIfPresent(Int.self, forKey: ._index) ?? 0 |
||||||
|
self.club = try container.decodeIfPresent(String.self, forKey: ._club) ?? "" |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil |
||||||
|
self.exitAllowed = try container.decodeIfPresent(Bool.self, forKey: ._exitAllowed) ?? false |
||||||
|
self.indoor = try container.decodeIfPresent(Bool.self, forKey: ._indoor) ?? false |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.index, forKey: ._index) |
||||||
|
try container.encode(self.club, forKey: ._club) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.exitAllowed, forKey: ._exitAllowed) |
||||||
|
try container.encode(self.indoor, forKey: ._indoor) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func clubValue() -> Club? { |
||||||
|
return Store.main.findById(club) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let court = other as? BaseCourt else { return } |
||||||
|
self.id = court.id |
||||||
|
self.index = court.index |
||||||
|
self.club = court.club |
||||||
|
self.name = court.name |
||||||
|
self.exitAllowed = court.exitAllowed |
||||||
|
self.indoor = court.indoor |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Club.self, keyPath: \BaseCourt.club), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,202 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseCustomUser: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "users" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var username: String = "" |
||||||
|
var email: String = "" |
||||||
|
var clubs: [String] = [] |
||||||
|
var umpireCode: String? = nil |
||||||
|
var licenceId: String? = nil |
||||||
|
var firstName: String = "" |
||||||
|
var lastName: String = "" |
||||||
|
var phone: String? = nil |
||||||
|
var country: String? = nil |
||||||
|
var summonsMessageBody: String? = nil |
||||||
|
var summonsMessageSignature: String? = nil |
||||||
|
var summonsAvailablePaymentMethods: String? = nil |
||||||
|
var summonsDisplayFormat: Bool = false |
||||||
|
var summonsDisplayEntryFee: Bool = false |
||||||
|
var summonsUseFullCustomMessage: Bool = false |
||||||
|
var matchFormatsDefaultDuration: [MatchFormat: Int]? = nil |
||||||
|
var bracketMatchFormatPreference: MatchFormat? = nil |
||||||
|
var groupStageMatchFormatPreference: MatchFormat? = nil |
||||||
|
var loserBracketMatchFormatPreference: MatchFormat? = nil |
||||||
|
var loserBracketMode: LoserBracketMode = .automatic |
||||||
|
var deviceId: String? = nil |
||||||
|
var agents: [String] = [] |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
username: String = "", |
||||||
|
email: String = "", |
||||||
|
clubs: [String] = [], |
||||||
|
umpireCode: String? = nil, |
||||||
|
licenceId: String? = nil, |
||||||
|
firstName: String = "", |
||||||
|
lastName: String = "", |
||||||
|
phone: String? = nil, |
||||||
|
country: String? = nil, |
||||||
|
summonsMessageBody: String? = nil, |
||||||
|
summonsMessageSignature: String? = nil, |
||||||
|
summonsAvailablePaymentMethods: String? = nil, |
||||||
|
summonsDisplayFormat: Bool = false, |
||||||
|
summonsDisplayEntryFee: Bool = false, |
||||||
|
summonsUseFullCustomMessage: Bool = false, |
||||||
|
matchFormatsDefaultDuration: [MatchFormat: Int]? = nil, |
||||||
|
bracketMatchFormatPreference: MatchFormat? = nil, |
||||||
|
groupStageMatchFormatPreference: MatchFormat? = nil, |
||||||
|
loserBracketMatchFormatPreference: MatchFormat? = nil, |
||||||
|
loserBracketMode: LoserBracketMode = .automatic, |
||||||
|
deviceId: String? = nil, |
||||||
|
agents: [String] = [] |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.username = username |
||||||
|
self.email = email |
||||||
|
self.clubs = clubs |
||||||
|
self.umpireCode = umpireCode |
||||||
|
self.licenceId = licenceId |
||||||
|
self.firstName = firstName |
||||||
|
self.lastName = lastName |
||||||
|
self.phone = phone |
||||||
|
self.country = country |
||||||
|
self.summonsMessageBody = summonsMessageBody |
||||||
|
self.summonsMessageSignature = summonsMessageSignature |
||||||
|
self.summonsAvailablePaymentMethods = summonsAvailablePaymentMethods |
||||||
|
self.summonsDisplayFormat = summonsDisplayFormat |
||||||
|
self.summonsDisplayEntryFee = summonsDisplayEntryFee |
||||||
|
self.summonsUseFullCustomMessage = summonsUseFullCustomMessage |
||||||
|
self.matchFormatsDefaultDuration = matchFormatsDefaultDuration |
||||||
|
self.bracketMatchFormatPreference = bracketMatchFormatPreference |
||||||
|
self.groupStageMatchFormatPreference = groupStageMatchFormatPreference |
||||||
|
self.loserBracketMatchFormatPreference = loserBracketMatchFormatPreference |
||||||
|
self.loserBracketMode = loserBracketMode |
||||||
|
self.deviceId = deviceId |
||||||
|
self.agents = agents |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _username = "username" |
||||||
|
case _email = "email" |
||||||
|
case _clubs = "clubs" |
||||||
|
case _umpireCode = "umpireCode" |
||||||
|
case _licenceId = "licenceId" |
||||||
|
case _firstName = "firstName" |
||||||
|
case _lastName = "lastName" |
||||||
|
case _phone = "phone" |
||||||
|
case _country = "country" |
||||||
|
case _summonsMessageBody = "summonsMessageBody" |
||||||
|
case _summonsMessageSignature = "summonsMessageSignature" |
||||||
|
case _summonsAvailablePaymentMethods = "summonsAvailablePaymentMethods" |
||||||
|
case _summonsDisplayFormat = "summonsDisplayFormat" |
||||||
|
case _summonsDisplayEntryFee = "summonsDisplayEntryFee" |
||||||
|
case _summonsUseFullCustomMessage = "summonsUseFullCustomMessage" |
||||||
|
case _matchFormatsDefaultDuration = "matchFormatsDefaultDuration" |
||||||
|
case _bracketMatchFormatPreference = "bracketMatchFormatPreference" |
||||||
|
case _groupStageMatchFormatPreference = "groupStageMatchFormatPreference" |
||||||
|
case _loserBracketMatchFormatPreference = "loserBracketMatchFormatPreference" |
||||||
|
case _loserBracketMode = "loserBracketMode" |
||||||
|
case _deviceId = "deviceId" |
||||||
|
case _agents = "agents" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.username = try container.decodeIfPresent(String.self, forKey: ._username) ?? "" |
||||||
|
self.email = try container.decodeIfPresent(String.self, forKey: ._email) ?? "" |
||||||
|
self.clubs = try container.decodeIfPresent([String].self, forKey: ._clubs) ?? [] |
||||||
|
self.umpireCode = try container.decodeIfPresent(String.self, forKey: ._umpireCode) ?? nil |
||||||
|
self.licenceId = try container.decodeIfPresent(String.self, forKey: ._licenceId) ?? nil |
||||||
|
self.firstName = try container.decodeIfPresent(String.self, forKey: ._firstName) ?? "" |
||||||
|
self.lastName = try container.decodeIfPresent(String.self, forKey: ._lastName) ?? "" |
||||||
|
self.phone = try container.decodeIfPresent(String.self, forKey: ._phone) ?? nil |
||||||
|
self.country = try container.decodeIfPresent(String.self, forKey: ._country) ?? nil |
||||||
|
self.summonsMessageBody = try container.decodeIfPresent(String.self, forKey: ._summonsMessageBody) ?? nil |
||||||
|
self.summonsMessageSignature = try container.decodeIfPresent(String.self, forKey: ._summonsMessageSignature) ?? nil |
||||||
|
self.summonsAvailablePaymentMethods = try container.decodeIfPresent(String.self, forKey: ._summonsAvailablePaymentMethods) ?? nil |
||||||
|
self.summonsDisplayFormat = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayFormat) ?? false |
||||||
|
self.summonsDisplayEntryFee = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayEntryFee) ?? false |
||||||
|
self.summonsUseFullCustomMessage = try container.decodeIfPresent(Bool.self, forKey: ._summonsUseFullCustomMessage) ?? false |
||||||
|
self.matchFormatsDefaultDuration = try container.decodeIfPresent([MatchFormat: Int].self, forKey: ._matchFormatsDefaultDuration) ?? nil |
||||||
|
self.bracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._bracketMatchFormatPreference) ?? nil |
||||||
|
self.groupStageMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._groupStageMatchFormatPreference) ?? nil |
||||||
|
self.loserBracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._loserBracketMatchFormatPreference) ?? nil |
||||||
|
self.loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic |
||||||
|
self.deviceId = try container.decodeIfPresent(String.self, forKey: ._deviceId) ?? nil |
||||||
|
self.agents = try container.decodeIfPresent([String].self, forKey: ._agents) ?? [] |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.username, forKey: ._username) |
||||||
|
try container.encode(self.email, forKey: ._email) |
||||||
|
try container.encode(self.clubs, forKey: ._clubs) |
||||||
|
try container.encode(self.umpireCode, forKey: ._umpireCode) |
||||||
|
try container.encode(self.licenceId, forKey: ._licenceId) |
||||||
|
try container.encode(self.firstName, forKey: ._firstName) |
||||||
|
try container.encode(self.lastName, forKey: ._lastName) |
||||||
|
try container.encode(self.phone, forKey: ._phone) |
||||||
|
try container.encode(self.country, forKey: ._country) |
||||||
|
try container.encode(self.summonsMessageBody, forKey: ._summonsMessageBody) |
||||||
|
try container.encode(self.summonsMessageSignature, forKey: ._summonsMessageSignature) |
||||||
|
try container.encode(self.summonsAvailablePaymentMethods, forKey: ._summonsAvailablePaymentMethods) |
||||||
|
try container.encode(self.summonsDisplayFormat, forKey: ._summonsDisplayFormat) |
||||||
|
try container.encode(self.summonsDisplayEntryFee, forKey: ._summonsDisplayEntryFee) |
||||||
|
try container.encode(self.summonsUseFullCustomMessage, forKey: ._summonsUseFullCustomMessage) |
||||||
|
try container.encode(self.matchFormatsDefaultDuration, forKey: ._matchFormatsDefaultDuration) |
||||||
|
try container.encode(self.bracketMatchFormatPreference, forKey: ._bracketMatchFormatPreference) |
||||||
|
try container.encode(self.groupStageMatchFormatPreference, forKey: ._groupStageMatchFormatPreference) |
||||||
|
try container.encode(self.loserBracketMatchFormatPreference, forKey: ._loserBracketMatchFormatPreference) |
||||||
|
try container.encode(self.loserBracketMode, forKey: ._loserBracketMode) |
||||||
|
try container.encode(self.deviceId, forKey: ._deviceId) |
||||||
|
try container.encode(self.agents, forKey: ._agents) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let customuser = other as? BaseCustomUser else { return } |
||||||
|
self.id = customuser.id |
||||||
|
self.username = customuser.username |
||||||
|
self.email = customuser.email |
||||||
|
self.clubs = customuser.clubs |
||||||
|
self.umpireCode = customuser.umpireCode |
||||||
|
self.licenceId = customuser.licenceId |
||||||
|
self.firstName = customuser.firstName |
||||||
|
self.lastName = customuser.lastName |
||||||
|
self.phone = customuser.phone |
||||||
|
self.country = customuser.country |
||||||
|
self.summonsMessageBody = customuser.summonsMessageBody |
||||||
|
self.summonsMessageSignature = customuser.summonsMessageSignature |
||||||
|
self.summonsAvailablePaymentMethods = customuser.summonsAvailablePaymentMethods |
||||||
|
self.summonsDisplayFormat = customuser.summonsDisplayFormat |
||||||
|
self.summonsDisplayEntryFee = customuser.summonsDisplayEntryFee |
||||||
|
self.summonsUseFullCustomMessage = customuser.summonsUseFullCustomMessage |
||||||
|
self.matchFormatsDefaultDuration = customuser.matchFormatsDefaultDuration |
||||||
|
self.bracketMatchFormatPreference = customuser.bracketMatchFormatPreference |
||||||
|
self.groupStageMatchFormatPreference = customuser.groupStageMatchFormatPreference |
||||||
|
self.loserBracketMatchFormatPreference = customuser.loserBracketMatchFormatPreference |
||||||
|
self.loserBracketMode = customuser.loserBracketMode |
||||||
|
self.deviceId = customuser.deviceId |
||||||
|
self.agents = customuser.agents |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,76 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseDateInterval: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "date-intervals" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var event: String = "" |
||||||
|
var courtIndex: Int = 0 |
||||||
|
var startDate: Date = Date() |
||||||
|
var endDate: Date = Date() |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
event: String = "", |
||||||
|
courtIndex: Int = 0, |
||||||
|
startDate: Date = Date(), |
||||||
|
endDate: Date = Date() |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.event = event |
||||||
|
self.courtIndex = courtIndex |
||||||
|
self.startDate = startDate |
||||||
|
self.endDate = endDate |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _event = "event" |
||||||
|
case _courtIndex = "courtIndex" |
||||||
|
case _startDate = "startDate" |
||||||
|
case _endDate = "endDate" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.event = try container.decodeIfPresent(String.self, forKey: ._event) ?? "" |
||||||
|
self.courtIndex = try container.decodeIfPresent(Int.self, forKey: ._courtIndex) ?? 0 |
||||||
|
self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? Date() |
||||||
|
self.endDate = try container.decodeIfPresent(Date.self, forKey: ._endDate) ?? Date() |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.event, forKey: ._event) |
||||||
|
try container.encode(self.courtIndex, forKey: ._courtIndex) |
||||||
|
try container.encode(self.startDate, forKey: ._startDate) |
||||||
|
try container.encode(self.endDate, forKey: ._endDate) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let dateinterval = other as? BaseDateInterval else { return } |
||||||
|
self.id = dateinterval.id |
||||||
|
self.event = dateinterval.event |
||||||
|
self.courtIndex = dateinterval.courtIndex |
||||||
|
self.startDate = dateinterval.startDate |
||||||
|
self.endDate = dateinterval.endDate |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,96 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseDrawLog: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "draw-logs" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var tournament: String = "" |
||||||
|
var drawDate: Date = Date() |
||||||
|
var drawSeed: Int = 0 |
||||||
|
var drawMatchIndex: Int = 0 |
||||||
|
var drawTeamPosition: TeamPosition = TeamPosition.one |
||||||
|
var drawType: DrawType = DrawType.seed |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
tournament: String = "", |
||||||
|
drawDate: Date = Date(), |
||||||
|
drawSeed: Int = 0, |
||||||
|
drawMatchIndex: Int = 0, |
||||||
|
drawTeamPosition: TeamPosition = TeamPosition.one, |
||||||
|
drawType: DrawType = DrawType.seed |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.tournament = tournament |
||||||
|
self.drawDate = drawDate |
||||||
|
self.drawSeed = drawSeed |
||||||
|
self.drawMatchIndex = drawMatchIndex |
||||||
|
self.drawTeamPosition = drawTeamPosition |
||||||
|
self.drawType = drawType |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _tournament = "tournament" |
||||||
|
case _drawDate = "drawDate" |
||||||
|
case _drawSeed = "drawSeed" |
||||||
|
case _drawMatchIndex = "drawMatchIndex" |
||||||
|
case _drawTeamPosition = "drawTeamPosition" |
||||||
|
case _drawType = "drawType" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.tournament = try container.decodeIfPresent(String.self, forKey: ._tournament) ?? "" |
||||||
|
self.drawDate = try container.decodeIfPresent(Date.self, forKey: ._drawDate) ?? Date() |
||||||
|
self.drawSeed = try container.decodeIfPresent(Int.self, forKey: ._drawSeed) ?? 0 |
||||||
|
self.drawMatchIndex = try container.decodeIfPresent(Int.self, forKey: ._drawMatchIndex) ?? 0 |
||||||
|
self.drawTeamPosition = try container.decodeIfPresent(TeamPosition.self, forKey: ._drawTeamPosition) ?? TeamPosition.one |
||||||
|
self.drawType = try container.decodeIfPresent(DrawType.self, forKey: ._drawType) ?? DrawType.seed |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.tournament, forKey: ._tournament) |
||||||
|
try container.encode(self.drawDate, forKey: ._drawDate) |
||||||
|
try container.encode(self.drawSeed, forKey: ._drawSeed) |
||||||
|
try container.encode(self.drawMatchIndex, forKey: ._drawMatchIndex) |
||||||
|
try container.encode(self.drawTeamPosition, forKey: ._drawTeamPosition) |
||||||
|
try container.encode(self.drawType, forKey: ._drawType) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func tournamentValue() -> Tournament? { |
||||||
|
return Store.main.findById(tournament) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let drawlog = other as? BaseDrawLog else { return } |
||||||
|
self.id = drawlog.id |
||||||
|
self.tournament = drawlog.tournament |
||||||
|
self.drawDate = drawlog.drawDate |
||||||
|
self.drawSeed = drawlog.drawSeed |
||||||
|
self.drawMatchIndex = drawlog.drawMatchIndex |
||||||
|
self.drawTeamPosition = drawlog.drawTeamPosition |
||||||
|
self.drawType = drawlog.drawType |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Tournament.self, keyPath: \BaseDrawLog.tournament), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,96 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseEvent: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "events" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var creator: String? = nil |
||||||
|
var club: String? = nil |
||||||
|
var creationDate: Date = Date() |
||||||
|
var name: String? = nil |
||||||
|
var tenupId: String? = nil |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
creator: String? = nil, |
||||||
|
club: String? = nil, |
||||||
|
creationDate: Date = Date(), |
||||||
|
name: String? = nil, |
||||||
|
tenupId: String? = nil |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.creator = creator |
||||||
|
self.club = club |
||||||
|
self.creationDate = creationDate |
||||||
|
self.name = name |
||||||
|
self.tenupId = tenupId |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _creator = "creator" |
||||||
|
case _club = "club" |
||||||
|
case _creationDate = "creationDate" |
||||||
|
case _name = "name" |
||||||
|
case _tenupId = "tenupId" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.creator = try container.decodeIfPresent(String.self, forKey: ._creator) ?? nil |
||||||
|
self.club = try container.decodeIfPresent(String.self, forKey: ._club) ?? nil |
||||||
|
self.creationDate = try container.decodeIfPresent(Date.self, forKey: ._creationDate) ?? Date() |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil |
||||||
|
self.tenupId = try container.decodeIfPresent(String.self, forKey: ._tenupId) ?? nil |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.creator, forKey: ._creator) |
||||||
|
try container.encode(self.club, forKey: ._club) |
||||||
|
try container.encode(self.creationDate, forKey: ._creationDate) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.tenupId, forKey: ._tenupId) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func creatorValue() -> CustomUser? { |
||||||
|
guard let creator = self.creator else { return nil } |
||||||
|
return Store.main.findById(creator) |
||||||
|
} |
||||||
|
|
||||||
|
func clubValue() -> Club? { |
||||||
|
guard let club = self.club else { return nil } |
||||||
|
return Store.main.findById(club) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let event = other as? BaseEvent else { return } |
||||||
|
self.id = event.id |
||||||
|
self.creator = event.creator |
||||||
|
self.club = event.club |
||||||
|
self.creationDate = event.creationDate |
||||||
|
self.name = event.name |
||||||
|
self.tenupId = event.tenupId |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: CustomUser.self, keyPath: \BaseEvent.creator), |
||||||
|
Relationship(type: Club.self, keyPath: \BaseEvent.club), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,103 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseGroupStage: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "group-stages" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var tournament: String = "" |
||||||
|
var index: Int = 0 |
||||||
|
var size: Int = 0 |
||||||
|
var format: MatchFormat? = nil |
||||||
|
var startDate: Date? = nil |
||||||
|
var name: String? = nil |
||||||
|
var step: Int = 0 |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
tournament: String = "", |
||||||
|
index: Int = 0, |
||||||
|
size: Int = 0, |
||||||
|
format: MatchFormat? = nil, |
||||||
|
startDate: Date? = nil, |
||||||
|
name: String? = nil, |
||||||
|
step: Int = 0 |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.tournament = tournament |
||||||
|
self.index = index |
||||||
|
self.size = size |
||||||
|
self.format = format |
||||||
|
self.startDate = startDate |
||||||
|
self.name = name |
||||||
|
self.step = step |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _tournament = "tournament" |
||||||
|
case _index = "index" |
||||||
|
case _size = "size" |
||||||
|
case _format = "format" |
||||||
|
case _startDate = "startDate" |
||||||
|
case _name = "name" |
||||||
|
case _step = "step" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.tournament = try container.decodeIfPresent(String.self, forKey: ._tournament) ?? "" |
||||||
|
self.index = try container.decodeIfPresent(Int.self, forKey: ._index) ?? 0 |
||||||
|
self.size = try container.decodeIfPresent(Int.self, forKey: ._size) ?? 0 |
||||||
|
self.format = try container.decodeIfPresent(MatchFormat.self, forKey: ._format) ?? nil |
||||||
|
self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? nil |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil |
||||||
|
self.step = try container.decodeIfPresent(Int.self, forKey: ._step) ?? 0 |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.tournament, forKey: ._tournament) |
||||||
|
try container.encode(self.index, forKey: ._index) |
||||||
|
try container.encode(self.size, forKey: ._size) |
||||||
|
try container.encode(self.format, forKey: ._format) |
||||||
|
try container.encode(self.startDate, forKey: ._startDate) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.step, forKey: ._step) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func tournamentValue() -> Tournament? { |
||||||
|
return Store.main.findById(tournament) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let groupstage = other as? BaseGroupStage else { return } |
||||||
|
self.id = groupstage.id |
||||||
|
self.tournament = groupstage.tournament |
||||||
|
self.index = groupstage.index |
||||||
|
self.size = groupstage.size |
||||||
|
self.format = groupstage.format |
||||||
|
self.startDate = groupstage.startDate |
||||||
|
self.name = groupstage.name |
||||||
|
self.step = groupstage.step |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Tournament.self, keyPath: \BaseGroupStage.tournament), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,152 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseMatch: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "matches" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var round: String? = nil |
||||||
|
var groupStage: String? = nil |
||||||
|
var startDate: Date? = nil |
||||||
|
var endDate: Date? = nil |
||||||
|
var index: Int = 0 |
||||||
|
var format: MatchFormat? = nil |
||||||
|
var servingTeamId: String? = nil |
||||||
|
var winningTeamId: String? = nil |
||||||
|
var losingTeamId: String? = nil |
||||||
|
var name: String? = nil |
||||||
|
var disabled: Bool = false |
||||||
|
var courtIndex: Int? = nil |
||||||
|
var confirmed: Bool = false |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
round: String? = nil, |
||||||
|
groupStage: String? = nil, |
||||||
|
startDate: Date? = nil, |
||||||
|
endDate: Date? = nil, |
||||||
|
index: Int = 0, |
||||||
|
format: MatchFormat? = nil, |
||||||
|
servingTeamId: String? = nil, |
||||||
|
winningTeamId: String? = nil, |
||||||
|
losingTeamId: String? = nil, |
||||||
|
name: String? = nil, |
||||||
|
disabled: Bool = false, |
||||||
|
courtIndex: Int? = nil, |
||||||
|
confirmed: Bool = false |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.round = round |
||||||
|
self.groupStage = groupStage |
||||||
|
self.startDate = startDate |
||||||
|
self.endDate = endDate |
||||||
|
self.index = index |
||||||
|
self.format = format |
||||||
|
self.servingTeamId = servingTeamId |
||||||
|
self.winningTeamId = winningTeamId |
||||||
|
self.losingTeamId = losingTeamId |
||||||
|
self.name = name |
||||||
|
self.disabled = disabled |
||||||
|
self.courtIndex = courtIndex |
||||||
|
self.confirmed = confirmed |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _round = "round" |
||||||
|
case _groupStage = "groupStage" |
||||||
|
case _startDate = "startDate" |
||||||
|
case _endDate = "endDate" |
||||||
|
case _index = "index" |
||||||
|
case _format = "format" |
||||||
|
case _servingTeamId = "servingTeamId" |
||||||
|
case _winningTeamId = "winningTeamId" |
||||||
|
case _losingTeamId = "losingTeamId" |
||||||
|
case _name = "name" |
||||||
|
case _disabled = "disabled" |
||||||
|
case _courtIndex = "courtIndex" |
||||||
|
case _confirmed = "confirmed" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.round = try container.decodeIfPresent(String.self, forKey: ._round) ?? nil |
||||||
|
self.groupStage = try container.decodeIfPresent(String.self, forKey: ._groupStage) ?? nil |
||||||
|
self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? nil |
||||||
|
self.endDate = try container.decodeIfPresent(Date.self, forKey: ._endDate) ?? nil |
||||||
|
self.index = try container.decodeIfPresent(Int.self, forKey: ._index) ?? 0 |
||||||
|
self.format = try container.decodeIfPresent(MatchFormat.self, forKey: ._format) ?? nil |
||||||
|
self.servingTeamId = try container.decodeIfPresent(String.self, forKey: ._servingTeamId) ?? nil |
||||||
|
self.winningTeamId = try container.decodeIfPresent(String.self, forKey: ._winningTeamId) ?? nil |
||||||
|
self.losingTeamId = try container.decodeIfPresent(String.self, forKey: ._losingTeamId) ?? nil |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil |
||||||
|
self.disabled = try container.decodeIfPresent(Bool.self, forKey: ._disabled) ?? false |
||||||
|
self.courtIndex = try container.decodeIfPresent(Int.self, forKey: ._courtIndex) ?? nil |
||||||
|
self.confirmed = try container.decodeIfPresent(Bool.self, forKey: ._confirmed) ?? false |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.round, forKey: ._round) |
||||||
|
try container.encode(self.groupStage, forKey: ._groupStage) |
||||||
|
try container.encode(self.startDate, forKey: ._startDate) |
||||||
|
try container.encode(self.endDate, forKey: ._endDate) |
||||||
|
try container.encode(self.index, forKey: ._index) |
||||||
|
try container.encode(self.format, forKey: ._format) |
||||||
|
try container.encode(self.servingTeamId, forKey: ._servingTeamId) |
||||||
|
try container.encode(self.winningTeamId, forKey: ._winningTeamId) |
||||||
|
try container.encode(self.losingTeamId, forKey: ._losingTeamId) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.disabled, forKey: ._disabled) |
||||||
|
try container.encode(self.courtIndex, forKey: ._courtIndex) |
||||||
|
try container.encode(self.confirmed, forKey: ._confirmed) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func roundValue() -> Round? { |
||||||
|
guard let round = self.round else { return nil } |
||||||
|
return self.store?.findById(round) |
||||||
|
} |
||||||
|
|
||||||
|
func groupStageValue() -> GroupStage? { |
||||||
|
guard let groupStage = self.groupStage else { return nil } |
||||||
|
return self.store?.findById(groupStage) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let match = other as? BaseMatch else { return } |
||||||
|
self.id = match.id |
||||||
|
self.round = match.round |
||||||
|
self.groupStage = match.groupStage |
||||||
|
self.startDate = match.startDate |
||||||
|
self.endDate = match.endDate |
||||||
|
self.index = match.index |
||||||
|
self.format = match.format |
||||||
|
self.servingTeamId = match.servingTeamId |
||||||
|
self.winningTeamId = match.winningTeamId |
||||||
|
self.losingTeamId = match.losingTeamId |
||||||
|
self.name = match.name |
||||||
|
self.disabled = match.disabled |
||||||
|
self.courtIndex = match.courtIndex |
||||||
|
self.confirmed = match.confirmed |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Round.self, keyPath: \BaseMatch.round), |
||||||
|
Relationship(type: GroupStage.self, keyPath: \BaseMatch.groupStage), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,159 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseMatchScheduler: BaseModelObject, Storable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "match-scheduler" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var tournament: String = "" |
||||||
|
var timeDifferenceLimit: Int = 0 |
||||||
|
var loserBracketRotationDifference: Int = 0 |
||||||
|
var upperBracketRotationDifference: Int = 0 |
||||||
|
var accountUpperBracketBreakTime: Bool = false |
||||||
|
var accountLoserBracketBreakTime: Bool = false |
||||||
|
var randomizeCourts: Bool = false |
||||||
|
var rotationDifferenceIsImportant: Bool = false |
||||||
|
var shouldHandleUpperRoundSlice: Bool = false |
||||||
|
var shouldEndRoundBeforeStartingNext: Bool = false |
||||||
|
var groupStageChunkCount: Int? = nil |
||||||
|
var overrideCourtsUnavailability: Bool = false |
||||||
|
var shouldTryToFillUpCourtsAvailable: Bool = false |
||||||
|
var courtsAvailable: Set<Int> = Set<Int>() |
||||||
|
var simultaneousStart: Bool = true |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
tournament: String = "", |
||||||
|
timeDifferenceLimit: Int = 0, |
||||||
|
loserBracketRotationDifference: Int = 0, |
||||||
|
upperBracketRotationDifference: Int = 0, |
||||||
|
accountUpperBracketBreakTime: Bool = false, |
||||||
|
accountLoserBracketBreakTime: Bool = false, |
||||||
|
randomizeCourts: Bool = false, |
||||||
|
rotationDifferenceIsImportant: Bool = false, |
||||||
|
shouldHandleUpperRoundSlice: Bool = false, |
||||||
|
shouldEndRoundBeforeStartingNext: Bool = false, |
||||||
|
groupStageChunkCount: Int? = nil, |
||||||
|
overrideCourtsUnavailability: Bool = false, |
||||||
|
shouldTryToFillUpCourtsAvailable: Bool = false, |
||||||
|
courtsAvailable: Set<Int> = Set<Int>(), |
||||||
|
simultaneousStart: Bool = true |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.tournament = tournament |
||||||
|
self.timeDifferenceLimit = timeDifferenceLimit |
||||||
|
self.loserBracketRotationDifference = loserBracketRotationDifference |
||||||
|
self.upperBracketRotationDifference = upperBracketRotationDifference |
||||||
|
self.accountUpperBracketBreakTime = accountUpperBracketBreakTime |
||||||
|
self.accountLoserBracketBreakTime = accountLoserBracketBreakTime |
||||||
|
self.randomizeCourts = randomizeCourts |
||||||
|
self.rotationDifferenceIsImportant = rotationDifferenceIsImportant |
||||||
|
self.shouldHandleUpperRoundSlice = shouldHandleUpperRoundSlice |
||||||
|
self.shouldEndRoundBeforeStartingNext = shouldEndRoundBeforeStartingNext |
||||||
|
self.groupStageChunkCount = groupStageChunkCount |
||||||
|
self.overrideCourtsUnavailability = overrideCourtsUnavailability |
||||||
|
self.shouldTryToFillUpCourtsAvailable = shouldTryToFillUpCourtsAvailable |
||||||
|
self.courtsAvailable = courtsAvailable |
||||||
|
self.simultaneousStart = simultaneousStart |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _tournament = "tournament" |
||||||
|
case _timeDifferenceLimit = "timeDifferenceLimit" |
||||||
|
case _loserBracketRotationDifference = "loserBracketRotationDifference" |
||||||
|
case _upperBracketRotationDifference = "upperBracketRotationDifference" |
||||||
|
case _accountUpperBracketBreakTime = "accountUpperBracketBreakTime" |
||||||
|
case _accountLoserBracketBreakTime = "accountLoserBracketBreakTime" |
||||||
|
case _randomizeCourts = "randomizeCourts" |
||||||
|
case _rotationDifferenceIsImportant = "rotationDifferenceIsImportant" |
||||||
|
case _shouldHandleUpperRoundSlice = "shouldHandleUpperRoundSlice" |
||||||
|
case _shouldEndRoundBeforeStartingNext = "shouldEndRoundBeforeStartingNext" |
||||||
|
case _groupStageChunkCount = "groupStageChunkCount" |
||||||
|
case _overrideCourtsUnavailability = "overrideCourtsUnavailability" |
||||||
|
case _shouldTryToFillUpCourtsAvailable = "shouldTryToFillUpCourtsAvailable" |
||||||
|
case _courtsAvailable = "courtsAvailable" |
||||||
|
case _simultaneousStart = "simultaneousStart" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.tournament = try container.decodeIfPresent(String.self, forKey: ._tournament) ?? "" |
||||||
|
self.timeDifferenceLimit = try container.decodeIfPresent(Int.self, forKey: ._timeDifferenceLimit) ?? 0 |
||||||
|
self.loserBracketRotationDifference = try container.decodeIfPresent(Int.self, forKey: ._loserBracketRotationDifference) ?? 0 |
||||||
|
self.upperBracketRotationDifference = try container.decodeIfPresent(Int.self, forKey: ._upperBracketRotationDifference) ?? 0 |
||||||
|
self.accountUpperBracketBreakTime = try container.decodeIfPresent(Bool.self, forKey: ._accountUpperBracketBreakTime) ?? false |
||||||
|
self.accountLoserBracketBreakTime = try container.decodeIfPresent(Bool.self, forKey: ._accountLoserBracketBreakTime) ?? false |
||||||
|
self.randomizeCourts = try container.decodeIfPresent(Bool.self, forKey: ._randomizeCourts) ?? false |
||||||
|
self.rotationDifferenceIsImportant = try container.decodeIfPresent(Bool.self, forKey: ._rotationDifferenceIsImportant) ?? false |
||||||
|
self.shouldHandleUpperRoundSlice = try container.decodeIfPresent(Bool.self, forKey: ._shouldHandleUpperRoundSlice) ?? false |
||||||
|
self.shouldEndRoundBeforeStartingNext = try container.decodeIfPresent(Bool.self, forKey: ._shouldEndRoundBeforeStartingNext) ?? false |
||||||
|
self.groupStageChunkCount = try container.decodeIfPresent(Int.self, forKey: ._groupStageChunkCount) ?? nil |
||||||
|
self.overrideCourtsUnavailability = try container.decodeIfPresent(Bool.self, forKey: ._overrideCourtsUnavailability) ?? false |
||||||
|
self.shouldTryToFillUpCourtsAvailable = try container.decodeIfPresent(Bool.self, forKey: ._shouldTryToFillUpCourtsAvailable) ?? false |
||||||
|
self.courtsAvailable = try container.decodeIfPresent(Set<Int>.self, forKey: ._courtsAvailable) ?? Set<Int>() |
||||||
|
self.simultaneousStart = try container.decodeIfPresent(Bool.self, forKey: ._simultaneousStart) ?? true |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.tournament, forKey: ._tournament) |
||||||
|
try container.encode(self.timeDifferenceLimit, forKey: ._timeDifferenceLimit) |
||||||
|
try container.encode(self.loserBracketRotationDifference, forKey: ._loserBracketRotationDifference) |
||||||
|
try container.encode(self.upperBracketRotationDifference, forKey: ._upperBracketRotationDifference) |
||||||
|
try container.encode(self.accountUpperBracketBreakTime, forKey: ._accountUpperBracketBreakTime) |
||||||
|
try container.encode(self.accountLoserBracketBreakTime, forKey: ._accountLoserBracketBreakTime) |
||||||
|
try container.encode(self.randomizeCourts, forKey: ._randomizeCourts) |
||||||
|
try container.encode(self.rotationDifferenceIsImportant, forKey: ._rotationDifferenceIsImportant) |
||||||
|
try container.encode(self.shouldHandleUpperRoundSlice, forKey: ._shouldHandleUpperRoundSlice) |
||||||
|
try container.encode(self.shouldEndRoundBeforeStartingNext, forKey: ._shouldEndRoundBeforeStartingNext) |
||||||
|
try container.encode(self.groupStageChunkCount, forKey: ._groupStageChunkCount) |
||||||
|
try container.encode(self.overrideCourtsUnavailability, forKey: ._overrideCourtsUnavailability) |
||||||
|
try container.encode(self.shouldTryToFillUpCourtsAvailable, forKey: ._shouldTryToFillUpCourtsAvailable) |
||||||
|
try container.encode(self.courtsAvailable, forKey: ._courtsAvailable) |
||||||
|
try container.encode(self.simultaneousStart, forKey: ._simultaneousStart) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func tournamentValue() -> Tournament? { |
||||||
|
return Store.main.findById(tournament) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let matchscheduler = other as? BaseMatchScheduler else { return } |
||||||
|
self.id = matchscheduler.id |
||||||
|
self.tournament = matchscheduler.tournament |
||||||
|
self.timeDifferenceLimit = matchscheduler.timeDifferenceLimit |
||||||
|
self.loserBracketRotationDifference = matchscheduler.loserBracketRotationDifference |
||||||
|
self.upperBracketRotationDifference = matchscheduler.upperBracketRotationDifference |
||||||
|
self.accountUpperBracketBreakTime = matchscheduler.accountUpperBracketBreakTime |
||||||
|
self.accountLoserBracketBreakTime = matchscheduler.accountLoserBracketBreakTime |
||||||
|
self.randomizeCourts = matchscheduler.randomizeCourts |
||||||
|
self.rotationDifferenceIsImportant = matchscheduler.rotationDifferenceIsImportant |
||||||
|
self.shouldHandleUpperRoundSlice = matchscheduler.shouldHandleUpperRoundSlice |
||||||
|
self.shouldEndRoundBeforeStartingNext = matchscheduler.shouldEndRoundBeforeStartingNext |
||||||
|
self.groupStageChunkCount = matchscheduler.groupStageChunkCount |
||||||
|
self.overrideCourtsUnavailability = matchscheduler.overrideCourtsUnavailability |
||||||
|
self.shouldTryToFillUpCourtsAvailable = matchscheduler.shouldTryToFillUpCourtsAvailable |
||||||
|
self.courtsAvailable = matchscheduler.courtsAvailable |
||||||
|
self.simultaneousStart = matchscheduler.simultaneousStart |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Tournament.self, keyPath: \BaseMatchScheduler.tournament), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,118 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseMonthData: BaseModelObject, Storable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "month-data" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var monthKey: String = "" |
||||||
|
var creationDate: Date = Date() |
||||||
|
var maleUnrankedValue: Int? = nil |
||||||
|
var femaleUnrankedValue: Int? = nil |
||||||
|
var maleCount: Int? = nil |
||||||
|
var femaleCount: Int? = nil |
||||||
|
var anonymousCount: Int? = nil |
||||||
|
var incompleteMode: Bool = false |
||||||
|
var dataModelIdentifier: String? = nil |
||||||
|
var fileModelIdentifier: String? = nil |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
monthKey: String = "", |
||||||
|
creationDate: Date = Date(), |
||||||
|
maleUnrankedValue: Int? = nil, |
||||||
|
femaleUnrankedValue: Int? = nil, |
||||||
|
maleCount: Int? = nil, |
||||||
|
femaleCount: Int? = nil, |
||||||
|
anonymousCount: Int? = nil, |
||||||
|
incompleteMode: Bool = false, |
||||||
|
dataModelIdentifier: String? = nil, |
||||||
|
fileModelIdentifier: String? = nil |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.monthKey = monthKey |
||||||
|
self.creationDate = creationDate |
||||||
|
self.maleUnrankedValue = maleUnrankedValue |
||||||
|
self.femaleUnrankedValue = femaleUnrankedValue |
||||||
|
self.maleCount = maleCount |
||||||
|
self.femaleCount = femaleCount |
||||||
|
self.anonymousCount = anonymousCount |
||||||
|
self.incompleteMode = incompleteMode |
||||||
|
self.dataModelIdentifier = dataModelIdentifier |
||||||
|
self.fileModelIdentifier = fileModelIdentifier |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _monthKey = "monthKey" |
||||||
|
case _creationDate = "creationDate" |
||||||
|
case _maleUnrankedValue = "maleUnrankedValue" |
||||||
|
case _femaleUnrankedValue = "femaleUnrankedValue" |
||||||
|
case _maleCount = "maleCount" |
||||||
|
case _femaleCount = "femaleCount" |
||||||
|
case _anonymousCount = "anonymousCount" |
||||||
|
case _incompleteMode = "incompleteMode" |
||||||
|
case _dataModelIdentifier = "dataModelIdentifier" |
||||||
|
case _fileModelIdentifier = "fileModelIdentifier" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.monthKey = try container.decodeIfPresent(String.self, forKey: ._monthKey) ?? "" |
||||||
|
self.creationDate = try container.decodeIfPresent(Date.self, forKey: ._creationDate) ?? Date() |
||||||
|
self.maleUnrankedValue = try container.decodeIfPresent(Int.self, forKey: ._maleUnrankedValue) ?? nil |
||||||
|
self.femaleUnrankedValue = try container.decodeIfPresent(Int.self, forKey: ._femaleUnrankedValue) ?? nil |
||||||
|
self.maleCount = try container.decodeIfPresent(Int.self, forKey: ._maleCount) ?? nil |
||||||
|
self.femaleCount = try container.decodeIfPresent(Int.self, forKey: ._femaleCount) ?? nil |
||||||
|
self.anonymousCount = try container.decodeIfPresent(Int.self, forKey: ._anonymousCount) ?? nil |
||||||
|
self.incompleteMode = try container.decodeIfPresent(Bool.self, forKey: ._incompleteMode) ?? false |
||||||
|
self.dataModelIdentifier = try container.decodeIfPresent(String.self, forKey: ._dataModelIdentifier) ?? nil |
||||||
|
self.fileModelIdentifier = try container.decodeIfPresent(String.self, forKey: ._fileModelIdentifier) ?? nil |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.monthKey, forKey: ._monthKey) |
||||||
|
try container.encode(self.creationDate, forKey: ._creationDate) |
||||||
|
try container.encode(self.maleUnrankedValue, forKey: ._maleUnrankedValue) |
||||||
|
try container.encode(self.femaleUnrankedValue, forKey: ._femaleUnrankedValue) |
||||||
|
try container.encode(self.maleCount, forKey: ._maleCount) |
||||||
|
try container.encode(self.femaleCount, forKey: ._femaleCount) |
||||||
|
try container.encode(self.anonymousCount, forKey: ._anonymousCount) |
||||||
|
try container.encode(self.incompleteMode, forKey: ._incompleteMode) |
||||||
|
try container.encode(self.dataModelIdentifier, forKey: ._dataModelIdentifier) |
||||||
|
try container.encode(self.fileModelIdentifier, forKey: ._fileModelIdentifier) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let monthdata = other as? BaseMonthData else { return } |
||||||
|
self.id = monthdata.id |
||||||
|
self.monthKey = monthdata.monthKey |
||||||
|
self.creationDate = monthdata.creationDate |
||||||
|
self.maleUnrankedValue = monthdata.maleUnrankedValue |
||||||
|
self.femaleUnrankedValue = monthdata.femaleUnrankedValue |
||||||
|
self.maleCount = monthdata.maleCount |
||||||
|
self.femaleCount = monthdata.femaleCount |
||||||
|
self.anonymousCount = monthdata.anonymousCount |
||||||
|
self.incompleteMode = monthdata.incompleteMode |
||||||
|
self.dataModelIdentifier = monthdata.dataModelIdentifier |
||||||
|
self.fileModelIdentifier = monthdata.fileModelIdentifier |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,202 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BasePlayerRegistration: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "player-registrations" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var teamRegistration: String? = nil |
||||||
|
var firstName: String = "" |
||||||
|
var lastName: String = "" |
||||||
|
var licenceId: String? = nil |
||||||
|
var rank: Int? = nil |
||||||
|
var paymentType: PlayerPaymentType? = nil |
||||||
|
var sex: PlayerSexType? = nil |
||||||
|
var tournamentPlayed: Int? = nil |
||||||
|
var points: Double? = nil |
||||||
|
var clubName: String? = nil |
||||||
|
var ligueName: String? = nil |
||||||
|
var assimilation: String? = nil |
||||||
|
var phoneNumber: String? = nil |
||||||
|
var email: String? = nil |
||||||
|
var birthdate: String? = nil |
||||||
|
var computedRank: Int = 0 |
||||||
|
var source: PlayerRegistration.PlayerDataSource? = nil |
||||||
|
var hasArrived: Bool = false |
||||||
|
var coach: Bool = false |
||||||
|
var captain: Bool = false |
||||||
|
var registeredOnline: Bool = false |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
teamRegistration: String? = nil, |
||||||
|
firstName: String = "", |
||||||
|
lastName: String = "", |
||||||
|
licenceId: String? = nil, |
||||||
|
rank: Int? = nil, |
||||||
|
paymentType: PlayerPaymentType? = nil, |
||||||
|
sex: PlayerSexType? = nil, |
||||||
|
tournamentPlayed: Int? = nil, |
||||||
|
points: Double? = nil, |
||||||
|
clubName: String? = nil, |
||||||
|
ligueName: String? = nil, |
||||||
|
assimilation: String? = nil, |
||||||
|
phoneNumber: String? = nil, |
||||||
|
email: String? = nil, |
||||||
|
birthdate: String? = nil, |
||||||
|
computedRank: Int = 0, |
||||||
|
source: PlayerRegistration.PlayerDataSource? = nil, |
||||||
|
hasArrived: Bool = false, |
||||||
|
coach: Bool = false, |
||||||
|
captain: Bool = false, |
||||||
|
registeredOnline: Bool = false |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.teamRegistration = teamRegistration |
||||||
|
self.firstName = firstName |
||||||
|
self.lastName = lastName |
||||||
|
self.licenceId = licenceId |
||||||
|
self.rank = rank |
||||||
|
self.paymentType = paymentType |
||||||
|
self.sex = sex |
||||||
|
self.tournamentPlayed = tournamentPlayed |
||||||
|
self.points = points |
||||||
|
self.clubName = clubName |
||||||
|
self.ligueName = ligueName |
||||||
|
self.assimilation = assimilation |
||||||
|
self.phoneNumber = phoneNumber |
||||||
|
self.email = email |
||||||
|
self.birthdate = birthdate |
||||||
|
self.computedRank = computedRank |
||||||
|
self.source = source |
||||||
|
self.hasArrived = hasArrived |
||||||
|
self.coach = coach |
||||||
|
self.captain = captain |
||||||
|
self.registeredOnline = registeredOnline |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _teamRegistration = "teamRegistration" |
||||||
|
case _firstName = "firstName" |
||||||
|
case _lastName = "lastName" |
||||||
|
case _licenceId = "licenceId" |
||||||
|
case _rank = "rank" |
||||||
|
case _paymentType = "paymentType" |
||||||
|
case _sex = "sex" |
||||||
|
case _tournamentPlayed = "tournamentPlayed" |
||||||
|
case _points = "points" |
||||||
|
case _clubName = "clubName" |
||||||
|
case _ligueName = "ligueName" |
||||||
|
case _assimilation = "assimilation" |
||||||
|
case _phoneNumber = "phoneNumber" |
||||||
|
case _email = "email" |
||||||
|
case _birthdate = "birthdate" |
||||||
|
case _computedRank = "computedRank" |
||||||
|
case _source = "source" |
||||||
|
case _hasArrived = "hasArrived" |
||||||
|
case _coach = "coach" |
||||||
|
case _captain = "captain" |
||||||
|
case _registeredOnline = "registeredOnline" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.teamRegistration = try container.decodeIfPresent(String.self, forKey: ._teamRegistration) ?? nil |
||||||
|
self.firstName = try container.decodeIfPresent(String.self, forKey: ._firstName) ?? "" |
||||||
|
self.lastName = try container.decodeIfPresent(String.self, forKey: ._lastName) ?? "" |
||||||
|
self.licenceId = try container.decodeIfPresent(String.self, forKey: ._licenceId) ?? nil |
||||||
|
self.rank = try container.decodeIfPresent(Int.self, forKey: ._rank) ?? nil |
||||||
|
self.paymentType = try container.decodeIfPresent(PlayerPaymentType.self, forKey: ._paymentType) ?? nil |
||||||
|
self.sex = try container.decodeIfPresent(PlayerSexType.self, forKey: ._sex) ?? nil |
||||||
|
self.tournamentPlayed = try container.decodeIfPresent(Int.self, forKey: ._tournamentPlayed) ?? nil |
||||||
|
self.points = try container.decodeIfPresent(Double.self, forKey: ._points) ?? nil |
||||||
|
self.clubName = try container.decodeIfPresent(String.self, forKey: ._clubName) ?? nil |
||||||
|
self.ligueName = try container.decodeIfPresent(String.self, forKey: ._ligueName) ?? nil |
||||||
|
self.assimilation = try container.decodeIfPresent(String.self, forKey: ._assimilation) ?? nil |
||||||
|
self.phoneNumber = try container.decodeIfPresent(String.self, forKey: ._phoneNumber) ?? nil |
||||||
|
self.email = try container.decodeIfPresent(String.self, forKey: ._email) ?? nil |
||||||
|
self.birthdate = try container.decodeIfPresent(String.self, forKey: ._birthdate) ?? nil |
||||||
|
self.computedRank = try container.decodeIfPresent(Int.self, forKey: ._computedRank) ?? 0 |
||||||
|
self.source = try container.decodeIfPresent(PlayerRegistration.PlayerDataSource.self, forKey: ._source) ?? nil |
||||||
|
self.hasArrived = try container.decodeIfPresent(Bool.self, forKey: ._hasArrived) ?? false |
||||||
|
self.coach = try container.decodeIfPresent(Bool.self, forKey: ._coach) ?? false |
||||||
|
self.captain = try container.decodeIfPresent(Bool.self, forKey: ._captain) ?? false |
||||||
|
self.registeredOnline = try container.decodeIfPresent(Bool.self, forKey: ._registeredOnline) ?? false |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.teamRegistration, forKey: ._teamRegistration) |
||||||
|
try container.encode(self.firstName, forKey: ._firstName) |
||||||
|
try container.encode(self.lastName, forKey: ._lastName) |
||||||
|
try container.encode(self.licenceId, forKey: ._licenceId) |
||||||
|
try container.encode(self.rank, forKey: ._rank) |
||||||
|
try container.encode(self.paymentType, forKey: ._paymentType) |
||||||
|
try container.encode(self.sex, forKey: ._sex) |
||||||
|
try container.encode(self.tournamentPlayed, forKey: ._tournamentPlayed) |
||||||
|
try container.encode(self.points, forKey: ._points) |
||||||
|
try container.encode(self.clubName, forKey: ._clubName) |
||||||
|
try container.encode(self.ligueName, forKey: ._ligueName) |
||||||
|
try container.encode(self.assimilation, forKey: ._assimilation) |
||||||
|
try container.encode(self.phoneNumber, forKey: ._phoneNumber) |
||||||
|
try container.encode(self.email, forKey: ._email) |
||||||
|
try container.encode(self.birthdate, forKey: ._birthdate) |
||||||
|
try container.encode(self.computedRank, forKey: ._computedRank) |
||||||
|
try container.encode(self.source, forKey: ._source) |
||||||
|
try container.encode(self.hasArrived, forKey: ._hasArrived) |
||||||
|
try container.encode(self.coach, forKey: ._coach) |
||||||
|
try container.encode(self.captain, forKey: ._captain) |
||||||
|
try container.encode(self.registeredOnline, forKey: ._registeredOnline) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func teamRegistrationValue() -> TeamRegistration? { |
||||||
|
guard let teamRegistration = self.teamRegistration else { return nil } |
||||||
|
return Store.main.findById(teamRegistration) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let playerregistration = other as? BasePlayerRegistration else { return } |
||||||
|
self.id = playerregistration.id |
||||||
|
self.teamRegistration = playerregistration.teamRegistration |
||||||
|
self.firstName = playerregistration.firstName |
||||||
|
self.lastName = playerregistration.lastName |
||||||
|
self.licenceId = playerregistration.licenceId |
||||||
|
self.rank = playerregistration.rank |
||||||
|
self.paymentType = playerregistration.paymentType |
||||||
|
self.sex = playerregistration.sex |
||||||
|
self.tournamentPlayed = playerregistration.tournamentPlayed |
||||||
|
self.points = playerregistration.points |
||||||
|
self.clubName = playerregistration.clubName |
||||||
|
self.ligueName = playerregistration.ligueName |
||||||
|
self.assimilation = playerregistration.assimilation |
||||||
|
self.phoneNumber = playerregistration.phoneNumber |
||||||
|
self.email = playerregistration.email |
||||||
|
self.birthdate = playerregistration.birthdate |
||||||
|
self.computedRank = playerregistration.computedRank |
||||||
|
self.source = playerregistration.source |
||||||
|
self.hasArrived = playerregistration.hasArrived |
||||||
|
self.coach = playerregistration.coach |
||||||
|
self.captain = playerregistration.captain |
||||||
|
self.registeredOnline = playerregistration.registeredOnline |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: TeamRegistration.self, keyPath: \BasePlayerRegistration.teamRegistration), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,95 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
class BasePurchase: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "purchases" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: UInt64 = 0 |
||||||
|
var user: String = "" |
||||||
|
var purchaseDate: Date = Date() |
||||||
|
var productId: String = "" |
||||||
|
var quantity: Int? = nil |
||||||
|
var revocationDate: Date? = nil |
||||||
|
var expirationDate: Date? = nil |
||||||
|
|
||||||
|
init( |
||||||
|
id: UInt64 = 0, |
||||||
|
user: String = "", |
||||||
|
purchaseDate: Date = Date(), |
||||||
|
productId: String = "", |
||||||
|
quantity: Int? = nil, |
||||||
|
revocationDate: Date? = nil, |
||||||
|
expirationDate: Date? = nil |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.user = user |
||||||
|
self.purchaseDate = purchaseDate |
||||||
|
self.productId = productId |
||||||
|
self.quantity = quantity |
||||||
|
self.revocationDate = revocationDate |
||||||
|
self.expirationDate = expirationDate |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case id = "id" |
||||||
|
case user = "user" |
||||||
|
case purchaseDate = "purchaseDate" |
||||||
|
case productId = "productId" |
||||||
|
case quantity = "quantity" |
||||||
|
case revocationDate = "revocationDate" |
||||||
|
case expirationDate = "expirationDate" |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(UInt64.self, forKey: .id) ?? 0 |
||||||
|
self.user = try container.decodeEncrypted(key: .user) |
||||||
|
self.purchaseDate = try container.decodeIfPresent(Date.self, forKey: .purchaseDate) ?? Date() |
||||||
|
self.productId = try container.decodeIfPresent(String.self, forKey: .productId) ?? "" |
||||||
|
self.quantity = try container.decodeIfPresent(Int.self, forKey: .quantity) ?? nil |
||||||
|
self.revocationDate = try container.decodeIfPresent(Date.self, forKey: .revocationDate) ?? nil |
||||||
|
self.expirationDate = try container.decodeIfPresent(Date.self, forKey: .expirationDate) ?? nil |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: .id) |
||||||
|
try container.encodeAndEncryptIfPresent(self.user.data(using: .utf8), forKey: .user) |
||||||
|
try container.encode(self.purchaseDate, forKey: .purchaseDate) |
||||||
|
try container.encode(self.productId, forKey: .productId) |
||||||
|
try container.encode(self.quantity, forKey: .quantity) |
||||||
|
try container.encode(self.revocationDate, forKey: .revocationDate) |
||||||
|
try container.encode(self.expirationDate, forKey: .expirationDate) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func userValue() -> CustomUser? { |
||||||
|
return Store.main.findById(user) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let purchase = other as? BasePurchase else { return } |
||||||
|
self.id = purchase.id |
||||||
|
self.user = purchase.user |
||||||
|
self.purchaseDate = purchase.purchaseDate |
||||||
|
self.productId = purchase.productId |
||||||
|
self.quantity = purchase.quantity |
||||||
|
self.revocationDate = purchase.revocationDate |
||||||
|
self.expirationDate = purchase.expirationDate |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: CustomUser.self, keyPath: \BasePurchase.user), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,103 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseRound: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "rounds" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var tournament: String = "" |
||||||
|
var index: Int = 0 |
||||||
|
var parent: String? = nil |
||||||
|
var format: MatchFormat? = nil |
||||||
|
var startDate: Date? = nil |
||||||
|
var groupStageLoserBracket: Bool = false |
||||||
|
var loserBracketMode: LoserBracketMode = .automatic |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
tournament: String = "", |
||||||
|
index: Int = 0, |
||||||
|
parent: String? = nil, |
||||||
|
format: MatchFormat? = nil, |
||||||
|
startDate: Date? = nil, |
||||||
|
groupStageLoserBracket: Bool = false, |
||||||
|
loserBracketMode: LoserBracketMode = .automatic |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.tournament = tournament |
||||||
|
self.index = index |
||||||
|
self.parent = parent |
||||||
|
self.format = format |
||||||
|
self.startDate = startDate |
||||||
|
self.groupStageLoserBracket = groupStageLoserBracket |
||||||
|
self.loserBracketMode = loserBracketMode |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _tournament = "tournament" |
||||||
|
case _index = "index" |
||||||
|
case _parent = "parent" |
||||||
|
case _format = "format" |
||||||
|
case _startDate = "startDate" |
||||||
|
case _groupStageLoserBracket = "groupStageLoserBracket" |
||||||
|
case _loserBracketMode = "loserBracketMode" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.tournament = try container.decodeIfPresent(String.self, forKey: ._tournament) ?? "" |
||||||
|
self.index = try container.decodeIfPresent(Int.self, forKey: ._index) ?? 0 |
||||||
|
self.parent = try container.decodeIfPresent(String.self, forKey: ._parent) ?? nil |
||||||
|
self.format = try container.decodeIfPresent(MatchFormat.self, forKey: ._format) ?? nil |
||||||
|
self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? nil |
||||||
|
self.groupStageLoserBracket = try container.decodeIfPresent(Bool.self, forKey: ._groupStageLoserBracket) ?? false |
||||||
|
self.loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.tournament, forKey: ._tournament) |
||||||
|
try container.encode(self.index, forKey: ._index) |
||||||
|
try container.encode(self.parent, forKey: ._parent) |
||||||
|
try container.encode(self.format, forKey: ._format) |
||||||
|
try container.encode(self.startDate, forKey: ._startDate) |
||||||
|
try container.encode(self.groupStageLoserBracket, forKey: ._groupStageLoserBracket) |
||||||
|
try container.encode(self.loserBracketMode, forKey: ._loserBracketMode) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func tournamentValue() -> Tournament? { |
||||||
|
return Store.main.findById(tournament) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let round = other as? BaseRound else { return } |
||||||
|
self.id = round.id |
||||||
|
self.tournament = round.tournament |
||||||
|
self.index = round.index |
||||||
|
self.parent = round.parent |
||||||
|
self.format = round.format |
||||||
|
self.startDate = round.startDate |
||||||
|
self.groupStageLoserBracket = round.groupStageLoserBracket |
||||||
|
self.loserBracketMode = round.loserBracketMode |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Tournament.self, keyPath: \BaseRound.tournament), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,195 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseTeamRegistration: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "team-registrations" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var tournament: String = "" |
||||||
|
var groupStage: String? = nil |
||||||
|
var registrationDate: Date? = nil |
||||||
|
var callDate: Date? = nil |
||||||
|
var bracketPosition: Int? = nil |
||||||
|
var groupStagePosition: Int? = nil |
||||||
|
var comment: String? = nil |
||||||
|
var source: String? = nil |
||||||
|
var sourceValue: String? = nil |
||||||
|
var logo: String? = nil |
||||||
|
var name: String? = nil |
||||||
|
var walkOut: Bool = false |
||||||
|
var wildCardBracket: Bool = false |
||||||
|
var wildCardGroupStage: Bool = false |
||||||
|
var weight: Int = 0 |
||||||
|
var lockedWeight: Int? = nil |
||||||
|
var confirmationDate: Date? = nil |
||||||
|
var qualified: Bool = false |
||||||
|
var finalRanking: Int? = nil |
||||||
|
var pointsEarned: Int? = nil |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
tournament: String = "", |
||||||
|
groupStage: String? = nil, |
||||||
|
registrationDate: Date? = nil, |
||||||
|
callDate: Date? = nil, |
||||||
|
bracketPosition: Int? = nil, |
||||||
|
groupStagePosition: Int? = nil, |
||||||
|
comment: String? = nil, |
||||||
|
source: String? = nil, |
||||||
|
sourceValue: String? = nil, |
||||||
|
logo: String? = nil, |
||||||
|
name: String? = nil, |
||||||
|
walkOut: Bool = false, |
||||||
|
wildCardBracket: Bool = false, |
||||||
|
wildCardGroupStage: Bool = false, |
||||||
|
weight: Int = 0, |
||||||
|
lockedWeight: Int? = nil, |
||||||
|
confirmationDate: Date? = nil, |
||||||
|
qualified: Bool = false, |
||||||
|
finalRanking: Int? = nil, |
||||||
|
pointsEarned: Int? = nil |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.tournament = tournament |
||||||
|
self.groupStage = groupStage |
||||||
|
self.registrationDate = registrationDate |
||||||
|
self.callDate = callDate |
||||||
|
self.bracketPosition = bracketPosition |
||||||
|
self.groupStagePosition = groupStagePosition |
||||||
|
self.comment = comment |
||||||
|
self.source = source |
||||||
|
self.sourceValue = sourceValue |
||||||
|
self.logo = logo |
||||||
|
self.name = name |
||||||
|
self.walkOut = walkOut |
||||||
|
self.wildCardBracket = wildCardBracket |
||||||
|
self.wildCardGroupStage = wildCardGroupStage |
||||||
|
self.weight = weight |
||||||
|
self.lockedWeight = lockedWeight |
||||||
|
self.confirmationDate = confirmationDate |
||||||
|
self.qualified = qualified |
||||||
|
self.finalRanking = finalRanking |
||||||
|
self.pointsEarned = pointsEarned |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _tournament = "tournament" |
||||||
|
case _groupStage = "groupStage" |
||||||
|
case _registrationDate = "registrationDate" |
||||||
|
case _callDate = "callDate" |
||||||
|
case _bracketPosition = "bracketPosition" |
||||||
|
case _groupStagePosition = "groupStagePosition" |
||||||
|
case _comment = "comment" |
||||||
|
case _source = "source" |
||||||
|
case _sourceValue = "sourceValue" |
||||||
|
case _logo = "logo" |
||||||
|
case _name = "name" |
||||||
|
case _walkOut = "walkOut" |
||||||
|
case _wildCardBracket = "wildCardBracket" |
||||||
|
case _wildCardGroupStage = "wildCardGroupStage" |
||||||
|
case _weight = "weight" |
||||||
|
case _lockedWeight = "lockedWeight" |
||||||
|
case _confirmationDate = "confirmationDate" |
||||||
|
case _qualified = "qualified" |
||||||
|
case _finalRanking = "finalRanking" |
||||||
|
case _pointsEarned = "pointsEarned" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.tournament = try container.decodeIfPresent(String.self, forKey: ._tournament) ?? "" |
||||||
|
self.groupStage = try container.decodeIfPresent(String.self, forKey: ._groupStage) ?? nil |
||||||
|
self.registrationDate = try container.decodeIfPresent(Date.self, forKey: ._registrationDate) ?? nil |
||||||
|
self.callDate = try container.decodeIfPresent(Date.self, forKey: ._callDate) ?? nil |
||||||
|
self.bracketPosition = try container.decodeIfPresent(Int.self, forKey: ._bracketPosition) ?? nil |
||||||
|
self.groupStagePosition = try container.decodeIfPresent(Int.self, forKey: ._groupStagePosition) ?? nil |
||||||
|
self.comment = try container.decodeIfPresent(String.self, forKey: ._comment) ?? nil |
||||||
|
self.source = try container.decodeIfPresent(String.self, forKey: ._source) ?? nil |
||||||
|
self.sourceValue = try container.decodeIfPresent(String.self, forKey: ._sourceValue) ?? nil |
||||||
|
self.logo = try container.decodeIfPresent(String.self, forKey: ._logo) ?? nil |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil |
||||||
|
self.walkOut = try container.decodeIfPresent(Bool.self, forKey: ._walkOut) ?? false |
||||||
|
self.wildCardBracket = try container.decodeIfPresent(Bool.self, forKey: ._wildCardBracket) ?? false |
||||||
|
self.wildCardGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._wildCardGroupStage) ?? false |
||||||
|
self.weight = try container.decodeIfPresent(Int.self, forKey: ._weight) ?? 0 |
||||||
|
self.lockedWeight = try container.decodeIfPresent(Int.self, forKey: ._lockedWeight) ?? nil |
||||||
|
self.confirmationDate = try container.decodeIfPresent(Date.self, forKey: ._confirmationDate) ?? nil |
||||||
|
self.qualified = try container.decodeIfPresent(Bool.self, forKey: ._qualified) ?? false |
||||||
|
self.finalRanking = try container.decodeIfPresent(Int.self, forKey: ._finalRanking) ?? nil |
||||||
|
self.pointsEarned = try container.decodeIfPresent(Int.self, forKey: ._pointsEarned) ?? nil |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.tournament, forKey: ._tournament) |
||||||
|
try container.encode(self.groupStage, forKey: ._groupStage) |
||||||
|
try container.encode(self.registrationDate, forKey: ._registrationDate) |
||||||
|
try container.encode(self.callDate, forKey: ._callDate) |
||||||
|
try container.encode(self.bracketPosition, forKey: ._bracketPosition) |
||||||
|
try container.encode(self.groupStagePosition, forKey: ._groupStagePosition) |
||||||
|
try container.encode(self.comment, forKey: ._comment) |
||||||
|
try container.encode(self.source, forKey: ._source) |
||||||
|
try container.encode(self.sourceValue, forKey: ._sourceValue) |
||||||
|
try container.encode(self.logo, forKey: ._logo) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.walkOut, forKey: ._walkOut) |
||||||
|
try container.encode(self.wildCardBracket, forKey: ._wildCardBracket) |
||||||
|
try container.encode(self.wildCardGroupStage, forKey: ._wildCardGroupStage) |
||||||
|
try container.encode(self.weight, forKey: ._weight) |
||||||
|
try container.encode(self.lockedWeight, forKey: ._lockedWeight) |
||||||
|
try container.encode(self.confirmationDate, forKey: ._confirmationDate) |
||||||
|
try container.encode(self.qualified, forKey: ._qualified) |
||||||
|
try container.encode(self.finalRanking, forKey: ._finalRanking) |
||||||
|
try container.encode(self.pointsEarned, forKey: ._pointsEarned) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func groupStageValue() -> GroupStage? { |
||||||
|
guard let groupStage = self.groupStage else { return nil } |
||||||
|
return self.store?.findById(groupStage) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let teamregistration = other as? BaseTeamRegistration else { return } |
||||||
|
self.id = teamregistration.id |
||||||
|
self.tournament = teamregistration.tournament |
||||||
|
self.groupStage = teamregistration.groupStage |
||||||
|
self.registrationDate = teamregistration.registrationDate |
||||||
|
self.callDate = teamregistration.callDate |
||||||
|
self.bracketPosition = teamregistration.bracketPosition |
||||||
|
self.groupStagePosition = teamregistration.groupStagePosition |
||||||
|
self.comment = teamregistration.comment |
||||||
|
self.source = teamregistration.source |
||||||
|
self.sourceValue = teamregistration.sourceValue |
||||||
|
self.logo = teamregistration.logo |
||||||
|
self.name = teamregistration.name |
||||||
|
self.walkOut = teamregistration.walkOut |
||||||
|
self.wildCardBracket = teamregistration.wildCardBracket |
||||||
|
self.wildCardGroupStage = teamregistration.wildCardGroupStage |
||||||
|
self.weight = teamregistration.weight |
||||||
|
self.lockedWeight = teamregistration.lockedWeight |
||||||
|
self.confirmationDate = teamregistration.confirmationDate |
||||||
|
self.qualified = teamregistration.qualified |
||||||
|
self.finalRanking = teamregistration.finalRanking |
||||||
|
self.pointsEarned = teamregistration.pointsEarned |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: GroupStage.self, keyPath: \BaseTeamRegistration.groupStage), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,95 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseTeamScore: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "team-scores" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var match: String = "" |
||||||
|
var teamRegistration: String? = nil |
||||||
|
var score: String? = nil |
||||||
|
var walkOut: Int? = nil |
||||||
|
var luckyLoser: Int? = nil |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
match: String = "", |
||||||
|
teamRegistration: String? = nil, |
||||||
|
score: String? = nil, |
||||||
|
walkOut: Int? = nil, |
||||||
|
luckyLoser: Int? = nil |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.match = match |
||||||
|
self.teamRegistration = teamRegistration |
||||||
|
self.score = score |
||||||
|
self.walkOut = walkOut |
||||||
|
self.luckyLoser = luckyLoser |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _match = "match" |
||||||
|
case _teamRegistration = "teamRegistration" |
||||||
|
case _score = "score" |
||||||
|
case _walkOut = "walkOut" |
||||||
|
case _luckyLoser = "luckyLoser" |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.match = try container.decodeIfPresent(String.self, forKey: ._match) ?? "" |
||||||
|
self.teamRegistration = try container.decodeIfPresent(String.self, forKey: ._teamRegistration) ?? nil |
||||||
|
self.score = try container.decodeIfPresent(String.self, forKey: ._score) ?? nil |
||||||
|
self.walkOut = try container.decodeIfPresent(Int.self, forKey: ._walkOut) ?? nil |
||||||
|
self.luckyLoser = try container.decodeIfPresent(Int.self, forKey: ._luckyLoser) ?? nil |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.match, forKey: ._match) |
||||||
|
try container.encode(self.teamRegistration, forKey: ._teamRegistration) |
||||||
|
try container.encode(self.score, forKey: ._score) |
||||||
|
try container.encode(self.walkOut, forKey: ._walkOut) |
||||||
|
try container.encode(self.luckyLoser, forKey: ._luckyLoser) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func matchValue() -> Match? { |
||||||
|
return self.store?.findById(match) |
||||||
|
} |
||||||
|
|
||||||
|
func teamRegistrationValue() -> TeamRegistration? { |
||||||
|
guard let teamRegistration = self.teamRegistration else { return nil } |
||||||
|
return self.store?.findById(teamRegistration) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let teamscore = other as? BaseTeamScore else { return } |
||||||
|
self.id = teamscore.id |
||||||
|
self.match = teamscore.match |
||||||
|
self.teamRegistration = teamscore.teamRegistration |
||||||
|
self.score = teamscore.score |
||||||
|
self.walkOut = teamscore.walkOut |
||||||
|
self.luckyLoser = teamscore.luckyLoser |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Match.self, keyPath: \BaseTeamScore.match), |
||||||
|
Relationship(type: TeamRegistration.self, keyPath: \BaseTeamScore.teamRegistration), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,473 @@ |
|||||||
|
// Generated by SwiftModelGenerator |
||||||
|
// Do not modify this file manually |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
@Observable |
||||||
|
class BaseTournament: SyncedModelObject, SyncedStorable { |
||||||
|
|
||||||
|
static func resourceName() -> String { return "tournaments" } |
||||||
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } |
||||||
|
|
||||||
|
var id: String = Store.randomId() |
||||||
|
var event: String? = nil |
||||||
|
var name: String? = nil |
||||||
|
var startDate: Date = Date() |
||||||
|
var endDate: Date? = nil |
||||||
|
var creationDate: Date = Date() |
||||||
|
var isPrivate: Bool = false |
||||||
|
var groupStageFormat: MatchFormat? = nil |
||||||
|
var roundFormat: MatchFormat? = nil |
||||||
|
var loserRoundFormat: MatchFormat? = nil |
||||||
|
var groupStageSortMode: GroupStageOrderingMode = GroupStageOrderingMode.snake |
||||||
|
var groupStageCount: Int = 0 |
||||||
|
var rankSourceDate: Date? = nil |
||||||
|
var dayDuration: Int = 0 |
||||||
|
var teamCount: Int = 0 |
||||||
|
var teamSorting: TeamSortingType = TeamSortingType.inscriptionDate |
||||||
|
var federalCategory: TournamentCategory = TournamentCategory.men |
||||||
|
var federalLevelCategory: TournamentLevel = TournamentLevel.unlisted |
||||||
|
var federalAgeCategory: FederalTournamentAge = FederalTournamentAge.unlisted |
||||||
|
var closedRegistrationDate: Date? = nil |
||||||
|
var groupStageAdditionalQualified: Int = 0 |
||||||
|
var courtCount: Int = 2 |
||||||
|
var prioritizeClubMembers: Bool = false |
||||||
|
var qualifiedPerGroupStage: Int = 0 |
||||||
|
var teamsPerGroupStage: Int = 0 |
||||||
|
var entryFee: Double? = nil |
||||||
|
var payment: TournamentPayment? = nil |
||||||
|
var additionalEstimationDuration: Int = 0 |
||||||
|
var isDeleted: Bool = false |
||||||
|
var isCanceled: Bool = false |
||||||
|
var publishTeams: Bool = false |
||||||
|
var publishSummons: Bool = false |
||||||
|
var publishGroupStages: Bool = false |
||||||
|
var publishBrackets: Bool = false |
||||||
|
var shouldVerifyGroupStage: Bool = false |
||||||
|
var shouldVerifyBracket: Bool = false |
||||||
|
var hideTeamsWeight: Bool = false |
||||||
|
var publishTournament: Bool = false |
||||||
|
var hidePointsEarned: Bool = false |
||||||
|
var publishRankings: Bool = false |
||||||
|
var loserBracketMode: LoserBracketMode = .automatic |
||||||
|
var initialSeedRound: Int = 0 |
||||||
|
var initialSeedCount: Int = 0 |
||||||
|
var enableOnlineRegistration: Bool = false |
||||||
|
var registrationDateLimit: Date? = nil |
||||||
|
var openingRegistrationDate: Date? = nil |
||||||
|
var waitingListLimit: Int? = nil |
||||||
|
var accountIsRequired: Bool = true |
||||||
|
var licenseIsRequired: Bool = true |
||||||
|
var minimumPlayerPerTeam: Int = 2 |
||||||
|
var maximumPlayerPerTeam: Int = 2 |
||||||
|
var information: String? = nil |
||||||
|
|
||||||
|
init( |
||||||
|
id: String = Store.randomId(), |
||||||
|
event: String? = nil, |
||||||
|
name: String? = nil, |
||||||
|
startDate: Date = Date(), |
||||||
|
endDate: Date? = nil, |
||||||
|
creationDate: Date = Date(), |
||||||
|
isPrivate: Bool = false, |
||||||
|
groupStageFormat: MatchFormat? = nil, |
||||||
|
roundFormat: MatchFormat? = nil, |
||||||
|
loserRoundFormat: MatchFormat? = nil, |
||||||
|
groupStageSortMode: GroupStageOrderingMode = GroupStageOrderingMode.snake, |
||||||
|
groupStageCount: Int = 0, |
||||||
|
rankSourceDate: Date? = nil, |
||||||
|
dayDuration: Int = 0, |
||||||
|
teamCount: Int = 0, |
||||||
|
teamSorting: TeamSortingType = TeamSortingType.inscriptionDate, |
||||||
|
federalCategory: TournamentCategory = TournamentCategory.men, |
||||||
|
federalLevelCategory: TournamentLevel = TournamentLevel.unlisted, |
||||||
|
federalAgeCategory: FederalTournamentAge = FederalTournamentAge.unlisted, |
||||||
|
closedRegistrationDate: Date? = nil, |
||||||
|
groupStageAdditionalQualified: Int = 0, |
||||||
|
courtCount: Int = 2, |
||||||
|
prioritizeClubMembers: Bool = false, |
||||||
|
qualifiedPerGroupStage: Int = 0, |
||||||
|
teamsPerGroupStage: Int = 0, |
||||||
|
entryFee: Double? = nil, |
||||||
|
payment: TournamentPayment? = nil, |
||||||
|
additionalEstimationDuration: Int = 0, |
||||||
|
isDeleted: Bool = false, |
||||||
|
isCanceled: Bool = false, |
||||||
|
publishTeams: Bool = false, |
||||||
|
publishSummons: Bool = false, |
||||||
|
publishGroupStages: Bool = false, |
||||||
|
publishBrackets: Bool = false, |
||||||
|
shouldVerifyGroupStage: Bool = false, |
||||||
|
shouldVerifyBracket: Bool = false, |
||||||
|
hideTeamsWeight: Bool = false, |
||||||
|
publishTournament: Bool = false, |
||||||
|
hidePointsEarned: Bool = false, |
||||||
|
publishRankings: Bool = false, |
||||||
|
loserBracketMode: LoserBracketMode = .automatic, |
||||||
|
initialSeedRound: Int = 0, |
||||||
|
initialSeedCount: Int = 0, |
||||||
|
enableOnlineRegistration: Bool = false, |
||||||
|
registrationDateLimit: Date? = nil, |
||||||
|
openingRegistrationDate: Date? = nil, |
||||||
|
waitingListLimit: Int? = nil, |
||||||
|
accountIsRequired: Bool = true, |
||||||
|
licenseIsRequired: Bool = true, |
||||||
|
minimumPlayerPerTeam: Int = 2, |
||||||
|
maximumPlayerPerTeam: Int = 2, |
||||||
|
information: String? = nil |
||||||
|
) { |
||||||
|
super.init() |
||||||
|
self.id = id |
||||||
|
self.event = event |
||||||
|
self.name = name |
||||||
|
self.startDate = startDate |
||||||
|
self.endDate = endDate |
||||||
|
self.creationDate = creationDate |
||||||
|
self.isPrivate = isPrivate |
||||||
|
self.groupStageFormat = groupStageFormat |
||||||
|
self.roundFormat = roundFormat |
||||||
|
self.loserRoundFormat = loserRoundFormat |
||||||
|
self.groupStageSortMode = groupStageSortMode |
||||||
|
self.groupStageCount = groupStageCount |
||||||
|
self.rankSourceDate = rankSourceDate |
||||||
|
self.dayDuration = dayDuration |
||||||
|
self.teamCount = teamCount |
||||||
|
self.teamSorting = teamSorting |
||||||
|
self.federalCategory = federalCategory |
||||||
|
self.federalLevelCategory = federalLevelCategory |
||||||
|
self.federalAgeCategory = federalAgeCategory |
||||||
|
self.closedRegistrationDate = closedRegistrationDate |
||||||
|
self.groupStageAdditionalQualified = groupStageAdditionalQualified |
||||||
|
self.courtCount = courtCount |
||||||
|
self.prioritizeClubMembers = prioritizeClubMembers |
||||||
|
self.qualifiedPerGroupStage = qualifiedPerGroupStage |
||||||
|
self.teamsPerGroupStage = teamsPerGroupStage |
||||||
|
self.entryFee = entryFee |
||||||
|
self.payment = payment |
||||||
|
self.additionalEstimationDuration = additionalEstimationDuration |
||||||
|
self.isDeleted = isDeleted |
||||||
|
self.isCanceled = isCanceled |
||||||
|
self.publishTeams = publishTeams |
||||||
|
self.publishSummons = publishSummons |
||||||
|
self.publishGroupStages = publishGroupStages |
||||||
|
self.publishBrackets = publishBrackets |
||||||
|
self.shouldVerifyGroupStage = shouldVerifyGroupStage |
||||||
|
self.shouldVerifyBracket = shouldVerifyBracket |
||||||
|
self.hideTeamsWeight = hideTeamsWeight |
||||||
|
self.publishTournament = publishTournament |
||||||
|
self.hidePointsEarned = hidePointsEarned |
||||||
|
self.publishRankings = publishRankings |
||||||
|
self.loserBracketMode = loserBracketMode |
||||||
|
self.initialSeedRound = initialSeedRound |
||||||
|
self.initialSeedCount = initialSeedCount |
||||||
|
self.enableOnlineRegistration = enableOnlineRegistration |
||||||
|
self.registrationDateLimit = registrationDateLimit |
||||||
|
self.openingRegistrationDate = openingRegistrationDate |
||||||
|
self.waitingListLimit = waitingListLimit |
||||||
|
self.accountIsRequired = accountIsRequired |
||||||
|
self.licenseIsRequired = licenseIsRequired |
||||||
|
self.minimumPlayerPerTeam = minimumPlayerPerTeam |
||||||
|
self.maximumPlayerPerTeam = maximumPlayerPerTeam |
||||||
|
self.information = information |
||||||
|
} |
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey { |
||||||
|
case _id = "id" |
||||||
|
case _event = "event" |
||||||
|
case _name = "name" |
||||||
|
case _startDate = "startDate" |
||||||
|
case _endDate = "endDate" |
||||||
|
case _creationDate = "creationDate" |
||||||
|
case _isPrivate = "isPrivate" |
||||||
|
case _groupStageFormat = "groupStageFormat" |
||||||
|
case _roundFormat = "roundFormat" |
||||||
|
case _loserRoundFormat = "loserRoundFormat" |
||||||
|
case _groupStageSortMode = "groupStageSortMode" |
||||||
|
case _groupStageCount = "groupStageCount" |
||||||
|
case _rankSourceDate = "rankSourceDate" |
||||||
|
case _dayDuration = "dayDuration" |
||||||
|
case _teamCount = "teamCount" |
||||||
|
case _teamSorting = "teamSorting" |
||||||
|
case _federalCategory = "federalCategory" |
||||||
|
case _federalLevelCategory = "federalLevelCategory" |
||||||
|
case _federalAgeCategory = "federalAgeCategory" |
||||||
|
case _closedRegistrationDate = "closedRegistrationDate" |
||||||
|
case _groupStageAdditionalQualified = "groupStageAdditionalQualified" |
||||||
|
case _courtCount = "courtCount" |
||||||
|
case _prioritizeClubMembers = "prioritizeClubMembers" |
||||||
|
case _qualifiedPerGroupStage = "qualifiedPerGroupStage" |
||||||
|
case _teamsPerGroupStage = "teamsPerGroupStage" |
||||||
|
case _entryFee = "entryFee" |
||||||
|
case _payment = "payment" |
||||||
|
case _additionalEstimationDuration = "additionalEstimationDuration" |
||||||
|
case _isDeleted = "isDeleted" |
||||||
|
case _isCanceled = "isCanceled" |
||||||
|
case _publishTeams = "publishTeams" |
||||||
|
case _publishSummons = "publishSummons" |
||||||
|
case _publishGroupStages = "publishGroupStages" |
||||||
|
case _publishBrackets = "publishBrackets" |
||||||
|
case _shouldVerifyGroupStage = "shouldVerifyGroupStage" |
||||||
|
case _shouldVerifyBracket = "shouldVerifyBracket" |
||||||
|
case _hideTeamsWeight = "hideTeamsWeight" |
||||||
|
case _publishTournament = "publishTournament" |
||||||
|
case _hidePointsEarned = "hidePointsEarned" |
||||||
|
case _publishRankings = "publishRankings" |
||||||
|
case _loserBracketMode = "loserBracketMode" |
||||||
|
case _initialSeedRound = "initialSeedRound" |
||||||
|
case _initialSeedCount = "initialSeedCount" |
||||||
|
case _enableOnlineRegistration = "enableOnlineRegistration" |
||||||
|
case _registrationDateLimit = "registrationDateLimit" |
||||||
|
case _openingRegistrationDate = "openingRegistrationDate" |
||||||
|
case _waitingListLimit = "waitingListLimit" |
||||||
|
case _accountIsRequired = "accountIsRequired" |
||||||
|
case _licenseIsRequired = "licenseIsRequired" |
||||||
|
case _minimumPlayerPerTeam = "minimumPlayerPerTeam" |
||||||
|
case _maximumPlayerPerTeam = "maximumPlayerPerTeam" |
||||||
|
case _information = "information" |
||||||
|
} |
||||||
|
|
||||||
|
private static func _decodePayment(container: KeyedDecodingContainer<CodingKeys>) throws -> TournamentPayment? { |
||||||
|
let data = try container.decodeIfPresent(Data.self, forKey: ._payment) |
||||||
|
|
||||||
|
if let data { |
||||||
|
do { |
||||||
|
let decoded: String = try data.decryptData(pass: CryptoKey.pass.rawValue) |
||||||
|
let sequence = decoded.compactMap { NumberFormatter.standard.number(from: String($0))?.intValue } |
||||||
|
return TournamentPayment(rawValue: sequence[18]) |
||||||
|
} catch { |
||||||
|
Logger.error(error) |
||||||
|
} |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
private func _encodePayment(container: inout KeyedEncodingContainer<CodingKeys>) throws { |
||||||
|
guard let payment else { |
||||||
|
try container.encodeNil(forKey: ._payment) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
let max: Int = TournamentPayment.allCases.count |
||||||
|
var sequence = (1...18).map { _ in Int.random(in: (0..<max)) } |
||||||
|
sequence.append(payment.rawValue) |
||||||
|
sequence.append(contentsOf: (1...13).map { _ in Int.random(in: (0..<max ))} ) |
||||||
|
|
||||||
|
let stringCombo: [String] = sequence.map { $0.formatted() } |
||||||
|
let joined: String = stringCombo.joined(separator: "") |
||||||
|
if let data = joined.data(using: .utf8) { |
||||||
|
let encryped: Data = try data.encrypt(pass: CryptoKey.pass.rawValue) |
||||||
|
try container.encodeIfPresent(encryped, forKey: ._payment) |
||||||
|
} |
||||||
|
} |
||||||
|
private static func _decodeIscanceled(container: KeyedDecodingContainer<CodingKeys>) throws -> Bool { |
||||||
|
let data = try container.decodeIfPresent(Data.self, forKey: ._isCanceled) |
||||||
|
if let data { |
||||||
|
do { |
||||||
|
let decoded: String = try data.decryptData(pass: CryptoKey.pass.rawValue) |
||||||
|
let sequence = decoded.compactMap { NumberFormatter.standard.number(from: String($0))?.intValue } |
||||||
|
return Bool.decodeInt(sequence[18]) |
||||||
|
} catch { |
||||||
|
Logger.error(error) |
||||||
|
} |
||||||
|
} |
||||||
|
return false |
||||||
|
} |
||||||
|
|
||||||
|
private func _encodeIscanceled(container: inout KeyedEncodingContainer<CodingKeys>) throws { |
||||||
|
let max: Int = 9 |
||||||
|
var sequence = (1...18).map { _ in Int.random(in: (0...max)) } |
||||||
|
sequence.append(self.isCanceled.encodedValue) |
||||||
|
sequence.append(contentsOf: (1...13).map { _ in Int.random(in: (0...max ))} ) |
||||||
|
|
||||||
|
let stringCombo: [String] = sequence.map { $0.formatted() } |
||||||
|
let joined: String = stringCombo.joined(separator: "") |
||||||
|
if let data = joined.data(using: .utf8) { |
||||||
|
let encryped: Data = try data.encrypt(pass: CryptoKey.pass.rawValue) |
||||||
|
try container.encode(encryped, forKey: ._isCanceled) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
required init(from decoder: Decoder) throws { |
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
||||||
|
self.event = try container.decodeIfPresent(String.self, forKey: ._event) ?? nil |
||||||
|
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil |
||||||
|
self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? Date() |
||||||
|
self.endDate = try container.decodeIfPresent(Date.self, forKey: ._endDate) ?? nil |
||||||
|
self.creationDate = try container.decodeIfPresent(Date.self, forKey: ._creationDate) ?? Date() |
||||||
|
self.isPrivate = try container.decodeIfPresent(Bool.self, forKey: ._isPrivate) ?? false |
||||||
|
self.groupStageFormat = try container.decodeIfPresent(MatchFormat.self, forKey: ._groupStageFormat) ?? nil |
||||||
|
self.roundFormat = try container.decodeIfPresent(MatchFormat.self, forKey: ._roundFormat) ?? nil |
||||||
|
self.loserRoundFormat = try container.decodeIfPresent(MatchFormat.self, forKey: ._loserRoundFormat) ?? nil |
||||||
|
self.groupStageSortMode = try container.decodeIfPresent(GroupStageOrderingMode.self, forKey: ._groupStageSortMode) ?? GroupStageOrderingMode.snake |
||||||
|
self.groupStageCount = try container.decodeIfPresent(Int.self, forKey: ._groupStageCount) ?? 0 |
||||||
|
self.rankSourceDate = try container.decodeIfPresent(Date.self, forKey: ._rankSourceDate) ?? nil |
||||||
|
self.dayDuration = try container.decodeIfPresent(Int.self, forKey: ._dayDuration) ?? 0 |
||||||
|
self.teamCount = try container.decodeIfPresent(Int.self, forKey: ._teamCount) ?? 0 |
||||||
|
self.teamSorting = try container.decodeIfPresent(TeamSortingType.self, forKey: ._teamSorting) ?? TeamSortingType.inscriptionDate |
||||||
|
self.federalCategory = try container.decodeIfPresent(TournamentCategory.self, forKey: ._federalCategory) ?? TournamentCategory.men |
||||||
|
self.federalLevelCategory = try container.decodeIfPresent(TournamentLevel.self, forKey: ._federalLevelCategory) ?? TournamentLevel.unlisted |
||||||
|
self.federalAgeCategory = try container.decodeIfPresent(FederalTournamentAge.self, forKey: ._federalAgeCategory) ?? FederalTournamentAge.unlisted |
||||||
|
self.closedRegistrationDate = try container.decodeIfPresent(Date.self, forKey: ._closedRegistrationDate) ?? nil |
||||||
|
self.groupStageAdditionalQualified = try container.decodeIfPresent(Int.self, forKey: ._groupStageAdditionalQualified) ?? 0 |
||||||
|
self.courtCount = try container.decodeIfPresent(Int.self, forKey: ._courtCount) ?? 2 |
||||||
|
self.prioritizeClubMembers = try container.decodeIfPresent(Bool.self, forKey: ._prioritizeClubMembers) ?? false |
||||||
|
self.qualifiedPerGroupStage = try container.decodeIfPresent(Int.self, forKey: ._qualifiedPerGroupStage) ?? 0 |
||||||
|
self.teamsPerGroupStage = try container.decodeIfPresent(Int.self, forKey: ._teamsPerGroupStage) ?? 0 |
||||||
|
self.entryFee = try container.decodeIfPresent(Double.self, forKey: ._entryFee) ?? nil |
||||||
|
self.payment = try Self._decodePayment(container: container) |
||||||
|
self.additionalEstimationDuration = try container.decodeIfPresent(Int.self, forKey: ._additionalEstimationDuration) ?? 0 |
||||||
|
self.isDeleted = try container.decodeIfPresent(Bool.self, forKey: ._isDeleted) ?? false |
||||||
|
self.isCanceled = try Self._decodeIscanceled(container: container) |
||||||
|
self.publishTeams = try container.decodeIfPresent(Bool.self, forKey: ._publishTeams) ?? false |
||||||
|
self.publishSummons = try container.decodeIfPresent(Bool.self, forKey: ._publishSummons) ?? false |
||||||
|
self.publishGroupStages = try container.decodeIfPresent(Bool.self, forKey: ._publishGroupStages) ?? false |
||||||
|
self.publishBrackets = try container.decodeIfPresent(Bool.self, forKey: ._publishBrackets) ?? false |
||||||
|
self.shouldVerifyGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._shouldVerifyGroupStage) ?? false |
||||||
|
self.shouldVerifyBracket = try container.decodeIfPresent(Bool.self, forKey: ._shouldVerifyBracket) ?? false |
||||||
|
self.hideTeamsWeight = try container.decodeIfPresent(Bool.self, forKey: ._hideTeamsWeight) ?? false |
||||||
|
self.publishTournament = try container.decodeIfPresent(Bool.self, forKey: ._publishTournament) ?? false |
||||||
|
self.hidePointsEarned = try container.decodeIfPresent(Bool.self, forKey: ._hidePointsEarned) ?? false |
||||||
|
self.publishRankings = try container.decodeIfPresent(Bool.self, forKey: ._publishRankings) ?? false |
||||||
|
self.loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic |
||||||
|
self.initialSeedRound = try container.decodeIfPresent(Int.self, forKey: ._initialSeedRound) ?? 0 |
||||||
|
self.initialSeedCount = try container.decodeIfPresent(Int.self, forKey: ._initialSeedCount) ?? 0 |
||||||
|
self.enableOnlineRegistration = try container.decodeIfPresent(Bool.self, forKey: ._enableOnlineRegistration) ?? false |
||||||
|
self.registrationDateLimit = try container.decodeIfPresent(Date.self, forKey: ._registrationDateLimit) ?? nil |
||||||
|
self.openingRegistrationDate = try container.decodeIfPresent(Date.self, forKey: ._openingRegistrationDate) ?? nil |
||||||
|
self.waitingListLimit = try container.decodeIfPresent(Int.self, forKey: ._waitingListLimit) ?? nil |
||||||
|
self.accountIsRequired = try container.decodeIfPresent(Bool.self, forKey: ._accountIsRequired) ?? true |
||||||
|
self.licenseIsRequired = try container.decodeIfPresent(Bool.self, forKey: ._licenseIsRequired) ?? true |
||||||
|
self.minimumPlayerPerTeam = try container.decodeIfPresent(Int.self, forKey: ._minimumPlayerPerTeam) ?? 2 |
||||||
|
self.maximumPlayerPerTeam = try container.decodeIfPresent(Int.self, forKey: ._maximumPlayerPerTeam) ?? 2 |
||||||
|
self.information = try container.decodeIfPresent(String.self, forKey: ._information) ?? nil |
||||||
|
try super.init(from: decoder) |
||||||
|
} |
||||||
|
|
||||||
|
override func encode(to encoder: Encoder) throws { |
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self) |
||||||
|
try container.encode(self.id, forKey: ._id) |
||||||
|
try container.encode(self.event, forKey: ._event) |
||||||
|
try container.encode(self.name, forKey: ._name) |
||||||
|
try container.encode(self.startDate, forKey: ._startDate) |
||||||
|
try container.encode(self.endDate, forKey: ._endDate) |
||||||
|
try container.encode(self.creationDate, forKey: ._creationDate) |
||||||
|
try container.encode(self.isPrivate, forKey: ._isPrivate) |
||||||
|
try container.encode(self.groupStageFormat, forKey: ._groupStageFormat) |
||||||
|
try container.encode(self.roundFormat, forKey: ._roundFormat) |
||||||
|
try container.encode(self.loserRoundFormat, forKey: ._loserRoundFormat) |
||||||
|
try container.encode(self.groupStageSortMode, forKey: ._groupStageSortMode) |
||||||
|
try container.encode(self.groupStageCount, forKey: ._groupStageCount) |
||||||
|
try container.encode(self.rankSourceDate, forKey: ._rankSourceDate) |
||||||
|
try container.encode(self.dayDuration, forKey: ._dayDuration) |
||||||
|
try container.encode(self.teamCount, forKey: ._teamCount) |
||||||
|
try container.encode(self.teamSorting, forKey: ._teamSorting) |
||||||
|
try container.encode(self.federalCategory, forKey: ._federalCategory) |
||||||
|
try container.encode(self.federalLevelCategory, forKey: ._federalLevelCategory) |
||||||
|
try container.encode(self.federalAgeCategory, forKey: ._federalAgeCategory) |
||||||
|
try container.encode(self.closedRegistrationDate, forKey: ._closedRegistrationDate) |
||||||
|
try container.encode(self.groupStageAdditionalQualified, forKey: ._groupStageAdditionalQualified) |
||||||
|
try container.encode(self.courtCount, forKey: ._courtCount) |
||||||
|
try container.encode(self.prioritizeClubMembers, forKey: ._prioritizeClubMembers) |
||||||
|
try container.encode(self.qualifiedPerGroupStage, forKey: ._qualifiedPerGroupStage) |
||||||
|
try container.encode(self.teamsPerGroupStage, forKey: ._teamsPerGroupStage) |
||||||
|
try container.encode(self.entryFee, forKey: ._entryFee) |
||||||
|
try _encodePayment(container: &container) |
||||||
|
try container.encode(self.additionalEstimationDuration, forKey: ._additionalEstimationDuration) |
||||||
|
try container.encode(self.isDeleted, forKey: ._isDeleted) |
||||||
|
try _encodeIscanceled(container: &container) |
||||||
|
try container.encode(self.publishTeams, forKey: ._publishTeams) |
||||||
|
try container.encode(self.publishSummons, forKey: ._publishSummons) |
||||||
|
try container.encode(self.publishGroupStages, forKey: ._publishGroupStages) |
||||||
|
try container.encode(self.publishBrackets, forKey: ._publishBrackets) |
||||||
|
try container.encode(self.shouldVerifyGroupStage, forKey: ._shouldVerifyGroupStage) |
||||||
|
try container.encode(self.shouldVerifyBracket, forKey: ._shouldVerifyBracket) |
||||||
|
try container.encode(self.hideTeamsWeight, forKey: ._hideTeamsWeight) |
||||||
|
try container.encode(self.publishTournament, forKey: ._publishTournament) |
||||||
|
try container.encode(self.hidePointsEarned, forKey: ._hidePointsEarned) |
||||||
|
try container.encode(self.publishRankings, forKey: ._publishRankings) |
||||||
|
try container.encode(self.loserBracketMode, forKey: ._loserBracketMode) |
||||||
|
try container.encode(self.initialSeedRound, forKey: ._initialSeedRound) |
||||||
|
try container.encode(self.initialSeedCount, forKey: ._initialSeedCount) |
||||||
|
try container.encode(self.enableOnlineRegistration, forKey: ._enableOnlineRegistration) |
||||||
|
try container.encode(self.registrationDateLimit, forKey: ._registrationDateLimit) |
||||||
|
try container.encode(self.openingRegistrationDate, forKey: ._openingRegistrationDate) |
||||||
|
try container.encode(self.waitingListLimit, forKey: ._waitingListLimit) |
||||||
|
try container.encode(self.accountIsRequired, forKey: ._accountIsRequired) |
||||||
|
try container.encode(self.licenseIsRequired, forKey: ._licenseIsRequired) |
||||||
|
try container.encode(self.minimumPlayerPerTeam, forKey: ._minimumPlayerPerTeam) |
||||||
|
try container.encode(self.maximumPlayerPerTeam, forKey: ._maximumPlayerPerTeam) |
||||||
|
try container.encode(self.information, forKey: ._information) |
||||||
|
try super.encode(to: encoder) |
||||||
|
} |
||||||
|
|
||||||
|
func eventValue() -> Event? { |
||||||
|
guard let event = self.event else { return nil } |
||||||
|
return Store.main.findById(event) |
||||||
|
} |
||||||
|
|
||||||
|
func copy(from other: any Storable) { |
||||||
|
guard let tournament = other as? BaseTournament else { return } |
||||||
|
self.id = tournament.id |
||||||
|
self.event = tournament.event |
||||||
|
self.name = tournament.name |
||||||
|
self.startDate = tournament.startDate |
||||||
|
self.endDate = tournament.endDate |
||||||
|
self.creationDate = tournament.creationDate |
||||||
|
self.isPrivate = tournament.isPrivate |
||||||
|
self.groupStageFormat = tournament.groupStageFormat |
||||||
|
self.roundFormat = tournament.roundFormat |
||||||
|
self.loserRoundFormat = tournament.loserRoundFormat |
||||||
|
self.groupStageSortMode = tournament.groupStageSortMode |
||||||
|
self.groupStageCount = tournament.groupStageCount |
||||||
|
self.rankSourceDate = tournament.rankSourceDate |
||||||
|
self.dayDuration = tournament.dayDuration |
||||||
|
self.teamCount = tournament.teamCount |
||||||
|
self.teamSorting = tournament.teamSorting |
||||||
|
self.federalCategory = tournament.federalCategory |
||||||
|
self.federalLevelCategory = tournament.federalLevelCategory |
||||||
|
self.federalAgeCategory = tournament.federalAgeCategory |
||||||
|
self.closedRegistrationDate = tournament.closedRegistrationDate |
||||||
|
self.groupStageAdditionalQualified = tournament.groupStageAdditionalQualified |
||||||
|
self.courtCount = tournament.courtCount |
||||||
|
self.prioritizeClubMembers = tournament.prioritizeClubMembers |
||||||
|
self.qualifiedPerGroupStage = tournament.qualifiedPerGroupStage |
||||||
|
self.teamsPerGroupStage = tournament.teamsPerGroupStage |
||||||
|
self.entryFee = tournament.entryFee |
||||||
|
self.payment = tournament.payment |
||||||
|
self.additionalEstimationDuration = tournament.additionalEstimationDuration |
||||||
|
self.isDeleted = tournament.isDeleted |
||||||
|
self.isCanceled = tournament.isCanceled |
||||||
|
self.publishTeams = tournament.publishTeams |
||||||
|
self.publishSummons = tournament.publishSummons |
||||||
|
self.publishGroupStages = tournament.publishGroupStages |
||||||
|
self.publishBrackets = tournament.publishBrackets |
||||||
|
self.shouldVerifyGroupStage = tournament.shouldVerifyGroupStage |
||||||
|
self.shouldVerifyBracket = tournament.shouldVerifyBracket |
||||||
|
self.hideTeamsWeight = tournament.hideTeamsWeight |
||||||
|
self.publishTournament = tournament.publishTournament |
||||||
|
self.hidePointsEarned = tournament.hidePointsEarned |
||||||
|
self.publishRankings = tournament.publishRankings |
||||||
|
self.loserBracketMode = tournament.loserBracketMode |
||||||
|
self.initialSeedRound = tournament.initialSeedRound |
||||||
|
self.initialSeedCount = tournament.initialSeedCount |
||||||
|
self.enableOnlineRegistration = tournament.enableOnlineRegistration |
||||||
|
self.registrationDateLimit = tournament.registrationDateLimit |
||||||
|
self.openingRegistrationDate = tournament.openingRegistrationDate |
||||||
|
self.waitingListLimit = tournament.waitingListLimit |
||||||
|
self.accountIsRequired = tournament.accountIsRequired |
||||||
|
self.licenseIsRequired = tournament.licenseIsRequired |
||||||
|
self.minimumPlayerPerTeam = tournament.minimumPlayerPerTeam |
||||||
|
self.maximumPlayerPerTeam = tournament.maximumPlayerPerTeam |
||||||
|
self.information = tournament.information |
||||||
|
} |
||||||
|
|
||||||
|
static func relationships() -> [Relationship] { |
||||||
|
return [ |
||||||
|
Relationship(type: Event.self, keyPath: \BaseTournament.event), |
||||||
|
] |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,92 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Club", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "creator", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil", |
||||||
|
"foreignKey": "CustomUser" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "\"\"" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "acronym", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "\"\"" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "phone", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "code", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "address", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "city", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "zipCode", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "latitude", |
||||||
|
"type": "Double", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "longitude", |
||||||
|
"type": "Double", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "courtCount", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "2" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "broadcastCode", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "timezone", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "TimeZone.current.identifier" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Court", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "index", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "club", |
||||||
|
"type": "String", |
||||||
|
"foreignKey": "Club" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "exitAllowed", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "indoor", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
} |
||||||
|
], |
||||||
|
"tokenExemptedMethods": [] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,136 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "CustomUser", |
||||||
|
"resource_name": "users", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"tokenExemptedMethods": ["post"], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "username", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "email", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "clubs", |
||||||
|
"type": "[String]", |
||||||
|
"defaultValue": "[]" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "umpireCode", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "licenceId", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "firstName", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "lastName", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "phone", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "country", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "summonsMessageBody", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "summonsMessageSignature", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "summonsAvailablePaymentMethods", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "summonsDisplayFormat", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "summonsDisplayEntryFee", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "summonsUseFullCustomMessage", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "matchFormatsDefaultDuration", |
||||||
|
"type": "[MatchFormat: Int]", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "bracketMatchFormatPreference", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageMatchFormatPreference", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "loserBracketMatchFormatPreference", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "loserBracketMode", |
||||||
|
"type": "LoserBracketMode", |
||||||
|
"defaultValue": ".automatic" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "deviceId", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "agents", |
||||||
|
"type": "[String]", |
||||||
|
"defaultValue": "[]" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "DateInterval", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "event", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "courtIndex", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "startDate", |
||||||
|
"type": "Date" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "endDate", |
||||||
|
"type": "Date" |
||||||
|
} |
||||||
|
], |
||||||
|
"tokenExemptedMethods": [] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,47 @@ |
|||||||
|
|
||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "DrawLog", |
||||||
|
"synchronizable": true, |
||||||
|
"sideStorable": true, |
||||||
|
"observable": true, |
||||||
|
"relationshipNames": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tournament", |
||||||
|
"type": "String", |
||||||
|
"foreignKey": "Tournament" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "drawDate", |
||||||
|
"type": "Date", |
||||||
|
"defaultValue": "Date()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "drawSeed", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "drawMatchIndex", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "drawTeamPosition", |
||||||
|
"type": "TeamPosition", |
||||||
|
"defaultValue": "TeamPosition.one" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "drawType", |
||||||
|
"type": "DrawType", |
||||||
|
"defaultValue": "DrawType.seed" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Event", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "creator", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil", |
||||||
|
"foreignKey": "CustomUser" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "club", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil", |
||||||
|
"foreignKey": "Club" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "creationDate", |
||||||
|
"type": "Date", |
||||||
|
"defaultValue": "Date()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tenupId", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
} |
||||||
|
], |
||||||
|
"tokenExemptedMethods": [] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "GroupStage", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tournament", |
||||||
|
"type": "String", |
||||||
|
"foreignKey": "Tournament" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "index", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "size", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "format", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "startDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "step", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "0" |
||||||
|
} |
||||||
|
], |
||||||
|
"tokenExemptedMethods": [] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,83 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Match", |
||||||
|
"synchronizable": true, |
||||||
|
"observable": true, |
||||||
|
"tokenExemptedMethods": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "round", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"foreignKey": "Round*" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStage", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"foreignKey": "GroupStage*" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "startDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "endDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "index", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "format", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "servingTeamId", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "winningTeamId", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "losingTeamId", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "disabled", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "courtIndex", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "confirmed", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,84 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "MatchScheduler", |
||||||
|
"resource_name": "match-scheduler", |
||||||
|
"synchronizable": false, |
||||||
|
"observable": true, |
||||||
|
"tokenExemptedMethods": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tournament", |
||||||
|
"type": "String", |
||||||
|
"foreignKey": "Tournament" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "timeDifferenceLimit", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "loserBracketRotationDifference", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "upperBracketRotationDifference", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "accountUpperBracketBreakTime", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "accountLoserBracketBreakTime", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "randomizeCourts", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "rotationDifferenceIsImportant", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "shouldHandleUpperRoundSlice", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "shouldEndRoundBeforeStartingNext", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageChunkCount", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "overrideCourtsUnavailability", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "shouldTryToFillUpCourtsAvailable", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "courtsAvailable", |
||||||
|
"type": "Set<Int>", |
||||||
|
"defaultValue": "Set<Int>()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "simultaneousStart", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "true" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,71 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "MonthData", |
||||||
|
"resource_name": "month-data", |
||||||
|
"synchronizable": false, |
||||||
|
"observable": true, |
||||||
|
"tokenExemptedMethods": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "monthKey", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "creationDate", |
||||||
|
"type": "Date" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "maleUnrankedValue", |
||||||
|
"type": "Int", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "femaleUnrankedValue", |
||||||
|
"type": "Int", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "maleCount", |
||||||
|
"type": "Int", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "femaleCount", |
||||||
|
"type": "Int", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "anonymousCount", |
||||||
|
"type": "Int", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "incompleteMode", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "dataModelIdentifier", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "fileModelIdentifier", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,122 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "PlayerRegistration", |
||||||
|
"synchronizable": true, |
||||||
|
"sideStorable": true, |
||||||
|
"observable": true, |
||||||
|
"relationshipNames": ["teamRegistration"], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "teamRegistration", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"foreignKey": "TeamRegistration" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "firstName", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "lastName", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "licenceId", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "rank", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "paymentType", |
||||||
|
"type": "PlayerPaymentType", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "sex", |
||||||
|
"type": "PlayerSexType", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tournamentPlayed", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "points", |
||||||
|
"type": "Double", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "clubName", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "ligueName", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "assimilation", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "phoneNumber", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "email", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "birthdate", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "computedRank", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "0" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "source", |
||||||
|
"type": "PlayerRegistration.PlayerDataSource", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "hasArrived", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "coach", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "captain", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "registeredOnline", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,51 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Purchase", |
||||||
|
"synchronizable": true, |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "UInt64", |
||||||
|
"defaultValue": "0" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "user", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "\"\"", |
||||||
|
"encryption": "standard", |
||||||
|
"foreignKey": "CustomUser" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "purchaseDate", |
||||||
|
"type": "Date" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "productId", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "\"\"" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "quantity", |
||||||
|
"type": "Int", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "revocationDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "expirationDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil" |
||||||
|
} |
||||||
|
], |
||||||
|
"tokenExemptedMethods": [], |
||||||
|
"relationshipNames": [] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Round", |
||||||
|
"synchronizable": true, |
||||||
|
"sideStorable": true, |
||||||
|
"observable": true, |
||||||
|
"relationshipNames": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tournament", |
||||||
|
"type": "String", |
||||||
|
"foreignKey": "Tournament" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "index", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "parent", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "format", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"private": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "startDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageLoserBracket", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "loserBracketMode", |
||||||
|
"type": "LoserBracketMode", |
||||||
|
"defaultValue": ".automatic" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,118 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "TeamRegistration", |
||||||
|
"synchronizable": true, |
||||||
|
"sideStorable": true, |
||||||
|
"observable": true, |
||||||
|
"relationshipNames": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "tournament", |
||||||
|
"type": "String" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStage", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"foreignKey": "GroupStage*" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "registrationDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "callDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "bracketPosition", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStagePosition", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "comment", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "source", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "sourceValue", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "logo", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "walkOut", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "wildCardBracket", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "wildCardGroupStage", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "weight", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "0" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "lockedWeight", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "confirmationDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "qualified", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "finalRanking", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "pointsEarned", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "TeamScore", |
||||||
|
"synchronizable": true, |
||||||
|
"sideStorable": true, |
||||||
|
"observable": true, |
||||||
|
"relationshipNames": ["match"], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "match", |
||||||
|
"type": "String", |
||||||
|
"foreignKey": "Match*" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "teamRegistration", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"foreignKey": "TeamRegistration*" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "score", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "walkOut", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "luckyLoser", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,271 @@ |
|||||||
|
{ |
||||||
|
"models": [ |
||||||
|
{ |
||||||
|
"name": "Tournament", |
||||||
|
"synchronizable": true, |
||||||
|
"copyable": true, |
||||||
|
"observable": true, |
||||||
|
"relationshipNames": [], |
||||||
|
"properties": [ |
||||||
|
{ |
||||||
|
"name": "id", |
||||||
|
"type": "String", |
||||||
|
"defaultValue": "Store.randomId()" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "event", |
||||||
|
"type": "String", |
||||||
|
"optional": true, |
||||||
|
"foreignKey": "Event" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "name", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "startDate", |
||||||
|
"type": "Date" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "endDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "creationDate", |
||||||
|
"type": "Date", |
||||||
|
"private": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "isPrivate", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageFormat", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"private": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "roundFormat", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"private": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "loserRoundFormat", |
||||||
|
"type": "MatchFormat", |
||||||
|
"optional": true, |
||||||
|
"private": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageSortMode", |
||||||
|
"type": "GroupStageOrderingMode", |
||||||
|
"defaultValue": "GroupStageOrderingMode.snake" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageCount", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "rankSourceDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "dayDuration", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "teamCount", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "teamSorting", |
||||||
|
"type": "TeamSortingType", |
||||||
|
"defaultValue": "TeamSortingType.inscriptionDate" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "federalCategory", |
||||||
|
"type": "TournamentCategory", |
||||||
|
"defaultValue": "TournamentCategory.men" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "federalLevelCategory", |
||||||
|
"type": "TournamentLevel", |
||||||
|
"defaultValue": "TournamentLevel.unlisted" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "federalAgeCategory", |
||||||
|
"type": "FederalTournamentAge", |
||||||
|
"defaultValue": "FederalTournamentAge.unlisted" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "closedRegistrationDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "groupStageAdditionalQualified", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "courtCount", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "2" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "prioritizeClubMembers", |
||||||
|
"type": "Bool" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "qualifiedPerGroupStage", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "teamsPerGroupStage", |
||||||
|
"type": "Int" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "entryFee", |
||||||
|
"type": "Double", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "payment", |
||||||
|
"type": "TournamentPayment", |
||||||
|
"optional": true, |
||||||
|
"defaultValue": "nil", |
||||||
|
"encryption": "tournament_payment" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "additionalEstimationDuration", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "0" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "isDeleted", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "isCanceled", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false", |
||||||
|
"encryption": "tournament_iscanceled" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "publishTeams", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "publishSummons", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "publishGroupStages", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "publishBrackets", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "shouldVerifyGroupStage", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "shouldVerifyBracket", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "hideTeamsWeight", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "publishTournament", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "hidePointsEarned", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "publishRankings", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "loserBracketMode", |
||||||
|
"type": "LoserBracketMode", |
||||||
|
"defaultValue": ".automatic" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "initialSeedRound", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "0" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "initialSeedCount", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": "0" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "enableOnlineRegistration", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "false" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "registrationDateLimit", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "openingRegistrationDate", |
||||||
|
"type": "Date", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "waitingListLimit", |
||||||
|
"type": "Int", |
||||||
|
"optional": true |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "accountIsRequired", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "true" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "licenseIsRequired", |
||||||
|
"type": "Bool", |
||||||
|
"defaultValue": "true" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "minimumPlayerPerTeam", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": 2 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "maximumPlayerPerTeam", |
||||||
|
"type": "Int", |
||||||
|
"defaultValue": 2 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "information", |
||||||
|
"type": "String", |
||||||
|
"optional": true |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,566 @@ |
|||||||
|
import json |
||||||
|
import re |
||||||
|
import os |
||||||
|
from pathlib import Path |
||||||
|
from typing import Dict, List, Any |
||||||
|
import argparse |
||||||
|
import sys |
||||||
|
import logging |
||||||
|
from datetime import datetime |
||||||
|
import inflect |
||||||
|
|
||||||
|
class SwiftModelGenerator: |
||||||
|
def __init__(self, json_data: Dict[str, Any]): |
||||||
|
self.data = json_data |
||||||
|
self.pluralizer = inflect.engine() |
||||||
|
|
||||||
|
def generate_model(self, model_data: Dict[str, Any]) -> str: |
||||||
|
model_name = model_data["name"] |
||||||
|
is_sync = model_data.get("synchronizable", False) |
||||||
|
is_observable = model_data.get("observable", False) |
||||||
|
properties = model_data["properties"] |
||||||
|
|
||||||
|
# Get protocol specific configurations |
||||||
|
resource = self.make_resource_name(model_name) |
||||||
|
resource_name = model_data.get("resource_name", resource) |
||||||
|
token_exempted = model_data.get("tokenExemptedMethods", []) |
||||||
|
|
||||||
|
lines = ["// Generated by SwiftModelGenerator", "// Do not modify this file manually", ""] |
||||||
|
|
||||||
|
# Import statement |
||||||
|
lines.append("import Foundation") |
||||||
|
lines.append("import LeStorage") |
||||||
|
if is_observable: |
||||||
|
lines.append("import SwiftUI") |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Class declaration |
||||||
|
if is_observable: |
||||||
|
lines.append("@Observable") |
||||||
|
protocol = "SyncedStorable" if is_sync else "Storable" |
||||||
|
base_class = "SyncedModelObject" if is_sync else "BaseModelObject" |
||||||
|
lines.append(f"class Base{model_name}: {base_class}, {protocol} {{") |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Add SyncedStorable protocol requirements |
||||||
|
lines.extend(self._generate_protocol_requirements(resource_name, token_exempted)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Properties |
||||||
|
for prop in properties: |
||||||
|
swift_type = prop["type"] |
||||||
|
if prop.get("optional", False): |
||||||
|
swift_type += "?" |
||||||
|
default_value = prop.get("defaultValue", "nil" if prop.get("optional", False) else self._get_default_value(swift_type)) |
||||||
|
lines.append(f" var {prop['name']}: {swift_type} = {default_value}") |
||||||
|
|
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Add constructor |
||||||
|
lines.extend(self._generate_constructor(model_name, properties)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# CodingKeys |
||||||
|
lines.extend(self._generate_coding_keys(properties, is_observable, is_sync)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Encryption methods |
||||||
|
encrypted_props = [p for p in properties if "encryption" in p] |
||||||
|
if encrypted_props: |
||||||
|
lines.extend(self._generate_encryption_methods(properties)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Codable implementation |
||||||
|
lines.extend(self._generate_decoder(model_name, properties, is_observable, is_sync)) |
||||||
|
lines.append("") |
||||||
|
lines.extend(self._generate_encoder(properties, is_observable, is_sync)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Foreign Key convenience |
||||||
|
foreign_key_methods = self._generate_foreign_key_methods(properties) |
||||||
|
if foreign_key_methods: |
||||||
|
lines.extend(foreign_key_methods) |
||||||
|
# lines.append("") |
||||||
|
|
||||||
|
# Copy method |
||||||
|
lines.extend(self._generate_copy_method(model_name, properties)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
# Add relationships function |
||||||
|
lines.extend(self._generate_relationships(model_name, properties)) |
||||||
|
lines.append("") |
||||||
|
|
||||||
|
lines.append("}") |
||||||
|
return "\n".join(lines) |
||||||
|
|
||||||
|
def _generate_constructor(self, model_name: str, properties: List[Dict[str, Any]]) -> List[str]: |
||||||
|
"""Generate a constructor with all properties as parameters with default values.""" |
||||||
|
lines = [" init("] |
||||||
|
|
||||||
|
# Generate parameter list |
||||||
|
params = [] |
||||||
|
for prop in properties: |
||||||
|
name = prop['name'] |
||||||
|
type_name = prop['type'] |
||||||
|
is_optional = prop.get("optional", False) |
||||||
|
|
||||||
|
# Always include a default value |
||||||
|
default_value = prop.get("defaultValue") |
||||||
|
if default_value is None: |
||||||
|
if is_optional: |
||||||
|
default_value = "nil" |
||||||
|
else: |
||||||
|
default_value = self._get_default_value(type_name) |
||||||
|
|
||||||
|
# Format the parameter with its type and default value |
||||||
|
param = f" {name}: {type_name}" |
||||||
|
if is_optional: |
||||||
|
param += "?" |
||||||
|
param += f" = {default_value}" |
||||||
|
params.append(param) |
||||||
|
|
||||||
|
# Join parameters with commas |
||||||
|
lines.extend([f"{param}," for param in params[:-1]]) |
||||||
|
lines.append(f"{params[-1]}") # Last parameter without comma |
||||||
|
|
||||||
|
# Constructor body |
||||||
|
lines.extend([ |
||||||
|
" ) {", |
||||||
|
" super.init()", |
||||||
|
]) |
||||||
|
|
||||||
|
# Property assignments |
||||||
|
for prop in properties: |
||||||
|
name = prop['name'] |
||||||
|
lines.append(f" self.{name} = {name}") |
||||||
|
|
||||||
|
lines.append(" }") |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_foreign_key_methods(self, properties: List[Dict[str, Any]]) -> List[str]: |
||||||
|
lines = [] |
||||||
|
for prop in properties: |
||||||
|
if "foreignKey" in prop: |
||||||
|
foreign_key = prop["foreignKey"] |
||||||
|
prop_name = prop["name"] |
||||||
|
method_name = f"{prop_name}Value" |
||||||
|
is_optional = prop.get("optional", False) |
||||||
|
|
||||||
|
lines.extend([f" func {method_name}() -> {foreign_key.rstrip('*')}? {{"]) |
||||||
|
|
||||||
|
if is_optional: |
||||||
|
lines.extend([ |
||||||
|
f" guard let {prop_name} = self.{prop_name} else {{ return nil }}" |
||||||
|
]) |
||||||
|
|
||||||
|
if foreign_key.endswith("*"): |
||||||
|
foreign_key = foreign_key[:-1] # Remove the asterisk |
||||||
|
lines.extend([ |
||||||
|
f" return self.store?.findById({prop_name})" |
||||||
|
]) |
||||||
|
else: |
||||||
|
lines.extend([ |
||||||
|
f" return Store.main.findById({prop_name})" |
||||||
|
]) |
||||||
|
|
||||||
|
lines.extend([" }", ""]) # Close the method and add a blank line |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_coding_keys(self, properties: List[Dict[str, Any]], is_observable: bool, is_sync: bool = False) -> List[str]: |
||||||
|
lines = [" enum CodingKeys: String, CodingKey {"] |
||||||
|
for prop in properties: |
||||||
|
name = prop['name'] |
||||||
|
# Add underscore prefix to case name if observable, but keep the string value without underscore |
||||||
|
case_name = f"_{name}" if is_observable else name |
||||||
|
lines.append(f" case {case_name} = \"{name}\"") |
||||||
|
|
||||||
|
lines.append(" }") |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_encryption_methods(self, properties: List[Dict[str, Any]]) -> List[str]: |
||||||
|
lines = [] |
||||||
|
for prop in properties: |
||||||
|
if "encryption" in prop: |
||||||
|
name = prop['name'] |
||||||
|
enc_type = prop['encryption'] |
||||||
|
if enc_type == "tournament_payment": |
||||||
|
lines.extend([ |
||||||
|
f" private static func _decode{name.capitalize()}(container: KeyedDecodingContainer<CodingKeys>) throws -> TournamentPayment? {{", |
||||||
|
f" let data = try container.decodeIfPresent(Data.self, forKey: ._{name})", |
||||||
|
" ", |
||||||
|
" if let data {", |
||||||
|
" do {", |
||||||
|
" let decoded: String = try data.decryptData(pass: CryptoKey.pass.rawValue)", |
||||||
|
" let sequence = decoded.compactMap { NumberFormatter.standard.number(from: String($0))?.intValue }", |
||||||
|
" return TournamentPayment(rawValue: sequence[18])", |
||||||
|
" } catch {", |
||||||
|
" Logger.error(error)", |
||||||
|
" }", |
||||||
|
" }", |
||||||
|
" return nil", |
||||||
|
" }", |
||||||
|
"", |
||||||
|
f" private func _encode{name.capitalize()}(container: inout KeyedEncodingContainer<CodingKeys>) throws {{", |
||||||
|
f" guard let {name} else {{", |
||||||
|
f" try container.encodeNil(forKey: ._{name})", |
||||||
|
" return", |
||||||
|
" }", |
||||||
|
" ", |
||||||
|
" let max: Int = TournamentPayment.allCases.count", |
||||||
|
" var sequence = (1...18).map { _ in Int.random(in: (0..<max)) }", |
||||||
|
f" sequence.append({name}.rawValue)", |
||||||
|
" sequence.append(contentsOf: (1...13).map { _ in Int.random(in: (0..<max ))} )", |
||||||
|
"", |
||||||
|
" let stringCombo: [String] = sequence.map { $0.formatted() }", |
||||||
|
" let joined: String = stringCombo.joined(separator: \"\")", |
||||||
|
" if let data = joined.data(using: .utf8) {", |
||||||
|
" let encryped: Data = try data.encrypt(pass: CryptoKey.pass.rawValue)", |
||||||
|
f" try container.encodeIfPresent(encryped, forKey: ._{name})", |
||||||
|
" }", |
||||||
|
" }" |
||||||
|
]) |
||||||
|
elif enc_type == "tournament_iscanceled": |
||||||
|
lines.extend([ |
||||||
|
f" private static func _decode{name.capitalize()}(container: KeyedDecodingContainer<CodingKeys>) throws -> Bool {{", |
||||||
|
f" let data = try container.decodeIfPresent(Data.self, forKey: ._{name})", |
||||||
|
" if let data {", |
||||||
|
" do {", |
||||||
|
" let decoded: String = try data.decryptData(pass: CryptoKey.pass.rawValue)", |
||||||
|
" let sequence = decoded.compactMap { NumberFormatter.standard.number(from: String($0))?.intValue }", |
||||||
|
" return Bool.decodeInt(sequence[18])", |
||||||
|
" } catch {", |
||||||
|
" Logger.error(error)", |
||||||
|
" }", |
||||||
|
" }", |
||||||
|
" return false", |
||||||
|
" }", |
||||||
|
"", |
||||||
|
f" private func _encode{name.capitalize()}(container: inout KeyedEncodingContainer<CodingKeys>) throws {{", |
||||||
|
" let max: Int = 9", |
||||||
|
" var sequence = (1...18).map { _ in Int.random(in: (0...max)) }", |
||||||
|
f" sequence.append(self.{name}.encodedValue)", |
||||||
|
" sequence.append(contentsOf: (1...13).map { _ in Int.random(in: (0...max ))} )", |
||||||
|
" ", |
||||||
|
" let stringCombo: [String] = sequence.map { $0.formatted() }", |
||||||
|
" let joined: String = stringCombo.joined(separator: \"\")", |
||||||
|
" if let data = joined.data(using: .utf8) {", |
||||||
|
" let encryped: Data = try data.encrypt(pass: CryptoKey.pass.rawValue)", |
||||||
|
f" try container.encode(encryped, forKey: ._{name})", |
||||||
|
" }", |
||||||
|
" }" |
||||||
|
]) |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_decoder(self, model_name: str, properties: List[Dict[str, Any]], is_observable: bool, is_sync: bool = False) -> List[str]: |
||||||
|
lines = [" required init(from decoder: Decoder) throws {", |
||||||
|
" let container = try decoder.container(keyedBy: CodingKeys.self)"] |
||||||
|
|
||||||
|
for prop in properties: |
||||||
|
name = prop['name'] |
||||||
|
type_name = prop['type'] |
||||||
|
is_optional = prop.get("optional", False) |
||||||
|
default_value = prop.get("defaultValue", "nil" if is_optional else self._get_default_value(type_name)) |
||||||
|
option = prop.get("option") |
||||||
|
|
||||||
|
# Use the correct case reference based on observable flag |
||||||
|
case_ref = f"_{name}" if is_observable else name |
||||||
|
|
||||||
|
if "encryption" in prop: |
||||||
|
enc_type = prop['encryption'] |
||||||
|
if enc_type == "standard": |
||||||
|
if is_optional: |
||||||
|
lines.append(f" self.{name} = try container.decodeEncryptedIfPresent(key: .{case_ref})") |
||||||
|
else: |
||||||
|
lines.append(f" self.{name} = try container.decodeEncrypted(key: .{case_ref})") |
||||||
|
elif enc_type in ["tournament_payment", "tournament_iscanceled"]: |
||||||
|
lines.append(f" self.{name} = try Self._decode{name.capitalize()}(container: container)") |
||||||
|
else: |
||||||
|
# Handle Date with fractional option |
||||||
|
if type_name == "Date" and option == "fractional": |
||||||
|
if is_optional: |
||||||
|
lines.append(f" if let dateString = try container.decodeIfPresent(String.self, forKey: .{case_ref}) {{") |
||||||
|
lines.append(f" self.{name} = Date.iso8601FractionalFormatter.date(from: dateString)") |
||||||
|
lines.append(" } else {") |
||||||
|
lines.append(f" self.{name} = {default_value}") |
||||||
|
lines.append(" }") |
||||||
|
else: |
||||||
|
lines.append(f" let dateString = try container.decode(String.self, forKey: .{case_ref})") |
||||||
|
lines.append(f" self.{name} = Date.iso8601FractionalFormatter.date(from: dateString) ?? {default_value}") |
||||||
|
else: |
||||||
|
lines.append(f" self.{name} = try container.decodeIfPresent({type_name}.self, forKey: .{case_ref}) ?? {default_value}") |
||||||
|
|
||||||
|
lines.append(" try super.init(from: decoder)") |
||||||
|
|
||||||
|
lines.append(" }") |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_encoder(self, properties: List[Dict[str, Any]], is_observable: bool, is_sync: bool = False) -> List[str]: |
||||||
|
lines = [" override func encode(to encoder: Encoder) throws {", |
||||||
|
" var container = encoder.container(keyedBy: CodingKeys.self)"] |
||||||
|
|
||||||
|
for prop in properties: |
||||||
|
name = prop['name'] |
||||||
|
type_name = prop['type'] |
||||||
|
is_optional = prop.get('optional', False) |
||||||
|
option = prop.get("option") |
||||||
|
|
||||||
|
# Use the correct case reference based on observable flag |
||||||
|
case_ref = f"_{name}" if is_observable else name |
||||||
|
|
||||||
|
if "encryption" in prop: |
||||||
|
enc_type = prop['encryption'] |
||||||
|
if enc_type == "standard": |
||||||
|
if is_optional: |
||||||
|
lines.append(f" try container.encodeAndEncryptIfPresent(self.{name}?.data(using: .utf8), forKey: .{case_ref})") |
||||||
|
else: |
||||||
|
lines.append(f" try container.encodeAndEncryptIfPresent(self.{name}.data(using: .utf8), forKey: .{case_ref})") |
||||||
|
elif enc_type in ["tournament_payment", "tournament_iscanceled"]: |
||||||
|
lines.append(f" try _encode{name.capitalize()}(container: &container)") |
||||||
|
else: |
||||||
|
if type_name == "Date" and option == "fractional": |
||||||
|
if is_optional: |
||||||
|
lines.append(f" if let date = self.{name} {{") |
||||||
|
lines.append(f" try container.encode(Date.iso8601FractionalFormatter.string(from: date), forKey: .{case_ref})") |
||||||
|
lines.append(" } else {") |
||||||
|
lines.append(f" try container.encodeNil(forKey: .{case_ref})") |
||||||
|
lines.append(" }") |
||||||
|
else: |
||||||
|
lines.append(f" try container.encode(Date.iso8601FractionalFormatter.string(from: self.{name}), forKey: .{case_ref})") |
||||||
|
else: |
||||||
|
lines.append(f" try container.encode(self.{name}, forKey: .{case_ref})") |
||||||
|
|
||||||
|
lines.append(" try super.encode(to: encoder)") |
||||||
|
lines.append(" }") |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_copy_method(self, model_name: str, properties: List[Dict[str, Any]]) -> List[str]: |
||||||
|
|
||||||
|
model_variable = model_name.lower() |
||||||
|
lines = [f" func copy(from other: any Storable) {{"] |
||||||
|
lines.append(f" guard let {model_variable} = other as? Base{model_name} else {{ return }}") |
||||||
|
|
||||||
|
for prop in properties: |
||||||
|
name = prop['name'] |
||||||
|
lines.append(f" self.{name} = {model_variable}.{name}") |
||||||
|
|
||||||
|
lines.append(" }") |
||||||
|
return lines |
||||||
|
|
||||||
|
def _generate_protocol_requirements(self, resource_name: str, token_exempted: List[str]) -> List[str]: |
||||||
|
"""Generate the static functions required by SyncedStorable protocol.""" |
||||||
|
# Convert HTTP methods to proper format |
||||||
|
formatted_methods = [f".{method.lower()}" for method in token_exempted] |
||||||
|
methods_str = ", ".join(formatted_methods) if formatted_methods else "" |
||||||
|
|
||||||
|
return [ |
||||||
|
f" static func resourceName() -> String {{ return \"{resource_name}\" }}", |
||||||
|
f" static func tokenExemptedMethods() -> [HTTPMethod] {{ return [{methods_str}] }}", |
||||||
|
] |
||||||
|
|
||||||
|
def _generate_relationships(self, model_name, properties: List[Dict[str, Any]]) -> List[str]: |
||||||
|
# Find all properties with foreign keys |
||||||
|
foreign_key_props = [p for p in properties if "foreignKey" in p] |
||||||
|
|
||||||
|
if not foreign_key_props: |
||||||
|
# If no foreign keys, return empty array |
||||||
|
return [ |
||||||
|
" static func relationships() -> [Relationship] {", |
||||||
|
" return []", |
||||||
|
" }" |
||||||
|
] |
||||||
|
|
||||||
|
lines = [ |
||||||
|
" static func relationships() -> [Relationship] {", |
||||||
|
" return [" |
||||||
|
] |
||||||
|
|
||||||
|
# Generate relationship entries |
||||||
|
for prop in foreign_key_props: |
||||||
|
name = prop["name"] |
||||||
|
foreign_key = prop["foreignKey"].rstrip('*') # Remove asterisk if present |
||||||
|
lines.append(f" Relationship(type: {foreign_key}.self, keyPath: \\Base{model_name}.{name}),") |
||||||
|
|
||||||
|
# Close the array and function |
||||||
|
lines.extend([ |
||||||
|
" ]", |
||||||
|
" }" |
||||||
|
]) |
||||||
|
|
||||||
|
return lines |
||||||
|
|
||||||
|
def _get_default_value(self, type_name: str) -> str: |
||||||
|
"""Get default value for non-optional types""" |
||||||
|
if "String" in type_name: |
||||||
|
return "\"\"" |
||||||
|
elif "Int" in type_name: |
||||||
|
return "0" |
||||||
|
elif "Double" in type_name: |
||||||
|
return "0.0" |
||||||
|
elif "Bool" in type_name: |
||||||
|
return "false" |
||||||
|
elif "Date" in type_name: |
||||||
|
return "Date()" |
||||||
|
else: |
||||||
|
return "nil" # For any other type |
||||||
|
|
||||||
|
def get_output_filename(self, model_name: str) -> str: |
||||||
|
"""Generate the output filename for a model.""" |
||||||
|
return f"Base{model_name}.swift" |
||||||
|
|
||||||
|
def make_resource_name(self, text): |
||||||
|
p = inflect.engine() |
||||||
|
# Split camelCase into words |
||||||
|
words = re.findall('[A-Z][^A-Z]*', text) |
||||||
|
|
||||||
|
if not words: |
||||||
|
words = [text] |
||||||
|
|
||||||
|
words = [word.lower() for word in words] |
||||||
|
words[-1] = p.plural(words[-1]) |
||||||
|
return '-'.join(words) |
||||||
|
|
||||||
|
def process_directory(input_dir: str, output_dir: str, logger: logging.Logger, dry_run: bool = False) -> int: |
||||||
|
"""Process all JSON files in the input directory and generate Swift models.""" |
||||||
|
try: |
||||||
|
input_path = validate_directory(input_dir) |
||||||
|
if not dry_run: |
||||||
|
output_path = validate_directory(output_dir, create=True) |
||||||
|
|
||||||
|
json_files = list(input_path.glob("*.json")) |
||||||
|
if not json_files: |
||||||
|
logger.warning(f"No JSON files found in '{input_dir}'") |
||||||
|
return 0 |
||||||
|
|
||||||
|
logger.info(f"Found {len(json_files)} JSON files to process") |
||||||
|
successful_files = 0 |
||||||
|
|
||||||
|
for json_file in json_files: |
||||||
|
try: |
||||||
|
with open(json_file, 'r') as f: |
||||||
|
json_data = json.load(f) |
||||||
|
|
||||||
|
generator = SwiftModelGenerator(json_data) |
||||||
|
|
||||||
|
# Generate each model in the JSON file |
||||||
|
for model in json_data["models"]: |
||||||
|
model_name = model["name"] |
||||||
|
swift_code = generator.generate_model(model) |
||||||
|
|
||||||
|
if dry_run: |
||||||
|
logger.info(f"Would generate Base{model_name}.swift") |
||||||
|
continue |
||||||
|
|
||||||
|
# Write to output file with Base prefix |
||||||
|
output_file = output_path / generator.get_output_filename(model_name) |
||||||
|
with open(output_file, 'w') as f: |
||||||
|
f.write(swift_code) |
||||||
|
|
||||||
|
logger.info(f"Generated Base{model_name}.swift") |
||||||
|
|
||||||
|
successful_files += 1 |
||||||
|
|
||||||
|
except json.JSONDecodeError as e: |
||||||
|
logger.error(f"Error parsing {json_file.name}: {e}") |
||||||
|
except KeyError as e: |
||||||
|
logger.error(f"Missing required key in {json_file.name}: {e}") |
||||||
|
except Exception as e: |
||||||
|
logger.error(f"Error processing {json_file.name}: {e}") |
||||||
|
|
||||||
|
return successful_files |
||||||
|
|
||||||
|
except Exception as e: |
||||||
|
logger.error(f"Fatal error: {e}") |
||||||
|
return 0 |
||||||
|
|
||||||
|
|
||||||
|
def setup_logging(verbose: bool) -> logging.Logger: |
||||||
|
"""Configure logging based on verbosity level.""" |
||||||
|
logger = logging.getLogger('SwiftModelGenerator') |
||||||
|
handler = logging.StreamHandler() |
||||||
|
|
||||||
|
if verbose: |
||||||
|
logger.setLevel(logging.DEBUG) |
||||||
|
handler.setFormatter(logging.Formatter( |
||||||
|
'%(asctime)s - %(levelname)s - %(message)s' |
||||||
|
)) |
||||||
|
else: |
||||||
|
logger.setLevel(logging.INFO) |
||||||
|
handler.setFormatter(logging.Formatter('%(message)s')) |
||||||
|
|
||||||
|
logger.addHandler(handler) |
||||||
|
return logger |
||||||
|
|
||||||
|
def validate_directory(path: str, create: bool = False) -> Path: |
||||||
|
"""Validate and optionally create a directory.""" |
||||||
|
dir_path = Path(path) |
||||||
|
if dir_path.exists(): |
||||||
|
if not dir_path.is_dir(): |
||||||
|
raise ValueError(f"'{path}' exists but is not a directory") |
||||||
|
elif create: |
||||||
|
dir_path.mkdir(parents=True) |
||||||
|
else: |
||||||
|
raise ValueError(f"Directory '{path}' does not exist") |
||||||
|
return dir_path |
||||||
|
|
||||||
|
def main(): |
||||||
|
parser = argparse.ArgumentParser( |
||||||
|
description="Generate Swift model classes from JSON definitions", |
||||||
|
epilog="Example: %(prog)s -i ./model_definitions -o ../MyProject/Models" |
||||||
|
) |
||||||
|
|
||||||
|
parser.add_argument( |
||||||
|
"-i", "--input-dir", |
||||||
|
required=True, |
||||||
|
help="Directory containing JSON model definitions" |
||||||
|
) |
||||||
|
|
||||||
|
parser.add_argument( |
||||||
|
"-o", "--output-dir", |
||||||
|
required=True, |
||||||
|
help="Directory where Swift files will be generated" |
||||||
|
) |
||||||
|
|
||||||
|
parser.add_argument( |
||||||
|
"-v", "--verbose", |
||||||
|
action="store_true", |
||||||
|
help="Enable verbose output" |
||||||
|
) |
||||||
|
|
||||||
|
parser.add_argument( |
||||||
|
"--dry-run", |
||||||
|
action="store_true", |
||||||
|
help="Show what would be generated without actually creating files" |
||||||
|
) |
||||||
|
|
||||||
|
parser.add_argument( |
||||||
|
"--version", |
||||||
|
action="version", |
||||||
|
version="%(prog)s 1.0.0" |
||||||
|
) |
||||||
|
|
||||||
|
args = parser.parse_args() |
||||||
|
|
||||||
|
# Setup logging |
||||||
|
logger = setup_logging(args.verbose) |
||||||
|
|
||||||
|
# Process the directories |
||||||
|
start_time = datetime.now() |
||||||
|
logger.info("Starting model generation...") |
||||||
|
|
||||||
|
successful_files = process_directory( |
||||||
|
args.input_dir, |
||||||
|
args.output_dir, |
||||||
|
logger, |
||||||
|
args.dry_run |
||||||
|
) |
||||||
|
|
||||||
|
# Report results |
||||||
|
duration = datetime.now() - start_time |
||||||
|
logger.info(f"\nGeneration completed in {duration.total_seconds():.2f} seconds") |
||||||
|
logger.info(f"Successfully processed {successful_files} files") |
||||||
|
|
||||||
|
# Return appropriate exit code |
||||||
|
sys.exit(0 if successful_files > 0 else 1) |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
main() |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
// |
||||||
|
// PlayerPaymentType.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 11/02/2025. |
||||||
|
// |
||||||
|
|
||||||
|
import Foundation |
||||||
|
|
||||||
|
enum PlayerPaymentType: Int, CaseIterable, Identifiable, Codable { |
||||||
|
|
||||||
|
init?(rawValue: Int?) { |
||||||
|
guard let value = rawValue else { return nil } |
||||||
|
self.init(rawValue: value) |
||||||
|
} |
||||||
|
|
||||||
|
var id: Self { |
||||||
|
self |
||||||
|
} |
||||||
|
|
||||||
|
case cash = 0 |
||||||
|
case lydia = 1 |
||||||
|
case gift = 2 |
||||||
|
case check = 3 |
||||||
|
case paylib = 4 |
||||||
|
case bankTransfer = 5 |
||||||
|
case clubHouse = 6 |
||||||
|
case creditCard = 7 |
||||||
|
case forfeit = 8 |
||||||
|
|
||||||
|
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { |
||||||
|
switch self { |
||||||
|
case .check: |
||||||
|
return "Chèque" |
||||||
|
case .cash: |
||||||
|
return "Cash" |
||||||
|
case .lydia: |
||||||
|
return "Lydia" |
||||||
|
case .paylib: |
||||||
|
return "Paylib" |
||||||
|
case .bankTransfer: |
||||||
|
return "Virement" |
||||||
|
case .clubHouse: |
||||||
|
return "Clubhouse" |
||||||
|
case .creditCard: |
||||||
|
return "CB" |
||||||
|
case .forfeit: |
||||||
|
return "Forfait" |
||||||
|
case .gift: |
||||||
|
return "Offert" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@ |
|||||||
|
// |
||||||
|
// TournamentLibrary.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 11/11/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import Foundation |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
class TournamentLibrary { |
||||||
|
|
||||||
|
static let shared: TournamentLibrary = TournamentLibrary() |
||||||
|
|
||||||
|
fileprivate var _stores: [String : TournamentStore] = [:] |
||||||
|
|
||||||
|
func store(tournamentId: String) -> TournamentStore? { |
||||||
|
guard let tournament = DataStore.shared.tournaments.first(where: { $0.id == tournamentId }) else { return nil } |
||||||
|
|
||||||
|
if let store = self._stores[tournamentId] { |
||||||
|
return store |
||||||
|
} |
||||||
|
let store = StoreCenter.main.store(identifier: tournamentId) |
||||||
|
let tournamentStore = TournamentStore(store: store) |
||||||
|
self._stores[tournamentId] = tournamentStore |
||||||
|
return tournamentStore |
||||||
|
} |
||||||
|
|
||||||
|
func reset() { |
||||||
|
self._stores.removeAll() |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,250 +0,0 @@ |
|||||||
// |
|
||||||
// User.swift |
|
||||||
// PadelClub |
|
||||||
// |
|
||||||
// Created by Laurent Morvillier on 21/02/2024. |
|
||||||
// |
|
||||||
|
|
||||||
import Foundation |
|
||||||
import LeStorage |
|
||||||
|
|
||||||
enum UserRight: Int, Codable { |
|
||||||
case none = 0 |
|
||||||
case edition = 1 |
|
||||||
case creation = 2 |
|
||||||
} |
|
||||||
|
|
||||||
@Observable |
|
||||||
class User: ModelObject, UserBase, Storable { |
|
||||||
|
|
||||||
static func resourceName() -> String { "users" } |
|
||||||
static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] } |
|
||||||
static func filterByStoreIdentifier() -> Bool { return false } |
|
||||||
static var relationshipNames: [String] = [] |
|
||||||
|
|
||||||
public var id: String = Store.randomId() |
|
||||||
public var username: String |
|
||||||
public var email: String |
|
||||||
var clubs: [String] = [] |
|
||||||
var umpireCode: String? |
|
||||||
var licenceId: String? |
|
||||||
var firstName: String |
|
||||||
var lastName: String |
|
||||||
var phone: String? |
|
||||||
var country: String? |
|
||||||
|
|
||||||
var summonsMessageBody : String? = nil |
|
||||||
var summonsMessageSignature: String? = nil |
|
||||||
var summonsAvailablePaymentMethods: String? = nil |
|
||||||
var summonsDisplayFormat: Bool = false |
|
||||||
var summonsDisplayEntryFee: Bool = false |
|
||||||
var summonsUseFullCustomMessage: Bool = false |
|
||||||
var matchFormatsDefaultDuration: [MatchFormat: Int]? = nil |
|
||||||
var bracketMatchFormatPreference: MatchFormat? |
|
||||||
var groupStageMatchFormatPreference: MatchFormat? |
|
||||||
var loserBracketMatchFormatPreference: MatchFormat? |
|
||||||
var loserBracketMode: LoserBracketMode = .automatic |
|
||||||
|
|
||||||
var deviceId: String? |
|
||||||
|
|
||||||
init(username: String, email: String, firstName: String, lastName: String, phone: String?, country: String?, loserBracketMode: LoserBracketMode = .automatic) { |
|
||||||
self.username = username |
|
||||||
self.firstName = firstName |
|
||||||
self.lastName = lastName |
|
||||||
self.email = email |
|
||||||
self.phone = phone |
|
||||||
self.country = country |
|
||||||
self.loserBracketMode = loserBracketMode |
|
||||||
} |
|
||||||
|
|
||||||
public func uuid() throws -> UUID { |
|
||||||
if let uuid = UUID(uuidString: self.id) { |
|
||||||
return uuid |
|
||||||
} |
|
||||||
throw UUIDError.cantConvertString(string: self.id) |
|
||||||
} |
|
||||||
|
|
||||||
func currentPlayerData() -> ImportedPlayer? { |
|
||||||
guard let licenceId else { return nil } |
|
||||||
let federalContext = PersistenceController.shared.localContainer.viewContext |
|
||||||
let fetchRequest = ImportedPlayer.fetchRequest() |
|
||||||
let predicate = NSPredicate(format: "license == %@", licenceId) |
|
||||||
fetchRequest.predicate = predicate |
|
||||||
return try? federalContext.fetch(fetchRequest).first |
|
||||||
} |
|
||||||
|
|
||||||
func defaultSignature() -> String { |
|
||||||
return "Sportivement,\n\(firstName) \(lastName), votre JAP." |
|
||||||
} |
|
||||||
|
|
||||||
func fullName() -> String? { |
|
||||||
guard firstName.isEmpty == false && lastName.isEmpty == false else { |
|
||||||
return nil |
|
||||||
} |
|
||||||
return "\(firstName) \(lastName)" |
|
||||||
} |
|
||||||
|
|
||||||
func hasTenupClubs() -> Bool { |
|
||||||
self.clubsObjects().filter({ $0.code != nil }).isEmpty == false |
|
||||||
} |
|
||||||
|
|
||||||
func hasFavoriteClubsAndCreatedClubs() -> Bool { |
|
||||||
clubsObjects(includeCreated: true).isEmpty == false |
|
||||||
} |
|
||||||
|
|
||||||
func setUserClub(_ userClub: Club) { |
|
||||||
self.clubs.insert(userClub.id, at: 0) |
|
||||||
} |
|
||||||
|
|
||||||
func clubsObjects(includeCreated: Bool = false) -> [Club] { |
|
||||||
return DataStore.shared.clubs.filter({ (includeCreated && $0.creator == id) || clubs.contains($0.id) }) |
|
||||||
} |
|
||||||
|
|
||||||
func createdClubsObjectsNotFavorite() -> [Club] { |
|
||||||
return DataStore.shared.clubs.filter({ ($0.creator == id) && clubs.contains($0.id) == false }) |
|
||||||
} |
|
||||||
|
|
||||||
func saveMatchFormatsDefaultDuration(_ matchFormat: MatchFormat, estimatedDuration: Int) { |
|
||||||
if estimatedDuration == matchFormat.defaultEstimatedDuration { |
|
||||||
matchFormatsDefaultDuration?.removeValue(forKey: matchFormat) |
|
||||||
} else { |
|
||||||
matchFormatsDefaultDuration = matchFormatsDefaultDuration ?? [MatchFormat: Int]() |
|
||||||
matchFormatsDefaultDuration?[matchFormat] = estimatedDuration |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
func addClub(_ club: Club) { |
|
||||||
if !self.clubs.contains(where: { $0.id == club.id }) { |
|
||||||
self.clubs.append(club.id) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey { |
|
||||||
case _id = "id" |
|
||||||
case _username = "username" |
|
||||||
case _email = "email" |
|
||||||
case _clubs = "clubs" |
|
||||||
case _umpireCode = "umpireCode" |
|
||||||
case _licenceId = "licenceId" |
|
||||||
case _firstName = "firstName" |
|
||||||
case _lastName = "lastName" |
|
||||||
case _phone = "phone" |
|
||||||
case _country = "country" |
|
||||||
case _summonsMessageBody = "summonsMessageBody" |
|
||||||
case _summonsMessageSignature = "summonsMessageSignature" |
|
||||||
case _summonsAvailablePaymentMethods = "summonsAvailablePaymentMethods" |
|
||||||
case _summonsDisplayFormat = "summonsDisplayFormat" |
|
||||||
case _summonsDisplayEntryFee = "summonsDisplayEntryFee" |
|
||||||
case _summonsUseFullCustomMessage = "summonsUseFullCustomMessage" |
|
||||||
case _matchFormatsDefaultDuration = "matchFormatsDefaultDuration" |
|
||||||
case _bracketMatchFormatPreference = "bracketMatchFormatPreference" |
|
||||||
case _groupStageMatchFormatPreference = "groupStageMatchFormatPreference" |
|
||||||
case _loserBracketMatchFormatPreference = "loserBracketMatchFormatPreference" |
|
||||||
case _deviceId = "deviceId" |
|
||||||
case _loserBracketMode = "loserBracketMode" |
|
||||||
} |
|
||||||
|
|
||||||
public required init(from decoder: Decoder) throws { |
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self) |
|
||||||
|
|
||||||
// Required properties |
|
||||||
id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId() |
|
||||||
username = try container.decode(String.self, forKey: ._username) |
|
||||||
email = try container.decode(String.self, forKey: ._email) |
|
||||||
firstName = try container.decode(String.self, forKey: ._firstName) |
|
||||||
lastName = try container.decode(String.self, forKey: ._lastName) |
|
||||||
|
|
||||||
// Optional properties |
|
||||||
clubs = try container.decodeIfPresent([String].self, forKey: ._clubs) ?? [] |
|
||||||
umpireCode = try container.decodeIfPresent(String.self, forKey: ._umpireCode) |
|
||||||
licenceId = try container.decodeIfPresent(String.self, forKey: ._licenceId) |
|
||||||
phone = try container.decodeIfPresent(String.self, forKey: ._phone) |
|
||||||
country = try container.decodeIfPresent(String.self, forKey: ._country) |
|
||||||
|
|
||||||
// Summons-related properties |
|
||||||
summonsMessageBody = try container.decodeIfPresent(String.self, forKey: ._summonsMessageBody) |
|
||||||
summonsMessageSignature = try container.decodeIfPresent(String.self, forKey: ._summonsMessageSignature) |
|
||||||
summonsAvailablePaymentMethods = try container.decodeIfPresent(String.self, forKey: ._summonsAvailablePaymentMethods) |
|
||||||
summonsDisplayFormat = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayFormat) ?? false |
|
||||||
summonsDisplayEntryFee = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayEntryFee) ?? false |
|
||||||
summonsUseFullCustomMessage = try container.decodeIfPresent(Bool.self, forKey: ._summonsUseFullCustomMessage) ?? false |
|
||||||
|
|
||||||
// Match-related properties |
|
||||||
matchFormatsDefaultDuration = try container.decodeIfPresent([MatchFormat: Int].self, forKey: ._matchFormatsDefaultDuration) |
|
||||||
bracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._bracketMatchFormatPreference) |
|
||||||
groupStageMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._groupStageMatchFormatPreference) |
|
||||||
loserBracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._loserBracketMatchFormatPreference) |
|
||||||
loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic |
|
||||||
} |
|
||||||
|
|
||||||
func encode(to encoder: Encoder) throws { |
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self) |
|
||||||
|
|
||||||
try container.encode(id, forKey: ._id) |
|
||||||
try container.encode(username, forKey: ._username) |
|
||||||
try container.encode(email, forKey: ._email) |
|
||||||
try container.encode(clubs, forKey: ._clubs) |
|
||||||
|
|
||||||
try container.encode(umpireCode, forKey: ._umpireCode) |
|
||||||
try container.encode(licenceId, forKey: ._licenceId) |
|
||||||
try container.encode(firstName, forKey: ._firstName) |
|
||||||
try container.encode(lastName, forKey: ._lastName) |
|
||||||
try container.encode(phone, forKey: ._phone) |
|
||||||
try container.encode(country, forKey: ._country) |
|
||||||
try container.encode(summonsMessageBody, forKey: ._summonsMessageBody) |
|
||||||
try container.encode(summonsMessageSignature, forKey: ._summonsMessageSignature) |
|
||||||
try container.encode(summonsAvailablePaymentMethods, forKey: ._summonsAvailablePaymentMethods) |
|
||||||
try container.encode(summonsDisplayFormat, forKey: ._summonsDisplayFormat) |
|
||||||
try container.encode(summonsDisplayEntryFee, forKey: ._summonsDisplayEntryFee) |
|
||||||
try container.encode(summonsUseFullCustomMessage, forKey: ._summonsUseFullCustomMessage) |
|
||||||
|
|
||||||
try container.encode(matchFormatsDefaultDuration, forKey: ._matchFormatsDefaultDuration) |
|
||||||
try container.encode(bracketMatchFormatPreference, forKey: ._bracketMatchFormatPreference) |
|
||||||
try container.encode(groupStageMatchFormatPreference, forKey: ._groupStageMatchFormatPreference) |
|
||||||
try container.encode(loserBracketMatchFormatPreference, forKey: ._loserBracketMatchFormatPreference) |
|
||||||
try container.encode(deviceId, forKey: ._deviceId) |
|
||||||
|
|
||||||
try container.encode(loserBracketMode, forKey: ._loserBracketMode) |
|
||||||
} |
|
||||||
|
|
||||||
static func placeHolder() -> User { |
|
||||||
return User(username: "", email: "", firstName: "", lastName: "", phone: nil, country: nil) |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
class UserCreationForm: User, UserPasswordBase { |
|
||||||
|
|
||||||
init(user: User, username: String, password: String, firstName: String, lastName: String, email: String, phone: String?, country: String?) { |
|
||||||
self.password = password |
|
||||||
super.init(username: username, email: email, firstName: firstName, lastName: lastName, phone: phone, country: country) |
|
||||||
|
|
||||||
self.summonsMessageBody = user.summonsMessageBody |
|
||||||
self.summonsMessageSignature = user.summonsMessageSignature |
|
||||||
self.summonsAvailablePaymentMethods = user.summonsAvailablePaymentMethods |
|
||||||
self.summonsDisplayFormat = user.summonsDisplayFormat |
|
||||||
self.summonsDisplayEntryFee = user.summonsDisplayEntryFee |
|
||||||
self.summonsUseFullCustomMessage = user.summonsUseFullCustomMessage |
|
||||||
self.matchFormatsDefaultDuration = user.matchFormatsDefaultDuration |
|
||||||
self.bracketMatchFormatPreference = user.bracketMatchFormatPreference |
|
||||||
self.groupStageMatchFormatPreference = user.groupStageMatchFormatPreference |
|
||||||
self.loserBracketMatchFormatPreference = user.loserBracketMatchFormatPreference |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
required init(from decoder: Decoder) throws { |
|
||||||
fatalError("init(from:) has not been implemented") |
|
||||||
} |
|
||||||
|
|
||||||
public var password: String |
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey { |
|
||||||
case password |
|
||||||
} |
|
||||||
|
|
||||||
override func encode(to encoder: Encoder) throws { |
|
||||||
try super.encode(to: encoder) |
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self) |
|
||||||
try container.encode(self.password, forKey: .password) |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,45 @@ |
|||||||
|
// |
||||||
|
// NetworkStatusView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 25/10/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
struct NetworkStatusView: View { |
||||||
|
|
||||||
|
@State private var isConnected = false |
||||||
|
@State private var timer: Timer? |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
Image(systemName: self.isConnected ? "network" : "network.slash") |
||||||
|
.resizable() |
||||||
|
.scaledToFit() |
||||||
|
|
||||||
|
.onAppear { |
||||||
|
self._defineStatus() |
||||||
|
// Start the timer when the view appears |
||||||
|
timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in |
||||||
|
withAnimation { |
||||||
|
self._defineStatus() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
.onDisappear { |
||||||
|
// Clean up timer when view disappears |
||||||
|
timer?.invalidate() |
||||||
|
timer = nil |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fileprivate func _defineStatus() { |
||||||
|
self.isConnected = LeStorage.NetworkMonitor.shared.isConnected |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#Preview { |
||||||
|
NetworkStatusView() |
||||||
|
} |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue