-
Notifications
You must be signed in to change notification settings - Fork 13
Add confirmed zone metadata (syncToken, atomic) to zone schemas #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
leogdion
wants to merge
3
commits into
v1.0.0-beta.4
Choose a base branch
from
386-zone-schema-metadata
base: v1.0.0-beta.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| name: reference_cloudkit_zone_dictionary | ||
| description: "CloudKit's Zone Dictionary has exactly three keys (zoneID, syncToken, atomic) — isEager and zone create options do not exist" | ||
| metadata: | ||
| node_type: memory | ||
| type: reference | ||
| --- | ||
|
|
||
| Verified against Apple's archived CloudKit Web Services Reference during issue #386 / PR #427. | ||
|
|
||
| **Zone Dictionary documents exactly three keys** ([Types.html](https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitWebServicesReference/Types.html)): | ||
|
|
||
| | Key | Apple's wording | | ||
| |-----|-----------------| | ||
| | `zoneID` | "The dictionary that identifies a record zone in the database" | | ||
| | `syncToken` | "The current point in the zone's change history." | | ||
| | `atomic` | "A Boolean value indicating whether this zone supports atomic operations." | | ||
|
|
||
| All four zone endpoints (`zones/list`, `zones/lookup`, `zones/modify`, `zones/changes`) route their **success** payload through this dictionary, and their **failure** payload through the "Zone Fetch Error Dictionary" (`zoneID`, `reason`, `serverErrorCode`, `retryAfter`, `redirectURL`). | ||
|
|
||
| **Things that do NOT exist — do not add them speculatively:** | ||
|
|
||
| - **`isEager`** — appears in no primary Apple source, nor in `.claude/docs/webservices.md` or `.claude/docs/cloudkitjs.md`. It was proposed in issue #386 but is unsourced. | ||
| - **`atomic` on the `zones/modify` request** — the request body is `operations` only. `records/modify` *does* document `atomic`; the asymmetry is deliberate. | ||
| - **Zone create options on `ZoneOperation`** — the operation's `zone` is documented as having "a single `zoneID` key". | ||
|
|
||
| **Open discrepancies (unresolved, see issue #386 comment):** | ||
|
|
||
| - `zones/changes` documents its token key as **`metaSyncToken`** in both request and response; MistKit sends/reads `syncToken`. Apple's page contradicts itself (the `moreComing` description refers back to "the included `syncToken` key"), so this needs a live-response check before changing. | ||
| - `zones/changes` is documented as **deprecated** in favor of `changes/database`. | ||
|
|
||
| Note `ZoneID`'s owner key: Apple documents `ownerRecordName`, while MistKit's `ZoneID` domain type calls it `ownerName` and the wire schema uses `ownerName`. Related: [[reference_cloudkit_archived_endpoints]]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,12 +39,30 @@ public struct ZoneInfo: Codable, Sendable { | |
| /// Note: always empty — CloudKit Web Services zone responses do not include | ||
| /// capabilities in the current OpenAPI schema. | ||
| public let capabilities: [String] | ||
| /// The current point in the zone's change history. | ||
| /// | ||
| /// Present on zone responses that carry Apple's "Zone Dictionary" payload; | ||
| /// `nil` when the server omits it. | ||
| public let syncToken: String? | ||
| /// Whether this zone supports atomic operations. | ||
| /// | ||
| /// `nil` when the server omits the key — deliberately *not* defaulted to | ||
| /// `false`, so "absent" stays distinguishable from "explicitly not atomic". | ||
| public let atomic: Bool? | ||
|
|
||
| /// Initialize zone information | ||
| public init(zoneName: String, ownerRecordName: String?, capabilities: [String]) { | ||
| public init( | ||
| zoneName: String, | ||
| ownerRecordName: String?, | ||
| capabilities: [String], | ||
| syncToken: String? = nil, | ||
| atomic: Bool? = nil | ||
| ) { | ||
| self.zoneName = zoneName | ||
| self.ownerRecordName = ownerRecordName | ||
| self.capabilities = capabilities | ||
| self.syncToken = syncToken | ||
| self.atomic = atomic | ||
| } | ||
|
|
||
| /// Convert a CloudKit zone payload's `zoneID` into a `ZoneInfo`. | ||
|
|
@@ -60,7 +78,11 @@ public struct ZoneInfo: Codable, Sendable { | |
| /// and make the generated decoder reject otherwise-valid payloads, so the | ||
| /// response-side "must be present" rule is enforced here at the domain | ||
| /// boundary instead. | ||
| internal init(fromZoneID zoneID: Components.Schemas.ZoneID?) throws(ConversionError) { | ||
| internal init( | ||
| fromZoneID zoneID: Components.Schemas.ZoneID?, | ||
| syncToken: String? = nil, | ||
| atomic: Bool? = nil | ||
| ) throws(ConversionError) { | ||
| guard let zoneID else { | ||
| try ConversionError.zoneMissingID.reportAndThrow() | ||
| } | ||
|
|
@@ -70,7 +92,19 @@ public struct ZoneInfo: Codable, Sendable { | |
| self.init( | ||
| zoneName: zoneName, | ||
| ownerRecordName: zoneID.ownerName, | ||
| capabilities: [] | ||
| capabilities: [], | ||
| syncToken: syncToken, | ||
| atomic: atomic | ||
| ) | ||
| } | ||
|
|
||
| /// Convert a CloudKit `Zone` payload into a `ZoneInfo`, carrying the | ||
| /// zone-level metadata (`syncToken`, `atomic`) alongside the identity. | ||
| internal init(from zone: Components.Schemas.Zone) throws(ConversionError) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of (from zone:) make this (zone: ) |
||
| try self.init( | ||
| fromZoneID: zone.zoneID, | ||
| syncToken: zone.syncToken, | ||
| atomic: zone.atomic | ||
| ) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove fromZoneID and just do zoneID