콘텐츠로 이동

requiredWriteScopes — @gj-kit/expo-workouts

@gj-kit/expo-workouts/core에서 공개하는 function입니다. package version 0.1.1의 release declaration을 그대로 표시합니다.

import { requiredWriteScopes } from '@gj-kit/expo-workouts/core';
/**
* WRITE-side pre-flight. Derives, from the fields a `WorkoutWrite` ACTUALLY CARRIES, which write
* scopes its single `insertRecords` transaction will need. A workout with no `distanceM` needs no
* `'distance'` scope, so nothing is over-demanded.
*
* `saveWorkout` calls this BEFORE touching the store and throws `notAuthorized` naming the missing
* scope. Without it, owner decision ②'s split would ship a hard REGRESSION: Android writes the
* session and all five metric records in ONE transaction, so a missing `WRITE_DISTANCE` fails the
* whole transaction and the workout is not saved at all.
*
* `'routes'` is the documented exception and is NEVER a throw: a missing route scope stays the
* established non-fatal path (`SaveResult.route === 'notPermitted'`).
*
* `steps <= 0` deliberately does NOT demand `'steps'`: Health Connect throws on a zero-count
* `StepsRecord`, so the library never writes one.
*/
declare function requiredWriteScopes(workout: WorkoutWrite): readonly Scope[];

이 선언은 매개변수, optionality, 제네릭, 반환값, 공개 union/type 계약의 정본입니다. 호출 전 필요한 환경·권한·오류 경계는 패키지 Golden path와 이 subpath의 import 조건을 함께 확인하세요.

  • 패키지: @gj-kit/expo-workouts
  • 버전: 0.1.1
  • 공개 entry: ./core
  • 소스: GitHub

WRITE-side pre-flight. Derives, from the fields a WorkoutWrite ACTUALLY CARRIES, which write scopes its single insertRecords transaction will need. A workout with no distanceM needs no 'distance' scope, so nothing is over-demanded.

saveWorkout calls this BEFORE touching the store and throws notAuthorized naming the missing scope. Without it, owner decision ②’s split would ship a hard REGRESSION: Android writes the session and all five metric records in ONE transaction, so a missing WRITE_DISTANCE fails the whole transaction and the workout is not saved at all.

'routes' is the documented exception and is NEVER a throw: a missing route scope stays the established non-fatal path (SaveResult.route === 'notPermitted').

steps <= 0 deliberately does NOT demand 'steps': Health Connect throws on a zero-count StepsRecord, so the library never writes one.