From c9d3ea278b8d392d62c5584ad07f7b07bc8a908d Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 4 Sep 2025 10:57:59 -0700 Subject: [PATCH 1/3] wip --- .../Documentation.docc/Articles/CloudKit.md | 9 +++++++++ .../Documentation.docc/Articles/CloudKitSharing.md | 6 ++++++ Sources/SQLiteData/Documentation.docc/SQLiteData.md | 11 ++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md b/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md index cfdfa26e..a0e36e07 100644 --- a/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md +++ b/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md @@ -716,6 +716,15 @@ from CloudKit. ## Topics +### CloudKit synchronization + +- ``SyncEngine`` +- ``SyncMetadata`` + +### Record identification + +- ``IdentifierStringConvertible`` + ### Go deeper - diff --git a/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md b/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md index f599c68d..9f5c4501 100644 --- a/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md +++ b/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md @@ -473,3 +473,9 @@ shares a list with a friend, it will _not_ share the private table, allowing eac their own personal ordering of lists. ## Querying share metadata + +## Topics + +### Accessing share metadata + +- ``SharedRecord`` diff --git a/Sources/SQLiteData/Documentation.docc/SQLiteData.md b/Sources/SQLiteData/Documentation.docc/SQLiteData.md index 86d76c13..709a3071 100644 --- a/Sources/SQLiteData/Documentation.docc/SQLiteData.md +++ b/Sources/SQLiteData/Documentation.docc/SQLiteData.md @@ -284,13 +284,13 @@ with SQLite to take full advantage of GRDB and SQLiteData. - ``Dependencies/DependencyValues/defaultDatabase`` -### Fetching and observing queries +### Observing model data - ``FetchAll`` - ``FetchOne`` - ``Fetch`` -### Executing statements +### Fetching model data - ``StructuredQueriesCore/Statement/execute(_:)`` - ``StructuredQueriesCore/Statement/fetchAll(_:)`` @@ -298,6 +298,11 @@ with SQLite to take full advantage of GRDB and SQLiteData. - ``StructuredQueriesCore/Statement/fetchCursor(_:)`` - ``StructuredQueriesCore/SelectStatement/fetchCount(_:)`` -### Seeding data +### Seeding model data - ``GRDB/Database/seed(_:)`` + +### User-defined functions + +- ``GRDB/Database/add(function:)`` +- ``GRDB/Database/remove(function:)`` From 0de8ecb8fd6afcfb539e16dda0de18b772167fee Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 4 Sep 2025 11:23:31 -0700 Subject: [PATCH 2/3] wip --- .../IdentifierStringConvertible.swift | 3 ++ .../Documentation.docc/Articles/CloudKit.md | 17 +--------- .../Articles/CloudKitSharing.md | 8 ----- .../Documentation.docc/Extensions/Database.md | 16 ++++++++++ .../Extensions/IdentifierStringConvertible.md | 29 +++++++++++++++++ .../Extensions/SystemFieldsRepresentation.md | 1 + .../Documentation.docc/SQLiteData.md | 31 +++++++++---------- 7 files changed, 65 insertions(+), 40 deletions(-) create mode 100644 Sources/SQLiteData/Documentation.docc/Extensions/Database.md create mode 100644 Sources/SQLiteData/Documentation.docc/Extensions/IdentifierStringConvertible.md create mode 100644 Sources/SQLiteData/Documentation.docc/Extensions/SystemFieldsRepresentation.md diff --git a/Sources/SQLiteData/CloudKit/IdentifierStringConvertible.swift b/Sources/SQLiteData/CloudKit/IdentifierStringConvertible.swift index 54243d39..259aa14c 100644 --- a/Sources/SQLiteData/CloudKit/IdentifierStringConvertible.swift +++ b/Sources/SQLiteData/CloudKit/IdentifierStringConvertible.swift @@ -1,6 +1,9 @@ import Foundation /// A type that can be represented by a string identifier. +/// +/// A requirement of tables synchronized to CloudKit using a ``SyncEngine``. You should generally +/// identify tables using Foundation's `UUID` type. public protocol IdentifierStringConvertible { init?(rawIdentifier: String) var rawIdentifier: String { get } diff --git a/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md b/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md index a0e36e07..181447a4 100644 --- a/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md +++ b/Sources/SQLiteData/Documentation.docc/Articles/CloudKit.md @@ -1,4 +1,4 @@ -# CloudKit synchronization +# Getting started with CloudKit Learn how to seamlessly add CloudKit synchronization to your SQLiteData application. @@ -713,18 +713,3 @@ Model.createTemporaryTrigger( This will skip the trigger's action when the row is being updated due to data being synchronized from CloudKit. - -## Topics - -### CloudKit synchronization - -- ``SyncEngine`` -- ``SyncMetadata`` - -### Record identification - -- ``IdentifierStringConvertible`` - -### Go deeper - -- diff --git a/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md b/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md index 9f5c4501..01e5e32e 100644 --- a/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md +++ b/Sources/SQLiteData/Documentation.docc/Articles/CloudKitSharing.md @@ -471,11 +471,3 @@ struct MyApp: App { This table will still be synchronized across all of a single user's devices, but if that user shares a list with a friend, it will _not_ share the private table, allowing each user to have their own personal ordering of lists. - -## Querying share metadata - -## Topics - -### Accessing share metadata - -- ``SharedRecord`` diff --git a/Sources/SQLiteData/Documentation.docc/Extensions/Database.md b/Sources/SQLiteData/Documentation.docc/Extensions/Database.md new file mode 100644 index 00000000..8c8f2316 --- /dev/null +++ b/Sources/SQLiteData/Documentation.docc/Extensions/Database.md @@ -0,0 +1,16 @@ +# ``GRDB/Database`` + +## Topics + +### Seeding model data + +- ``seed(_:)`` + +### User-defined functions + +- ``add(function:)`` +- ``remove(function:)`` + +### Querying CloudKit metadata + +- ``attachMetadatabase(containerIdentifier:)`` diff --git a/Sources/SQLiteData/Documentation.docc/Extensions/IdentifierStringConvertible.md b/Sources/SQLiteData/Documentation.docc/Extensions/IdentifierStringConvertible.md new file mode 100644 index 00000000..15411423 --- /dev/null +++ b/Sources/SQLiteData/Documentation.docc/Extensions/IdentifierStringConvertible.md @@ -0,0 +1,29 @@ +# ``IdentifierStringConvertible`` + +## Topics + +### Conformances + +- ``Swift/Bool`` +- ``Swift/Character`` +- ``Swift/Double`` +- ``Swift/Float`` +- ``Swift/Float16`` +- ``Swift/Int`` +- ``Swift/Int128`` +- ``Swift/Int16`` +- ``Swift/Int32`` +- ``Swift/Int64`` +- ``Swift/Int8`` +- ``Swift/String`` +- ``Swift/Substring`` +- ``Swift/UInt`` +- ``Swift/UInt128`` +- ``Swift/UInt16`` +- ``Swift/UInt32`` +- ``Swift/UInt64`` +- ``Swift/UInt8`` +- ``Swift/Optional`` +- ``Swift/Unicode/Scalar`` +- ``Foundation/UUID`` +- ``Tagged/Tagged`` diff --git a/Sources/SQLiteData/Documentation.docc/Extensions/SystemFieldsRepresentation.md b/Sources/SQLiteData/Documentation.docc/Extensions/SystemFieldsRepresentation.md new file mode 100644 index 00000000..ccf259bf --- /dev/null +++ b/Sources/SQLiteData/Documentation.docc/Extensions/SystemFieldsRepresentation.md @@ -0,0 +1 @@ +# ``CloudKit/CKRecord/SystemFieldsRepresentation`` diff --git a/Sources/SQLiteData/Documentation.docc/SQLiteData.md b/Sources/SQLiteData/Documentation.docc/SQLiteData.md index 709a3071..852ac7ec 100644 --- a/Sources/SQLiteData/Documentation.docc/SQLiteData.md +++ b/Sources/SQLiteData/Documentation.docc/SQLiteData.md @@ -277,32 +277,31 @@ with SQLite to take full advantage of GRDB and SQLiteData. - - - -- - ### Database configuration and access +- ``GRDB/Database`` - ``Dependencies/DependencyValues/defaultDatabase`` +### Querying model data + +- ``StructuredQueriesCore/Statement`` +- ``StructuredQueriesCore/SelectStatement`` +- ``QueryCursor`` + ### Observing model data - ``FetchAll`` - ``FetchOne`` - ``Fetch`` -### Fetching model data - -- ``StructuredQueriesCore/Statement/execute(_:)`` -- ``StructuredQueriesCore/Statement/fetchAll(_:)`` -- ``StructuredQueriesCore/Statement/fetchOne(_:)`` -- ``StructuredQueriesCore/Statement/fetchCursor(_:)`` -- ``StructuredQueriesCore/SelectStatement/fetchCount(_:)`` +### CloudKit synchronization and sharing -### Seeding model data - -- ``GRDB/Database/seed(_:)`` - -### User-defined functions - -- ``GRDB/Database/add(function:)`` -- ``GRDB/Database/remove(function:)`` +- +- +- ``SyncEngine`` +- ``Dependencies/DependencyValues/defaultSyncEngine`` +- ``IdentifierStringConvertible`` +- ``SyncMetadata`` +- ``SharedRecord`` From 31010bf41fd36ab2797a6617d35a31e25ec1b218 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 4 Sep 2025 11:35:47 -0700 Subject: [PATCH 3/3] wip --- Makefile | 2 +- Sources/SQLiteData/CloudKit/Internal/Triggers.swift | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d23c3fc0..f80e8f17 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ XCODEBUILD_FLAGS = \ XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS) -# TODO: Prefer 'xcbeautify --quiet' when this is fixed: +# NB: Prefer 'xcbeautify --quiet' when this is fixed: # https://github.com/cpisciotta/xcbeautify/issues/339 ifneq ($(strip $(shell which xcbeautify)),) XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify diff --git a/Sources/SQLiteData/CloudKit/Internal/Triggers.swift b/Sources/SQLiteData/CloudKit/Internal/Triggers.swift index 5deeae2e..c2fbe727 100644 --- a/Sources/SQLiteData/CloudKit/Internal/Triggers.swift +++ b/Sources/SQLiteData/CloudKit/Internal/Triggers.swift @@ -51,7 +51,6 @@ ifNotExists: true, after: .update { _, new in checkWritePermissions(alias: new, parentForeignKey: parentForeignKey) - // TODO: change to update? SyncMetadata.upsert(new: new, parentForeignKey: parentForeignKey) } )