Skip to content

requiredWriteScopes — @gj-kit/expo-workouts

A public function from @gj-kit/expo-workouts/core. The signature below is taken directly from the 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[];

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: ./core
  • Source: GitHub