reconcileSyncPage — @gj-kit/expo-workouts
@gj-kit/expo-workouts/core에서 공개하는 function입니다. package version 0.1.1의 release declaration을 그대로 표시합니다.
검증된 import 예제
섹션 제목: “검증된 import 예제”import { reconcileSyncPage } from '@gj-kit/expo-workouts/core';시그니처, 매개변수, 반환 타입
섹션 제목: “시그니처, 매개변수, 반환 타입”/** * 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; }[];};이 선언은 매개변수, optionality, 제네릭, 반환값, 공개 union/type 계약의 정본입니다. 호출 전 필요한 환경·권한·오류 경계는 패키지 Golden path와 이 subpath의 import 조건을 함께 확인하세요.
Release context
섹션 제목: “Release context”- 패키지:
@gj-kit/expo-workouts - 버전:
0.1.1 - 공개 entry:
./core - 소스: GitHub
구현 주석
섹션 제목: “구현 주석”Split one sync page into the three operations a local store actually performs.
rekeyscome fromremoved[].replaced === truematched against the same page’sadded— 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).deletesare 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.