Rename DynamicObjectID -> PersistentID

This commit is contained in:
John Estropia
2026-07-27 15:23:39 +09:00
parent 13093d72d4
commit 16c5bb3e15
23 changed files with 146 additions and 120 deletions
+8 -8
View File
@@ -55,7 +55,7 @@ public nonisolated final class AsynchronousDataTransaction: BaseDataTransaction
`Result<T>.success` indicates that the transaction succeeded, either because the save succeeded or because there were no changes to save. The associated `userInfo` is the value returned from the transaction closure.
`Result<T>.failure` indicates that the transaction either failed or was cancelled. The associated object for this value is a `CoreStoreError` enum value.
*/
public typealias Result<UserInfoType> = Swift.Result<UserInfoType, CoreStoreError>
public typealias Result<UserInfoType> = Swift::Result<UserInfoType, CoreStoreError>
// MARK: -
@@ -80,14 +80,14 @@ public nonisolated final class AsynchronousDataTransaction: BaseDataTransaction
}
/**
Returns an editable proxy of the object with the specified `DynamicObjectID`.
Returns an editable proxy of the object with the specified `PersistentID`.
- parameter into: an `Into` clause specifying the entity type
- parameter persistentID: the `DynamicObjectID` for the object to be edited
- parameter persistentID: the `PersistentID` for the object to be edited
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
*/
public override func edit<O>(
_ persistentID: DynamicObjectID<O>?
_ persistentID: PersistentID<O>?
) -> O? {
Internals.assert(
@@ -117,15 +117,15 @@ public nonisolated final class AsynchronousDataTransaction: BaseDataTransaction
}
/**
Returns an editable proxy of the object with the specified `DynamicObjectID`.
Returns an editable proxy of the object with the specified `PersistentID`.
- parameter into: an `Into` clause specifying the entity type
- parameter persistentID: the `DynamicObjectID` for the object to be edited
- parameter persistentID: the `PersistentID` for the object to be edited
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
*/
public override func edit<O>(
_ into: Into<O>,
_ persistentID: DynamicObjectID<O>
_ persistentID: PersistentID<O>
) -> O? {
Internals.assert(
@@ -163,7 +163,7 @@ public nonisolated final class AsynchronousDataTransaction: BaseDataTransaction
*/
public override func delete<O: DynamicObject, S: Sequence>(
persistentIDs: S
) where S.Iterator.Element == DynamicObjectID<O> {
) where S.Iterator.Element == PersistentID<O> {
Internals.assert(
!self.isCommitted,
+5 -5
View File
@@ -113,11 +113,11 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
/**
Fetches the `DynamicObject` instance in the transaction's context from an `NSManagedObjectID`.
- parameter persistentID: the `DynamicObjectID` for the object
- parameter persistentID: the `PersistentID` for the object
- returns: the `DynamicObject` instance if the object exists in the transaction, or `nil` if not found.
*/
public func fetchExisting<O: DynamicObject>(
_ persistentID: DynamicObjectID<O>
_ persistentID: PersistentID<O>
) -> O? {
return self.context.fetchExisting(persistentID.managedObjectID)
@@ -150,14 +150,14 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
}
/**
Fetches the `DynamicObject` instances in the transaction's context from a list of `DynamicObjectID`.
Fetches the `DynamicObject` instances in the transaction's context from a list of `PersistentID`.
- parameter objectIDs: the `DynamicObjectID` array for the objects
- parameter objectIDs: the `PersistentID` array for the objects
- returns: the `DynamicObject` array for objects that exists in the transaction
*/
public func fetchExisting<O: DynamicObject, S: Sequence>(
_ objectIDs: S
) -> [O] where S.Iterator.Element == DynamicObjectID<O> {
) -> [O] where S.Iterator.Element == PersistentID<O> {
return self.context.fetchExisting(objectIDs)
}
+8 -11
View File
@@ -26,9 +26,6 @@
import Foundation
import CoreData
// MARK: - BaseDataTransaction
/**
The `BaseDataTransaction` is an abstract interface for `NSManagedObject` creates, updates, and deletes. All `BaseDataTransaction` subclasses manage a private `NSManagedObjectContext` which are direct children of the `NSPersistentStoreCoordinator`'s root `NSManagedObjectContext`. This means that all updates are saved first to the persistent store, and then propagated up to the read-only `NSManagedObjectContext`.
*/
@@ -118,11 +115,11 @@ public /*abstract*/ class BaseDataTransaction {
/**
Returns an editable proxy of a specified `NSManagedObject` or `CoreStoreObject`.
- parameter persistentID: the `DynamicObjectID` pertaining ot the `NSManagedObject` or `CoreStoreObject` type to be edited
- parameter persistentID: the `PersistentID` pertaining ot the `NSManagedObject` or `CoreStoreObject` type to be edited
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
*/
public func edit<O>(
_ persistentID: DynamicObjectID<O>?
_ persistentID: PersistentID<O>?
) -> O? {
Internals.assert(
@@ -158,15 +155,15 @@ public /*abstract*/ class BaseDataTransaction {
}
/**
Returns an editable proxy of the object with the specified `DynamicObjectID`.
Returns an editable proxy of the object with the specified `PersistentID`.
- parameter into: an `Into` clause specifying the entity type
- parameter persistentID: the `DynamicObjectID` for the object to be edited
- parameter persistentID: the `PersistentID` for the object to be edited
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
*/
public func edit<O>(
_ into: Into<O>,
_ persistentID: DynamicObjectID<O>
_ persistentID: PersistentID<O>
) -> O? {
Internals.assert(
@@ -206,13 +203,13 @@ public /*abstract*/ class BaseDataTransaction {
}
/**
Deletes the objects with the specified `DynamicObjectID`s.
Deletes the objects with the specified `PersistentID`s.
- parameter persistentIDs: the `DynamicObjectID`s of the objects to delete
- parameter persistentIDs: the `PersistentID`s of the objects to delete
*/
public func delete<O: DynamicObject, S: Sequence>(
persistentIDs: S
) where S.Iterator.Element == DynamicObjectID<O> {
) where S.Iterator.Element == PersistentID<O> {
Internals.assert(
self.isRunningInAllowedQueue(),
+1 -1
View File
@@ -100,6 +100,6 @@ extension Internals {
lineNumber: lineNumber,
functionName: functionName
)
Swift.fatalError(message, file: fileName, line: UInt(lineNumber))
Swift::fatalError(message, file: fileName, line: UInt(lineNumber))
}
}
+1 -1
View File
@@ -124,6 +124,6 @@ extension CoreStoreLogger {
functionName: StaticString
) {
Swift.fatalError(message, file: fileName, line: UInt(lineNumber))
Swift::fatalError(message, file: fileName, line: UInt(lineNumber))
}
}
+5 -5
View File
@@ -49,11 +49,11 @@ extension DataStack: FetchableSource, QueryableSource {
/**
Fetches the `DynamicObject` instance in the `DataStack`'s context from an `NSManagedObjectID`.
- parameter persistentID: the `DynamicObjectID` for the object
- parameter persistentID: the `PersistentID` for the object
- returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found.
*/
public func fetchExisting<O: DynamicObject>(
_ persistentID: DynamicObjectID<O>
_ persistentID: PersistentID<O>
) -> O? {
return self.mainContext.fetchExisting(persistentID.managedObjectID)
@@ -86,14 +86,14 @@ extension DataStack: FetchableSource, QueryableSource {
}
/**
Fetches the `DynamicObject` instances in the `DataStack`'s context from a list of `DynamicObjectID`.
Fetches the `DynamicObject` instances in the `DataStack`'s context from a list of `PersistentID`.
- parameter objectIDs: the `DynamicObjectID` array for the objects
- parameter objectIDs: the `PersistentID` array for the objects
- returns: the `DynamicObject` array for objects that exists in the `DataStack`
*/
public func fetchExisting<O: DynamicObject, S: Sequence>(
_ objectIDs: S
) -> [O] where S.Iterator.Element == DynamicObjectID<O> {
) -> [O] where S.Iterator.Element == PersistentID<O> {
return self.mainContext.fetchExisting(objectIDs)
}
+36 -36
View File
@@ -55,29 +55,29 @@ public final class DefaultLogger: CoreStoreLogger {
functionName: StaticString
) {
#if DEBUG
let icon: String
let levelString: String
switch level {
case .trace:
icon = "🔹"
levelString = "Trace"
case .notice:
icon = "🔸"
levelString = "Notice"
case .warning:
icon = "⚠️"
levelString = "Warning"
case .fatal:
icon = ""
levelString = "Fatal"
}
Swift.print("\(icon) [CoreStore: \(levelString)] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
#endif
#if DEBUG
let icon: String
let levelString: String
switch level {
case .trace:
icon = "🔹"
levelString = "Trace"
case .notice:
icon = "🔸"
levelString = "Notice"
case .warning:
icon = "⚠️"
levelString = "Warning"
case .fatal:
icon = ""
levelString = "Fatal"
}
Swift::print("\(icon) [CoreStore: \(levelString)] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
#endif
}
/**
@@ -97,9 +97,9 @@ public final class DefaultLogger: CoreStoreLogger {
functionName: StaticString
) {
#if DEBUG
Swift.print("⚠️ [CoreStore: Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n \(error)\n")
#endif
#if DEBUG
Swift::print("⚠️ [CoreStore: Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n \(error)\n")
#endif
}
/**
@@ -119,14 +119,14 @@ public final class DefaultLogger: CoreStoreLogger {
functionName: StaticString
) {
#if DEBUG
if condition() {
return
}
Swift.print("❗ [CoreStore: Assertion Failure] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
Swift.fatalError(file: fileName, line: UInt(lineNumber))
#endif
#if DEBUG
if condition() {
return
}
Swift::print("❗ [CoreStore: Assertion Failure] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
Swift::fatalError(file: fileName, line: UInt(lineNumber))
#endif
}
/**
@@ -145,7 +145,7 @@ public final class DefaultLogger: CoreStoreLogger {
functionName: StaticString
) {
Swift.print("❗ [CoreStore: Fatal Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
Swift.fatalError(file: fileName, line: UInt(lineNumber))
Swift::print("❗ [CoreStore: Fatal Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
Swift::fatalError(file: fileName, line: UInt(lineNumber))
}
}
+1 -1
View File
@@ -54,7 +54,7 @@ extension Differentiable where Self: AnyObject {
@usableFromInline
internal protocol DifferentiableSection: Differentiable {
associatedtype Collection: Swift.Collection where Collection.Element: Differentiable
associatedtype Collection: Swift::Collection where Collection.Element: Differentiable
var elements: Collection { get }
+1 -1
View File
@@ -38,7 +38,7 @@ public nonisolated protocol DynamicObject: AnyObject, SendableMetatype {
/**
The object ID for this instance
*/
typealias ObjectID = DynamicObjectID<Self>
typealias ObjectID = PersistentID<Self>
/**
+1 -1
View File
@@ -235,7 +235,7 @@ extension FieldContainer {
self.keyPath = keyPath
self.entityDescriptionValues = {
let range = (Swift.max(0, minCount) ... maxCount)
let range = (Swift::max(0, minCount) ... maxCount)
return (
isToMany: isToMany,
isOrdered: isOrdered,
@@ -57,7 +57,7 @@ extension Internals {
self.structure = .init(
sections: sections,
sectionIndexTransformer: sectionIndexTransformer,
fetchOffset: Swift.max(0, fetchOffset),
fetchOffset: Swift::max(0, fetchOffset),
fetchLimit: (fetchLimit > 0) ? fetchLimit : nil
)
}
+1 -1
View File
@@ -43,4 +43,4 @@ import Foundation
}
```
*/
public typealias MigrationResult = Swift.Result<[MigrationType], CoreStoreError>
public typealias MigrationResult = Swift::Result<[MigrationType], CoreStoreError>
@@ -78,7 +78,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
@nonobjc
public func fetchExisting<O: DynamicObject>(
_ persistentID: DynamicObjectID<O>
_ persistentID: PersistentID<O>
) -> O? {
return self.fetchExisting(persistentID.managedObjectID)
@@ -111,7 +111,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
@nonobjc
public func fetchExisting<O: DynamicObject, S: Sequence>(
_ persistentIDs: S
) -> [O] where S.Iterator.Element == DynamicObjectID<O> {
) -> [O] where S.Iterator.Element == PersistentID<O> {
return persistentIDs.compactMap({ self.fetchExisting($0.managedObjectID) })
}
@@ -28,7 +28,7 @@ import CoreData
// MARK: - DynamicObjectID
public struct DynamicObjectID<O: DynamicObject>: Hashable, ObjectRepresentation, Sendable {
public struct PersistentID<O: DynamicObject>: Hashable, ObjectRepresentation, Sendable {
/**
The associated `NSManagedObject` or `CoreStoreObject` entity class
+1 -1
View File
@@ -203,7 +203,7 @@ extension RelationshipContainer {
self.keyPath = keyPath
self.entityDescriptionValues = {
let range = (Swift.max(0, minCount) ... maxCount)
let range = (Swift::max(0, minCount) ... maxCount)
return (
isToMany: true,
isOrdered: true,
+1 -1
View File
@@ -203,7 +203,7 @@ extension RelationshipContainer {
self.keyPath = keyPath
self.entityDescriptionValues = {
let range = (Swift.max(0, minCount) ... maxCount)
let range = (Swift::max(0, minCount) ... maxCount)
return (
isToMany: true,
isOrdered: false,
+1 -1
View File
@@ -47,4 +47,4 @@ import CoreData
)
```
*/
public typealias SetupResult<StorageInterfaceType> = Swift.Result<StorageInterfaceType, CoreStoreError> where StorageInterfaceType: StorageInterface
public typealias SetupResult<StorageInterfaceType> = Swift::Result<StorageInterfaceType, CoreStoreError> where StorageInterfaceType: StorageInterface
+6 -6
View File
@@ -71,11 +71,11 @@ public nonisolated final class SynchronousDataTransaction: BaseDataTransaction {
/**
Returns an editable proxy of a specified `NSManagedObject` or `CoreStoreObject`.
- parameter persistentID: the `DynamicObjectID` pertaining ot the `NSManagedObject` or `CoreStoreObject` type to be edited
- parameter persistentID: the `PersistentID` pertaining ot the `NSManagedObject` or `CoreStoreObject` type to be edited
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
*/
public override func edit<O: DynamicObject>(
_ persistentID: DynamicObjectID<O>?
_ persistentID: PersistentID<O>?
) -> O? {
Internals.assert(
@@ -104,15 +104,15 @@ public nonisolated final class SynchronousDataTransaction: BaseDataTransaction {
}
/**
Returns an editable proxy of the object with the specified `DynamicObjectID`.
Returns an editable proxy of the object with the specified `PersistentID`.
- parameter into: an `Into` clause specifying the entity type
- parameter persistentID: the `DynamicObjectID` for the object to be edited
- parameter persistentID: the `PersistentID` for the object to be edited
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
*/
public override func edit<O>(
_ into: Into<O>,
_ persistentID: DynamicObjectID<O>
_ persistentID: PersistentID<O>
) -> O? {
Internals.assert(
@@ -150,7 +150,7 @@ public nonisolated final class SynchronousDataTransaction: BaseDataTransaction {
*/
public override func delete<O: DynamicObject, S: Sequence>(
persistentIDs: S
) where S.Iterator.Element == DynamicObjectID<O> {
) where S.Iterator.Element == PersistentID<O> {
Internals.assert(
!self.isCommitted,