Enforce user locks for AI updates
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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 }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user