43 lines
1.2 KiB
Swift
43 lines
1.2 KiB
Swift
import Foundation
|
|
|
|
public enum SongProjectUpdateScope: String, CaseIterable, Codable, Equatable, Hashable, Sendable {
|
|
case duration
|
|
case genres
|
|
case instruments
|
|
case vocals
|
|
case languages
|
|
case lyrics
|
|
case structure
|
|
case arrangement
|
|
case musicalParameters
|
|
case emotionalArc
|
|
case productionDirections
|
|
case sunoOutput
|
|
}
|
|
|
|
public struct SongProjectUserLocks: Codable, Equatable, Sendable {
|
|
public var scopes: [SongProjectUpdateScope]
|
|
|
|
public init(scopes: [SongProjectUpdateScope] = []) {
|
|
self.scopes = Self.uniqueScopes(scopes)
|
|
}
|
|
|
|
public func contains(_ scope: SongProjectUpdateScope) -> Bool {
|
|
scopes.contains(scope)
|
|
}
|
|
|
|
public mutating func insert(_ scope: SongProjectUpdateScope) {
|
|
guard !contains(scope) else { return }
|
|
scopes.append(scope)
|
|
}
|
|
|
|
public mutating func remove(_ scope: SongProjectUpdateScope) {
|
|
scopes.removeAll { $0 == scope }
|
|
}
|
|
|
|
private static func uniqueScopes(_ scopes: [SongProjectUpdateScope]) -> [SongProjectUpdateScope] {
|
|
var seen = Set<SongProjectUpdateScope>()
|
|
return scopes.filter { seen.insert($0).inserted }
|
|
}
|
|
}
|