Skip to content

NativeWorkoutsModule — @gj-kit/expo-workouts

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

import { NativeWorkoutsModule } from '@gj-kit/expo-workouts';
/**
* 네이티브 모듈 계약. `./testing`의 `createFakeNativeWorkouts()`가 이것을 인메모리로 구현하고,
* 실물은 `requireOptionalNativeModule('GjKitWorkouts')`가 돌려준다.
*/
interface NativeWorkoutsModule {
availability(): Promise<AvailabilityDto>;
authorizationSnapshot(): Promise<AuthorizationSnapshotDto>;
/**
* No internal timeout (f120, f122). Returns the raw before/after granted sets.
*
* ⚠ **Phase 3 correction (design defect found by running the example app).** This member used to
* take ONE flat `readonly string[]`. That is lossless on Android — the direction lives in the
* permission string itself (`READ_EXERCISE` vs `WRITE_EXERCISE`) — but on iOS the SAME type
* identifier serves both directions, so a flat array cannot express what
* `HKHealthStore.requestAuthorization(toShare:read:)` requires: the iOS lane could only either
* over-request share access or silently drop it. The two sets are now explicit.
* `read`/`write` are Android permission strings on Android and HK type identifiers on iOS.
* `history` is Android's `READ_HEALTH_DATA_HISTORY` and rides in `read`.
*/
requestPermissions(request: PermissionRequestDto): Promise<PermissionOutcomeDto>;
/** 커서의 `g` 지문을 만드는 원시 연산. 정렬된 granted 권한 문자열 목록을 그대로 준다. */
grantedScopeFingerprint(): Promise<string>;
/** Start instant in `[fromMs, toMs)`. iOS `.strictStartDate`, Android `TimeRangeFilter.between`. */
readWorkoutPage(query: WindowDto & {
readonly pageSize: number;
readonly pageToken?: string | undefined;
}): Promise<WorkoutPageDto>;
/** One call per metric type per PAGE WINDOW - never per session (§8.4). Never `aggregate()` (f109). */
readMetricRecords(query: WindowDto & {
readonly type: MetricTypeDto;
readonly origins: readonly string[];
}): Promise<readonly MetricRowDto[]>;
readHeartRateSamples(query: WindowDto): Promise<readonly HeartRateDto[]>;
/** iOS provenance discriminator required by RESULTS 206 / f71. */
hasAssociatedSamples(nativeId: string, quantity: QuantityKindDto): Promise<boolean>;
takeCheckpoint(): Promise<string>;
drainCheckpoint(checkpoint: string, limit: number): Promise<DrainBatchDto>;
openRoute(nativeId: string, consent: 'skip' | 'prompt'): Promise<RouteHandleDto>;
readRouteChunk(handle: string, maxPoints: number): Promise<readonly RoutePointDto[] | null>;
closeRoute(handle: string): Promise<void>;
/** iOS: look the workout up by sync identifier BEFORE writing (idx f26). Android: `null`. */
findBySyncIdentifier(clientId: string): Promise<ExistingWorkoutDto | null>;
saveWorkout(spec: WorkoutWriteDto): Promise<SaveOutcomeDto>;
/** Android only, ALWAYS called after a save (f93, f94). `null` when nothing was found. */
readBackVersion(clientId: string): Promise<number | null>;
deleteWorkout(ref: DeleteRefDto): Promise<boolean>;
openSettings(): Promise<void>;
openStoreListing(): Promise<void>;
}

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