Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-offline-mutations-changes-field.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/offline-transactions': patch
---

Fix mutation.changes field being lost during offline transaction serialization. Previously, the changes field was not included in serialized mutations, causing it to be empty ({}) after app restart. This led to sync functions receiving incomplete data when using mutation.changes for partial updates.
5 changes: 5 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"permissions": {
"allow": ["Bash(git checkout:*)", "Bash(npx sherif:*)"]
}
}
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm 10.26.0
nodejs 22.13.1
5 changes: 5 additions & 0 deletions packages/db-collections/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "db-collections",
"version": "0.0.0",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class TransactionSerializer {
type: mutation.type,
modified: this.serializeValue(mutation.modified),
original: this.serializeValue(mutation.original),
changes: this.serializeValue(mutation.changes),
collectionId: registryKey, // Store registry key instead of collection.id
}
}
Expand All @@ -83,11 +84,11 @@ export class TransactionSerializer {
type: data.type as any,
modified: this.deserializeValue(data.modified),
original: this.deserializeValue(data.original),
changes: this.deserializeValue(data.changes) ?? {},
collection,
// These fields would need to be reconstructed by the executor
mutationId: ``, // Will be regenerated
key: null, // Will be extracted from the data
changes: {}, // Will be recalculated
metadata: undefined,
syncMetadata: {},
optimistic: true,
Expand All @@ -108,7 +109,7 @@ export class TransactionSerializer {
if (typeof value === `object`) {
const result: any = Array.isArray(value) ? [] : {}
for (const key in value) {
if (value.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(value, key)) {
result[key] = this.serializeValue(value[key])
}
}
Expand Down Expand Up @@ -139,7 +140,7 @@ export class TransactionSerializer {
if (typeof value === `object`) {
const result: any = Array.isArray(value) ? [] : {}
for (const key in value) {
if (value.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(value, key)) {
result[key] = this.deserializeValue(value[key])
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/offline-transactions/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface SerializedMutation {
type: string
modified: any
original: any
changes: any
collectionId: string
}

Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading