Skip to content

reconcileSyncPage — @gj-kit/expo-workouts

A public function from @gj-kit/expo-workouts. The signature below is taken directly from the 0.1.1 release declaration.

import { reconcileSyncPage } from '@gj-kit/expo-workouts';
/**
* Split one sync page into the three operations a local store actually performs.
*
* - `rekeys` come from `removed[].replaced === true` matched against the same page's `added` —
* iOS replaces a workout's native id when the same sync identifier is re-saved. Apply them as an
* UPDATE of the primary key, NEVER as DELETE + INSERT, or you lose your local join data (server
* ids, upload state, notes).
* - `deletes` are the genuinely-gone ids. Applying one for an id you never held must be a no-op.
*
* ⚠ Matching heuristic, stated out loud: `RemovedWorkout` deliberately does not carry a
* `replacedById` field, so a replaced removal is paired, in order, with the same page's own
* writes (`isOwn && clientId != null`). A batch that carries several replacements at once pairs
* them positionally, which is what the platform emits. A replaced removal that finds no partner
* is NEVER turned into a delete — `replaced: true` means the workout still exists, and deleting
* it would destroy the caller's join data.
*/
declare function reconcileSyncPage(page: Pick<SyncPage, 'added' | 'removed'>): {
readonly upserts: readonly Workout[];
readonly deletes: readonly string[];
readonly rekeys: readonly {
readonly fromId: string;
readonly toId: string;
}[];
};

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/expo-workouts
  • Version: 0.1.1
  • Public entry: .
  • Source: GitHub