@nativesquare/soma 0.7.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.d.ts +17 -55
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +63 -13
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +80 -4
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +153 -120
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/garmin/private.d.ts +475 -0
- package/dist/component/garmin/private.d.ts.map +1 -0
- package/dist/component/garmin/private.js +1614 -0
- package/dist/component/garmin/private.js.map +1 -0
- package/dist/component/{garmin.d.ts → garmin/public.d.ts} +25 -52
- package/dist/component/garmin/public.d.ts.map +1 -0
- package/dist/component/{garmin.js → garmin/public.js} +301 -215
- package/dist/component/garmin/public.js.map +1 -0
- package/dist/component/garmin/schemas/activity.d.ts +94 -0
- package/dist/component/garmin/schemas/activity.d.ts.map +1 -0
- package/dist/component/garmin/schemas/activity.js +27 -0
- package/dist/component/garmin/schemas/activity.js.map +1 -0
- package/dist/component/garmin/schemas/activityDetails.d.ts +146 -0
- package/dist/component/garmin/schemas/activityDetails.d.ts.map +1 -0
- package/dist/component/garmin/schemas/activityDetails.js +27 -0
- package/dist/component/garmin/schemas/activityDetails.js.map +1 -0
- package/dist/component/garmin/schemas/bloodPressure.d.ts +38 -0
- package/dist/component/garmin/schemas/bloodPressure.d.ts.map +1 -0
- package/dist/component/garmin/schemas/bloodPressure.js +27 -0
- package/dist/component/garmin/schemas/bloodPressure.js.map +1 -0
- package/dist/component/garmin/schemas/bodyCompositions.d.ts +42 -0
- package/dist/component/garmin/schemas/bodyCompositions.d.ts.map +1 -0
- package/dist/component/garmin/schemas/bodyCompositions.js +27 -0
- package/dist/component/garmin/schemas/bodyCompositions.js.map +1 -0
- package/dist/component/garmin/schemas/dailies.d.ts +98 -0
- package/dist/component/garmin/schemas/dailies.d.ts.map +1 -0
- package/dist/component/garmin/schemas/dailies.js +27 -0
- package/dist/component/garmin/schemas/dailies.js.map +1 -0
- package/dist/component/garmin/schemas/epochs.d.ts +54 -0
- package/dist/component/garmin/schemas/epochs.d.ts.map +1 -0
- package/dist/component/garmin/schemas/epochs.js +27 -0
- package/dist/component/garmin/schemas/epochs.js.map +1 -0
- package/dist/component/garmin/schemas/healthSnapshot.d.ts +48 -0
- package/dist/component/garmin/schemas/healthSnapshot.d.ts.map +1 -0
- package/dist/component/garmin/schemas/healthSnapshot.js +27 -0
- package/dist/component/garmin/schemas/healthSnapshot.js.map +1 -0
- package/dist/component/garmin/schemas/hrvSummary.d.ts +40 -0
- package/dist/component/garmin/schemas/hrvSummary.d.ts.map +1 -0
- package/dist/component/garmin/schemas/hrvSummary.js +27 -0
- package/dist/component/garmin/schemas/hrvSummary.js.map +1 -0
- package/dist/component/garmin/schemas/manuallyUpdatedActivities.d.ts +94 -0
- package/dist/component/garmin/schemas/manuallyUpdatedActivities.d.ts.map +1 -0
- package/dist/component/garmin/schemas/manuallyUpdatedActivities.js +27 -0
- package/dist/component/garmin/schemas/manuallyUpdatedActivities.js.map +1 -0
- package/dist/component/garmin/schemas/menstrualCycleTracking.d.ts +100 -0
- package/dist/component/garmin/schemas/menstrualCycleTracking.d.ts.map +1 -0
- package/dist/component/garmin/schemas/menstrualCycleTracking.js +28 -0
- package/dist/component/garmin/schemas/menstrualCycleTracking.js.map +1 -0
- package/dist/component/garmin/schemas/moveIQ.d.ts +40 -0
- package/dist/component/garmin/schemas/moveIQ.d.ts.map +1 -0
- package/dist/component/garmin/schemas/moveIQ.js +27 -0
- package/dist/component/garmin/schemas/moveIQ.js.map +1 -0
- package/dist/component/garmin/schemas/pulseOx.d.ts +38 -0
- package/dist/component/garmin/schemas/pulseOx.d.ts.map +1 -0
- package/dist/component/garmin/schemas/pulseOx.js +28 -0
- package/dist/component/garmin/schemas/pulseOx.js.map +1 -0
- package/dist/component/garmin/schemas/respiration.d.ts +34 -0
- package/dist/component/garmin/schemas/respiration.d.ts.map +1 -0
- package/dist/component/garmin/schemas/respiration.js +28 -0
- package/dist/component/garmin/schemas/respiration.js.map +1 -0
- package/dist/component/garmin/schemas/skinTemperature.d.ts +36 -0
- package/dist/component/garmin/schemas/skinTemperature.d.ts.map +1 -0
- package/dist/component/garmin/schemas/skinTemperature.js +28 -0
- package/dist/component/garmin/schemas/skinTemperature.js.map +1 -0
- package/dist/component/garmin/schemas/sleeps.d.ts +88 -0
- package/dist/component/garmin/schemas/sleeps.d.ts.map +1 -0
- package/dist/component/garmin/schemas/sleeps.js +27 -0
- package/dist/component/garmin/schemas/sleeps.js.map +1 -0
- package/dist/component/garmin/schemas/stress.d.ts +70 -0
- package/dist/component/garmin/schemas/stress.d.ts.map +1 -0
- package/dist/component/garmin/schemas/stress.js +28 -0
- package/dist/component/garmin/schemas/stress.js.map +1 -0
- package/dist/component/garmin/schemas/userMetrics.d.ts +36 -0
- package/dist/component/garmin/schemas/userMetrics.d.ts.map +1 -0
- package/dist/component/garmin/schemas/userMetrics.js +28 -0
- package/dist/component/garmin/schemas/userMetrics.js.map +1 -0
- package/dist/component/garmin/transform/activity.d.ts +13 -0
- package/dist/component/garmin/transform/activity.d.ts.map +1 -0
- package/dist/component/garmin/transform/activity.js +111 -0
- package/dist/component/garmin/transform/activity.js.map +1 -0
- package/dist/component/garmin/transform/activityDetails.d.ts +13 -0
- package/dist/component/garmin/transform/activityDetails.d.ts.map +1 -0
- package/dist/component/garmin/transform/activityDetails.js +173 -0
- package/dist/component/garmin/transform/activityDetails.js.map +1 -0
- package/dist/component/garmin/transform/bloodPressure.d.ts +12 -0
- package/dist/component/garmin/transform/bloodPressure.d.ts.map +1 -0
- package/dist/component/garmin/transform/bloodPressure.js +33 -0
- package/dist/component/garmin/transform/bloodPressure.js.map +1 -0
- package/dist/component/garmin/transform/bodyCompositions.d.ts +12 -0
- package/dist/component/garmin/transform/bodyCompositions.d.ts.map +1 -0
- package/dist/component/garmin/transform/bodyCompositions.js +42 -0
- package/dist/component/garmin/transform/bodyCompositions.js.map +1 -0
- package/dist/component/garmin/transform/dailies.d.ts +12 -0
- package/dist/component/garmin/transform/dailies.d.ts.map +1 -0
- package/dist/component/garmin/transform/dailies.js +132 -0
- package/dist/component/garmin/transform/dailies.js.map +1 -0
- package/dist/component/garmin/transform/epochs.d.ts +13 -0
- package/dist/component/garmin/transform/epochs.d.ts.map +1 -0
- package/dist/component/garmin/transform/epochs.js +76 -0
- package/dist/component/garmin/transform/epochs.js.map +1 -0
- package/dist/component/garmin/transform/healthSnapshot.d.ts +12 -0
- package/dist/component/garmin/transform/healthSnapshot.d.ts.map +1 -0
- package/dist/component/garmin/transform/healthSnapshot.js +111 -0
- package/dist/component/garmin/transform/healthSnapshot.js.map +1 -0
- package/dist/component/garmin/transform/hrvSummary.d.ts +12 -0
- package/dist/component/garmin/transform/hrvSummary.d.ts.map +1 -0
- package/dist/component/garmin/transform/hrvSummary.js +45 -0
- package/dist/component/garmin/transform/hrvSummary.js.map +1 -0
- package/dist/component/garmin/transform/manuallyUpdatedActivities.d.ts +11 -0
- package/dist/component/garmin/transform/manuallyUpdatedActivities.d.ts.map +1 -0
- package/dist/component/garmin/transform/manuallyUpdatedActivities.js +20 -0
- package/dist/component/garmin/transform/manuallyUpdatedActivities.js.map +1 -0
- package/dist/component/garmin/transform/menstrualCycleTracking.d.ts +10 -0
- package/dist/component/garmin/transform/menstrualCycleTracking.d.ts.map +1 -0
- package/dist/component/garmin/transform/menstrualCycleTracking.js +43 -0
- package/dist/component/garmin/transform/menstrualCycleTracking.js.map +1 -0
- package/dist/component/garmin/transform/moveIQ.d.ts +17 -0
- package/dist/component/garmin/transform/moveIQ.d.ts.map +1 -0
- package/dist/component/garmin/transform/moveIQ.js +41 -0
- package/dist/component/garmin/transform/moveIQ.js.map +1 -0
- package/dist/component/garmin/transform/pulseOx.d.ts +12 -0
- package/dist/component/garmin/transform/pulseOx.d.ts.map +1 -0
- package/dist/component/garmin/transform/pulseOx.js +46 -0
- package/dist/component/garmin/transform/pulseOx.js.map +1 -0
- package/dist/component/garmin/transform/respiration.d.ts +12 -0
- package/dist/component/garmin/transform/respiration.d.ts.map +1 -0
- package/dist/component/garmin/transform/respiration.js +54 -0
- package/dist/component/garmin/transform/respiration.js.map +1 -0
- package/dist/component/garmin/transform/skinTemperature.d.ts +12 -0
- package/dist/component/garmin/transform/skinTemperature.d.ts.map +1 -0
- package/dist/component/garmin/transform/skinTemperature.js +38 -0
- package/dist/component/garmin/transform/skinTemperature.js.map +1 -0
- package/dist/component/garmin/transform/sleeps.d.ts +55 -0
- package/dist/component/garmin/transform/sleeps.d.ts.map +1 -0
- package/dist/component/garmin/transform/sleeps.js +120 -0
- package/dist/component/garmin/transform/sleeps.js.map +1 -0
- package/dist/component/garmin/transform/stress.d.ts +12 -0
- package/dist/component/garmin/transform/stress.d.ts.map +1 -0
- package/dist/component/garmin/transform/stress.js +56 -0
- package/dist/component/garmin/transform/stress.js.map +1 -0
- package/dist/component/garmin/transform/userMetrics.d.ts +12 -0
- package/dist/component/garmin/transform/userMetrics.d.ts.map +1 -0
- package/dist/component/garmin/transform/userMetrics.js +48 -0
- package/dist/component/garmin/transform/userMetrics.js.map +1 -0
- package/dist/component/garmin/types/garmin.d.ts +21 -0
- package/dist/component/garmin/types/garmin.d.ts.map +1 -0
- package/dist/component/garmin/types/garmin.js +6 -0
- package/dist/component/garmin/types/garmin.js.map +1 -0
- package/dist/component/garmin/types/zod/zod.gen.d.ts +1319 -0
- package/dist/component/garmin/types/zod/zod.gen.d.ts.map +1 -0
- package/dist/component/garmin/types/zod/zod.gen.js +784 -0
- package/dist/component/garmin/types/zod/zod.gen.js.map +1 -0
- package/dist/component/garmin/webhooks.d.ts +141 -0
- package/dist/component/garmin/webhooks.d.ts.map +1 -0
- package/dist/component/garmin/webhooks.js +766 -0
- package/dist/component/garmin/webhooks.js.map +1 -0
- package/dist/component/private.d.ts +20 -2
- package/dist/component/private.d.ts.map +1 -1
- package/dist/component/private.js +18 -0
- package/dist/component/private.js.map +1 -1
- package/dist/component/public.d.ts +433 -387
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +12 -2
- package/dist/component/public.js.map +1 -1
- package/dist/component/schema.d.ts +217 -162
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +2 -1
- package/dist/component/schema.js.map +1 -1
- package/dist/component/strava/private.d.ts +30 -0
- package/dist/component/strava/private.d.ts.map +1 -0
- package/dist/component/strava/private.js +71 -0
- package/dist/component/strava/private.js.map +1 -0
- package/dist/component/{strava.d.ts → strava/public.d.ts} +3 -31
- package/dist/component/strava/public.d.ts.map +1 -0
- package/dist/component/{strava.js → strava/public.js} +22 -101
- package/dist/component/strava/public.js.map +1 -0
- package/dist/component/validators/activity.d.ts +6 -0
- package/dist/component/validators/activity.d.ts.map +1 -1
- package/dist/component/validators/activity.js.map +1 -1
- package/dist/component/validators/body.d.ts +20 -14
- package/dist/component/validators/body.d.ts.map +1 -1
- package/dist/component/validators/body.js.map +1 -1
- package/dist/component/validators/connection.d.ts +1 -0
- package/dist/component/validators/connection.d.ts.map +1 -1
- package/dist/component/validators/connection.js +2 -0
- package/dist/component/validators/connection.js.map +1 -1
- package/dist/component/validators/daily.d.ts +46 -5
- package/dist/component/validators/daily.d.ts.map +1 -1
- package/dist/component/validators/daily.js +10 -1
- package/dist/component/validators/daily.js.map +1 -1
- package/dist/component/validators/enums.d.ts +2 -2
- package/dist/component/validators/menstruation.d.ts +5 -0
- package/dist/component/validators/menstruation.d.ts.map +1 -1
- package/dist/component/validators/menstruation.js.map +1 -1
- package/dist/component/validators/plannedWorkout.d.ts +5 -1
- package/dist/component/validators/plannedWorkout.d.ts.map +1 -1
- package/dist/component/validators/plannedWorkout.js +4 -0
- package/dist/component/validators/plannedWorkout.js.map +1 -1
- package/dist/component/validators/sleep.d.ts +8 -8
- package/dist/garmin/bloodPressure.d.ts +28 -0
- package/dist/garmin/bloodPressure.d.ts.map +1 -0
- package/dist/garmin/bloodPressure.js +34 -0
- package/dist/garmin/bloodPressure.js.map +1 -0
- package/dist/garmin/body.js +1 -1
- package/dist/garmin/body.js.map +1 -1
- package/dist/garmin/client.d.ts +117 -17
- package/dist/garmin/client.d.ts.map +1 -1
- package/dist/garmin/client.js +337 -43
- package/dist/garmin/client.js.map +1 -1
- package/dist/garmin/daily.d.ts.map +1 -1
- package/dist/garmin/daily.js +3 -3
- package/dist/garmin/daily.js.map +1 -1
- package/dist/garmin/hrv.d.ts +30 -0
- package/dist/garmin/hrv.d.ts.map +1 -0
- package/dist/garmin/hrv.js +45 -0
- package/dist/garmin/hrv.js.map +1 -0
- package/dist/garmin/index.d.ts +16 -4
- package/dist/garmin/index.d.ts.map +1 -1
- package/dist/garmin/index.js +8 -2
- package/dist/garmin/index.js.map +1 -1
- package/dist/garmin/maps/activity-type.d.ts +1 -2
- package/dist/garmin/maps/activity-type.d.ts.map +1 -1
- package/dist/garmin/maps/activity-type.js +1 -0
- package/dist/garmin/maps/activity-type.js.map +1 -1
- package/dist/garmin/menstruation.d.ts +6 -4
- package/dist/garmin/menstruation.d.ts.map +1 -1
- package/dist/garmin/menstruation.js +12 -8
- package/dist/garmin/menstruation.js.map +1 -1
- package/dist/garmin/pulseOx.d.ts +24 -0
- package/dist/garmin/pulseOx.d.ts.map +1 -0
- package/dist/garmin/pulseOx.js +33 -0
- package/dist/garmin/pulseOx.js.map +1 -0
- package/dist/garmin/respiration.d.ts +29 -0
- package/dist/garmin/respiration.d.ts.map +1 -0
- package/dist/garmin/respiration.js +42 -0
- package/dist/garmin/respiration.js.map +1 -0
- package/dist/garmin/skinTemp.d.ts +27 -0
- package/dist/garmin/skinTemp.d.ts.map +1 -0
- package/dist/garmin/skinTemp.js +35 -0
- package/dist/garmin/skinTemp.js.map +1 -0
- package/dist/garmin/sleep.d.ts +4 -4
- package/dist/garmin/sleep.d.ts.map +1 -1
- package/dist/garmin/sleep.js +15 -9
- package/dist/garmin/sleep.js.map +1 -1
- package/dist/garmin/stressDetails.d.ts +30 -0
- package/dist/garmin/stressDetails.d.ts.map +1 -0
- package/dist/garmin/stressDetails.js +49 -0
- package/dist/garmin/stressDetails.js.map +1 -0
- package/dist/garmin/sync.d.ts +14 -0
- package/dist/garmin/sync.d.ts.map +1 -1
- package/dist/garmin/sync.js +290 -7
- package/dist/garmin/sync.js.map +1 -1
- package/dist/garmin/types.d.ts +77 -186
- package/dist/garmin/types.d.ts.map +1 -1
- package/dist/garmin/types.js +4 -2
- package/dist/garmin/types.js.map +1 -1
- package/dist/garmin/userMetrics.d.ts +23 -0
- package/dist/garmin/userMetrics.d.ts.map +1 -0
- package/dist/garmin/userMetrics.js +41 -0
- package/dist/garmin/userMetrics.js.map +1 -0
- package/dist/validators.d.ts +138 -56
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +2 -2
- package/dist/validators.js.map +1 -1
- package/package.json +130 -124
- package/src/client/index.ts +86 -18
- package/src/component/_generated/api.ts +96 -4
- package/src/component/_generated/component.ts +271 -144
- package/src/{garmin → component/garmin}/auth.ts +8 -1
- package/src/component/garmin/client.ts +39 -0
- package/src/component/garmin/private.ts +1798 -0
- package/src/component/garmin/public.ts +938 -0
- package/src/component/garmin/schemas/activity.ts +40 -0
- package/src/component/garmin/schemas/activityDetails.ts +45 -0
- package/src/component/garmin/schemas/bloodPressure.ts +38 -0
- package/src/component/garmin/schemas/bodyCompositions.ts +38 -0
- package/src/component/garmin/schemas/dailies.ts +38 -0
- package/src/component/garmin/schemas/epochs.ts +38 -0
- package/src/component/garmin/schemas/healthSnapshot.ts +38 -0
- package/src/component/garmin/schemas/hrvSummary.ts +38 -0
- package/src/component/garmin/schemas/manuallyUpdatedActivities.ts +49 -0
- package/src/component/garmin/schemas/menstrualCycleTracking.ts +39 -0
- package/src/component/garmin/schemas/moveIQ.ts +38 -0
- package/src/component/garmin/schemas/pulseOx.ts +39 -0
- package/src/component/garmin/schemas/respiration.ts +39 -0
- package/src/component/garmin/schemas/skinTemperature.ts +39 -0
- package/src/component/garmin/schemas/sleeps.ts +38 -0
- package/src/component/garmin/schemas/stress.ts +43 -0
- package/src/component/garmin/schemas/userMetrics.ts +39 -0
- package/src/component/garmin/transform/activity.ts +143 -0
- package/src/component/garmin/transform/activityDetails.ts +236 -0
- package/src/component/garmin/transform/bloodPressure.ts +39 -0
- package/src/component/garmin/transform/bodyCompositions.ts +51 -0
- package/src/component/garmin/transform/dailies.ts +179 -0
- package/src/component/garmin/transform/epochs.ts +94 -0
- package/src/component/garmin/transform/healthSnapshot.ts +152 -0
- package/src/component/garmin/transform/hrvSummary.ts +56 -0
- package/src/component/garmin/transform/manuallyUpdatedActivities.ts +27 -0
- package/src/{garmin/maps/activity-type.ts → component/garmin/transform/maps/activityType.ts} +116 -116
- package/src/{garmin/maps/sleep-level.ts → component/garmin/transform/maps/sleepLevel.ts} +22 -22
- package/src/component/garmin/transform/menstrualCycleTracking.ts +48 -0
- package/src/component/garmin/transform/moveIQ.ts +48 -0
- package/src/{garmin → component/garmin/transform}/plannedWorkout.ts +328 -333
- package/src/component/garmin/transform/pulseOx.ts +64 -0
- package/src/component/garmin/transform/respiration.ts +73 -0
- package/src/component/garmin/transform/skinTemperature.ts +44 -0
- package/src/component/garmin/transform/sleeps.ts +159 -0
- package/src/component/garmin/transform/stress.ts +78 -0
- package/src/component/garmin/transform/userMetrics.ts +56 -0
- package/src/component/garmin/types/specs/training-api-workouts.json +699 -0
- package/src/component/garmin/types/specs/wellness-api.json +1 -0
- package/src/component/garmin/types/trainingApiWorkouts/client/client.gen.ts +290 -0
- package/src/component/garmin/types/trainingApiWorkouts/client/index.ts +25 -0
- package/src/component/garmin/types/trainingApiWorkouts/client/types.gen.ts +214 -0
- package/src/component/garmin/types/trainingApiWorkouts/client/utils.gen.ts +316 -0
- package/src/component/garmin/types/trainingApiWorkouts/client.gen.ts +16 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/auth.gen.ts +41 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/bodySerializer.gen.ts +82 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/params.gen.ts +169 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/pathSerializer.gen.ts +171 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/queryKeySerializer.gen.ts +117 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/serverSentEvents.gen.ts +243 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/types.gen.ts +104 -0
- package/src/component/garmin/types/trainingApiWorkouts/core/utils.gen.ts +140 -0
- package/src/component/garmin/types/trainingApiWorkouts/index.ts +4 -0
- package/src/component/garmin/types/trainingApiWorkouts/sdk.gen.ts +126 -0
- package/src/component/garmin/types/trainingApiWorkouts/types.gen.ts +387 -0
- package/src/component/garmin/types/trainingApiWorkouts/zod.gen.ts +423 -0
- package/src/component/garmin/types/wellnessApi/client/client.gen.ts +290 -0
- package/src/component/garmin/types/wellnessApi/client/index.ts +25 -0
- package/src/component/garmin/types/wellnessApi/client/types.gen.ts +214 -0
- package/src/component/garmin/types/wellnessApi/client/utils.gen.ts +316 -0
- package/src/component/garmin/types/wellnessApi/client.gen.ts +16 -0
- package/src/component/garmin/types/wellnessApi/core/auth.gen.ts +41 -0
- package/src/component/garmin/types/wellnessApi/core/bodySerializer.gen.ts +82 -0
- package/src/component/garmin/types/wellnessApi/core/params.gen.ts +169 -0
- package/src/component/garmin/types/wellnessApi/core/pathSerializer.gen.ts +171 -0
- package/src/component/garmin/types/wellnessApi/core/queryKeySerializer.gen.ts +117 -0
- package/src/component/garmin/types/wellnessApi/core/serverSentEvents.gen.ts +243 -0
- package/src/component/garmin/types/wellnessApi/core/types.gen.ts +104 -0
- package/src/component/garmin/types/wellnessApi/core/utils.gen.ts +140 -0
- package/src/component/garmin/types/wellnessApi/index.ts +4 -0
- package/src/component/garmin/types/wellnessApi/sdk.gen.ts +207 -0
- package/src/component/garmin/types/wellnessApi/types.gen.ts +2942 -0
- package/src/component/garmin/types/wellnessApi/zod.gen.ts +878 -0
- package/src/component/garmin/utils.ts +25 -0
- package/src/component/garmin/webhooks.ts +852 -0
- package/src/component/private.ts +21 -0
- package/src/component/public.ts +11 -2
- package/src/component/schema.ts +2 -1
- package/src/component/strava/private.ts +89 -0
- package/src/component/{strava.ts → strava/public.ts} +341 -404
- package/src/component/validators/activity.ts +5 -0
- package/src/component/validators/body.ts +5 -0
- package/src/component/validators/connection.ts +2 -0
- package/src/component/validators/daily.ts +20 -0
- package/src/component/validators/menstruation.ts +5 -1
- package/src/component/validators/plannedWorkout.ts +9 -0
- package/src/validators.ts +12 -2
- package/dist/component/garmin.d.ts.map +0 -1
- package/dist/component/garmin.js.map +0 -1
- package/dist/component/strava.d.ts.map +0 -1
- package/dist/component/strava.js.map +0 -1
- package/dist/garmin/activity.d.ts +0 -101
- package/dist/garmin/activity.d.ts.map +0 -1
- package/dist/garmin/activity.js +0 -207
- package/dist/garmin/activity.js.map +0 -1
- package/src/component/garmin.ts +0 -850
- package/src/garmin/activity.test.ts +0 -178
- package/src/garmin/activity.ts +0 -272
- package/src/garmin/auth.test.ts +0 -103
- package/src/garmin/body.ts +0 -59
- package/src/garmin/client.ts +0 -407
- package/src/garmin/daily.ts +0 -211
- package/src/garmin/index.ts +0 -75
- package/src/garmin/maps/activity-type.test.ts +0 -78
- package/src/garmin/menstruation.ts +0 -42
- package/src/garmin/sleep.test.ts +0 -110
- package/src/garmin/sleep.ts +0 -170
- package/src/garmin/sync.ts +0 -223
- package/src/garmin/types.ts +0 -480
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { mapActivityType } from "./activity-type.js";
|
|
3
|
-
|
|
4
|
-
describe("mapActivityType", () => {
|
|
5
|
-
it("maps running types to Terra Running (8)", () => {
|
|
6
|
-
expect(mapActivityType("RUNNING")).toBe(8);
|
|
7
|
-
expect(mapActivityType("INDOOR_RUNNING")).toBe(8);
|
|
8
|
-
expect(mapActivityType("TRAIL_RUNNING")).toBe(8);
|
|
9
|
-
expect(mapActivityType("TREADMILL_RUNNING")).toBe(8);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("maps cycling types to Terra Biking (1)", () => {
|
|
13
|
-
expect(mapActivityType("CYCLING")).toBe(1);
|
|
14
|
-
expect(mapActivityType("INDOOR_CYCLING")).toBe(1);
|
|
15
|
-
expect(mapActivityType("MOUNTAIN_BIKING")).toBe(1);
|
|
16
|
-
expect(mapActivityType("GRAVEL_CYCLING")).toBe(1);
|
|
17
|
-
expect(mapActivityType("VIRTUAL_RIDE")).toBe(1);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("maps WALKING to Terra Walking (7)", () => {
|
|
21
|
-
expect(mapActivityType("WALKING")).toBe(7);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("maps HIKING to Terra Hiking (35)", () => {
|
|
25
|
-
expect(mapActivityType("HIKING")).toBe(35);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("maps swimming types to Terra Swimming (82)", () => {
|
|
29
|
-
expect(mapActivityType("SWIMMING")).toBe(82);
|
|
30
|
-
expect(mapActivityType("OPEN_WATER_SWIMMING")).toBe(82);
|
|
31
|
-
expect(mapActivityType("LAP_SWIMMING")).toBe(82);
|
|
32
|
-
expect(mapActivityType("POOL_SWIMMING")).toBe(82);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("maps snow sports correctly", () => {
|
|
36
|
-
expect(mapActivityType("ALPINE_SKIING")).toBe(66);
|
|
37
|
-
expect(mapActivityType("CROSS_COUNTRY_SKIING")).toBe(67);
|
|
38
|
-
expect(mapActivityType("SNOWBOARDING")).toBe(73);
|
|
39
|
-
expect(mapActivityType("SNOWSHOEING")).toBe(74);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("maps water sports correctly", () => {
|
|
43
|
-
expect(mapActivityType("ROWING")).toBe(53);
|
|
44
|
-
expect(mapActivityType("INDOOR_ROWING")).toBe(53);
|
|
45
|
-
expect(mapActivityType("KAYAKING")).toBe(40);
|
|
46
|
-
expect(mapActivityType("SAILING")).toBe(59);
|
|
47
|
-
expect(mapActivityType("SURFING")).toBe(81);
|
|
48
|
-
expect(mapActivityType("KITESURFING")).toBe(41);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("maps racket sports correctly", () => {
|
|
52
|
-
expect(mapActivityType("TENNIS")).toBe(87);
|
|
53
|
-
expect(mapActivityType("TABLE_TENNIS")).toBe(85);
|
|
54
|
-
expect(mapActivityType("BADMINTON")).toBe(10);
|
|
55
|
-
expect(mapActivityType("SQUASH")).toBe(76);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("maps gym/fitness activities correctly", () => {
|
|
59
|
-
expect(mapActivityType("STRENGTH_TRAINING")).toBe(80);
|
|
60
|
-
expect(mapActivityType("CROSSFIT")).toBe(113);
|
|
61
|
-
expect(mapActivityType("YOGA")).toBe(100);
|
|
62
|
-
expect(mapActivityType("PILATES")).toBe(49);
|
|
63
|
-
expect(mapActivityType("HIIT")).toBe(114);
|
|
64
|
-
expect(mapActivityType("ELLIPTICAL")).toBe(25);
|
|
65
|
-
expect(mapActivityType("STAIR_CLIMBING")).toBe(78);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("maps team sports correctly", () => {
|
|
69
|
-
expect(mapActivityType("SOCCER")).toBe(29);
|
|
70
|
-
expect(mapActivityType("BASKETBALL")).toBe(11);
|
|
71
|
-
expect(mapActivityType("VOLLEYBALL")).toBe(94);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("returns Terra Other (108) for unknown types", () => {
|
|
75
|
-
expect(mapActivityType("UNKNOWN_SPORT" as never)).toBe(108);
|
|
76
|
-
expect(mapActivityType("" as never)).toBe(108);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// ─── Menstruation Transformer ────────────────────────────────────────────────
|
|
2
|
-
// Transforms Garmin menstrual cycle data into the Soma Menstruation schema shape.
|
|
3
|
-
|
|
4
|
-
import type { GarminMenstrualCycleData } from "./types.js";
|
|
5
|
-
|
|
6
|
-
export type MenstruationData = ReturnType<typeof transformMenstruation>;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Transform a Garmin menstrual cycle record into a Soma Menstruation document shape.
|
|
10
|
-
*
|
|
11
|
-
* @param data - The Garmin menstrual cycle data from the Health API
|
|
12
|
-
* @returns Soma Menstruation fields (without connectionId/userId)
|
|
13
|
-
*/
|
|
14
|
-
export function transformMenstruation(data: GarminMenstrualCycleData) {
|
|
15
|
-
const dateStr = data.calendarDate;
|
|
16
|
-
const startTime = data.startTimeInSeconds
|
|
17
|
-
? new Date(data.startTimeInSeconds * 1000).toISOString()
|
|
18
|
-
: `${dateStr}T00:00:00.000Z`;
|
|
19
|
-
const endTime = data.startTimeInSeconds
|
|
20
|
-
? new Date(
|
|
21
|
-
(data.startTimeInSeconds + 86400) * 1000,
|
|
22
|
-
).toISOString()
|
|
23
|
-
: `${dateStr}T23:59:59.999Z`;
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
metadata: {
|
|
27
|
-
start_time: startTime,
|
|
28
|
-
end_time: endTime,
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
menstruation_data: {
|
|
32
|
-
day_in_cycle: data.dayInCycle,
|
|
33
|
-
current_phase: data.currentPhase?.toLowerCase(),
|
|
34
|
-
length_of_current_phase_days: data.lengthOfCurrentPhase,
|
|
35
|
-
period_length_days: data.periodLength,
|
|
36
|
-
predicted_cycle_length_days: data.predictedCycleLength,
|
|
37
|
-
is_predicted_cycle: data.isPredictedCycle != null
|
|
38
|
-
? String(data.isPredictedCycle)
|
|
39
|
-
: undefined,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
package/src/garmin/sleep.test.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { transformSleep } from "./sleep.js";
|
|
3
|
-
import type { GarminSleep } from "./types.js";
|
|
4
|
-
|
|
5
|
-
const baseSleep: GarminSleep = {
|
|
6
|
-
userId: "garmin_user_1",
|
|
7
|
-
userAccessToken: "token",
|
|
8
|
-
summaryId: "sleep_001",
|
|
9
|
-
calendarDate: "2023-11-14",
|
|
10
|
-
startTimeInSeconds: 1700000000,
|
|
11
|
-
startTimeOffsetInSeconds: -18000,
|
|
12
|
-
durationInSeconds: 28800, // 8 hours
|
|
13
|
-
validation: "ENHANCED_FINAL",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
describe("transformSleep", () => {
|
|
17
|
-
it("maps metadata correctly", () => {
|
|
18
|
-
const result = transformSleep(baseSleep);
|
|
19
|
-
|
|
20
|
-
expect(result.metadata.summary_id).toBe("sleep_001");
|
|
21
|
-
expect(result.metadata.start_time).toBe("2023-11-14T22:13:20.000Z");
|
|
22
|
-
expect(result.metadata.end_time).toBe("2023-11-15T06:13:20.000Z");
|
|
23
|
-
expect(result.metadata.upload_type).toBe(2); // ENHANCED_FINAL → Automatic
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("maps manual upload type", () => {
|
|
27
|
-
const manual = { ...baseSleep, validation: "MANUAL" as const };
|
|
28
|
-
const result = transformSleep(manual);
|
|
29
|
-
expect(result.metadata.upload_type).toBe(1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("maps tentative as indeterminate", () => {
|
|
33
|
-
const tentative = { ...baseSleep, validation: "AUTO_TENTATIVE" as const };
|
|
34
|
-
const result = transformSleep(tentative);
|
|
35
|
-
expect(result.metadata.upload_type).toBe(4);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("maps sleep stage durations", () => {
|
|
39
|
-
const withStages: GarminSleep = {
|
|
40
|
-
...baseSleep,
|
|
41
|
-
deepSleepDurationInSeconds: 7200,
|
|
42
|
-
lightSleepDurationInSeconds: 14400,
|
|
43
|
-
remSleepInSeconds: 5400,
|
|
44
|
-
awakeDurationInSeconds: 1800,
|
|
45
|
-
};
|
|
46
|
-
const result = transformSleep(withStages);
|
|
47
|
-
|
|
48
|
-
const durations = result.sleep_durations_data;
|
|
49
|
-
expect(durations.asleep.duration_deep_sleep_state_seconds).toBe(7200);
|
|
50
|
-
expect(durations.asleep.duration_light_sleep_state_seconds).toBe(14400);
|
|
51
|
-
expect(durations.asleep.duration_REM_sleep_state_seconds).toBe(5400);
|
|
52
|
-
expect(durations.asleep.duration_asleep_state_seconds).toBe(27000);
|
|
53
|
-
expect(durations.awake!.duration_awake_state_seconds).toBe(1800);
|
|
54
|
-
expect(durations.other!.duration_in_bed_seconds).toBe(28800);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("maps sleep levels hypnogram", () => {
|
|
58
|
-
const withLevels: GarminSleep = {
|
|
59
|
-
...baseSleep,
|
|
60
|
-
sleepLevelsMap: {
|
|
61
|
-
deep: [
|
|
62
|
-
{ startTimeInSeconds: 1700003600, endTimeInSeconds: 1700007200 },
|
|
63
|
-
],
|
|
64
|
-
light: [
|
|
65
|
-
{ startTimeInSeconds: 1700000000, endTimeInSeconds: 1700003600 },
|
|
66
|
-
],
|
|
67
|
-
rem: [
|
|
68
|
-
{ startTimeInSeconds: 1700010800, endTimeInSeconds: 1700014400 },
|
|
69
|
-
],
|
|
70
|
-
awake: [
|
|
71
|
-
{ startTimeInSeconds: 1700007200, endTimeInSeconds: 1700010800 },
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
const result = transformSleep(withLevels);
|
|
76
|
-
const samples = result.sleep_durations_data.hypnogram_samples;
|
|
77
|
-
|
|
78
|
-
expect(samples).toBeDefined();
|
|
79
|
-
expect(samples).toHaveLength(4);
|
|
80
|
-
// Sorted by timestamp
|
|
81
|
-
expect(samples![0].level).toBe(4); // Light
|
|
82
|
-
expect(samples![1].level).toBe(5); // Deep
|
|
83
|
-
expect(samples![2].level).toBe(1); // Awake
|
|
84
|
-
expect(samples![3].level).toBe(6); // REM
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("maps respiration data", () => {
|
|
88
|
-
const withResp: GarminSleep = {
|
|
89
|
-
...baseSleep,
|
|
90
|
-
averageRespirationInBreathsPerMinute: 16,
|
|
91
|
-
lowestRespirationInBreathsPerMinute: 12,
|
|
92
|
-
highestRespirationInBreathsPerMinute: 22,
|
|
93
|
-
timeOffsetSleepRespiration: {
|
|
94
|
-
"0": 16,
|
|
95
|
-
"3600": 14,
|
|
96
|
-
"7200": 12,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
const result = transformSleep(withResp);
|
|
100
|
-
|
|
101
|
-
expect(result.respiration_data).toBeDefined();
|
|
102
|
-
expect(result.respiration_data!.breaths_data!.avg_breaths_per_min).toBe(16);
|
|
103
|
-
expect(result.respiration_data!.breaths_data!.samples).toHaveLength(3);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("returns undefined respiration_data when no respiration fields", () => {
|
|
107
|
-
const result = transformSleep(baseSleep);
|
|
108
|
-
expect(result.respiration_data).toBeUndefined();
|
|
109
|
-
});
|
|
110
|
-
});
|
package/src/garmin/sleep.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// ─── Sleep Transformer ───────────────────────────────────────────────────────
|
|
2
|
-
// Transforms a Garmin sleep session into the Soma Sleep schema shape.
|
|
3
|
-
|
|
4
|
-
import type { GarminSleep, GarminSleepLevel } from "./types.js";
|
|
5
|
-
import { mapSleepLevel } from "./maps/sleep-level.js";
|
|
6
|
-
|
|
7
|
-
export type SleepData = ReturnType<typeof transformSleep>;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Transform a Garmin sleep session into a Soma Sleep document shape.
|
|
11
|
-
*
|
|
12
|
-
* @param sleep - The Garmin sleep data from the Health API
|
|
13
|
-
* @returns Soma Sleep fields (without connectionId/userId)
|
|
14
|
-
*/
|
|
15
|
-
export function transformSleep(sleep: GarminSleep) {
|
|
16
|
-
const startMs = sleep.startTimeInSeconds * 1000;
|
|
17
|
-
const endMs = startMs + sleep.durationInSeconds * 1000;
|
|
18
|
-
|
|
19
|
-
const uploadTypeMap: Record<string, number> = {
|
|
20
|
-
ENHANCED_FINAL: 2, // Automatic
|
|
21
|
-
ENHANCED_TENTATIVE: 4, // Indeterminate
|
|
22
|
-
AUTO_FINAL: 2, // Automatic
|
|
23
|
-
AUTO_TENTATIVE: 4, // Indeterminate
|
|
24
|
-
MANUAL: 1, // Manual
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
metadata: {
|
|
29
|
-
summary_id: sleep.summaryId,
|
|
30
|
-
start_time: new Date(startMs).toISOString(),
|
|
31
|
-
end_time: new Date(endMs).toISOString(),
|
|
32
|
-
upload_type: uploadTypeMap[sleep.validation] ?? 0,
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
sleep_durations_data: buildSleepDurationsData(sleep),
|
|
36
|
-
|
|
37
|
-
heart_rate_data: buildHeartRateData(sleep),
|
|
38
|
-
|
|
39
|
-
respiration_data: buildRespirationData(sleep),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
44
|
-
|
|
45
|
-
function buildSleepDurationsData(sleep: GarminSleep) {
|
|
46
|
-
const totalAsleep =
|
|
47
|
-
(sleep.deepSleepDurationInSeconds ?? 0) +
|
|
48
|
-
(sleep.lightSleepDurationInSeconds ?? 0) +
|
|
49
|
-
(sleep.remSleepInSeconds ?? 0);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
asleep: {
|
|
53
|
-
duration_asleep_state_seconds: totalAsleep || undefined,
|
|
54
|
-
duration_deep_sleep_state_seconds: sleep.deepSleepDurationInSeconds,
|
|
55
|
-
duration_light_sleep_state_seconds: sleep.lightSleepDurationInSeconds,
|
|
56
|
-
duration_REM_sleep_state_seconds: sleep.remSleepInSeconds,
|
|
57
|
-
},
|
|
58
|
-
awake: {
|
|
59
|
-
duration_awake_state_seconds: sleep.awakeDurationInSeconds,
|
|
60
|
-
},
|
|
61
|
-
other: {
|
|
62
|
-
duration_in_bed_seconds: sleep.durationInSeconds,
|
|
63
|
-
duration_unmeasurable_sleep_seconds: sleep.unmeasurableSleepInSeconds,
|
|
64
|
-
},
|
|
65
|
-
hypnogram_samples: buildHypnogramSamples(sleep),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function buildHypnogramSamples(sleep: GarminSleep) {
|
|
70
|
-
if (!sleep.sleepLevelsMap) return undefined;
|
|
71
|
-
|
|
72
|
-
const samples: Array<{ timestamp: string; level: number }> = [];
|
|
73
|
-
|
|
74
|
-
for (const [stage, levels] of Object.entries(sleep.sleepLevelsMap)) {
|
|
75
|
-
if (!levels) continue;
|
|
76
|
-
const terraLevel = mapSleepLevel(stage);
|
|
77
|
-
|
|
78
|
-
for (const level of levels as GarminSleepLevel[]) {
|
|
79
|
-
samples.push({
|
|
80
|
-
timestamp: new Date(level.startTimeInSeconds * 1000).toISOString(),
|
|
81
|
-
level: terraLevel,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
samples.sort(
|
|
87
|
-
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
return samples.length > 0 ? samples : undefined;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function buildHeartRateData(sleep: GarminSleep) {
|
|
94
|
-
if (
|
|
95
|
-
!sleep.timeOffsetHeartRateSamples ||
|
|
96
|
-
Object.keys(sleep.timeOffsetHeartRateSamples).length === 0
|
|
97
|
-
) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const hrSamples = Object.entries(sleep.timeOffsetHeartRateSamples).map(
|
|
102
|
-
([offset, bpm]) => ({
|
|
103
|
-
timestamp: new Date(
|
|
104
|
-
(sleep.startTimeInSeconds + parseInt(offset, 10)) * 1000,
|
|
105
|
-
).toISOString(),
|
|
106
|
-
bpm,
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
detailed: { hr_samples: hrSamples },
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function buildRespirationData(sleep: GarminSleep) {
|
|
116
|
-
const hasBreathSummary =
|
|
117
|
-
sleep.averageRespirationInBreathsPerMinute != null;
|
|
118
|
-
const hasBreathSamples =
|
|
119
|
-
sleep.timeOffsetSleepRespiration != null &&
|
|
120
|
-
Object.keys(sleep.timeOffsetSleepRespiration).length > 0;
|
|
121
|
-
const hasSpO2Samples =
|
|
122
|
-
sleep.timeOffsetSpo2Values != null &&
|
|
123
|
-
Object.keys(sleep.timeOffsetSpo2Values).length > 0;
|
|
124
|
-
|
|
125
|
-
if (!hasBreathSummary && !hasBreathSamples && !hasSpO2Samples) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const breathSamples = hasBreathSamples
|
|
130
|
-
? Object.entries(sleep.timeOffsetSleepRespiration!).map(
|
|
131
|
-
([offset, rate]) => ({
|
|
132
|
-
timestamp: new Date(
|
|
133
|
-
(sleep.startTimeInSeconds + parseInt(offset, 10)) * 1000,
|
|
134
|
-
).toISOString(),
|
|
135
|
-
breaths_per_min: rate,
|
|
136
|
-
}),
|
|
137
|
-
)
|
|
138
|
-
: undefined;
|
|
139
|
-
|
|
140
|
-
const spo2Samples = hasSpO2Samples
|
|
141
|
-
? Object.entries(sleep.timeOffsetSpo2Values!).map(([offset, pct]) => ({
|
|
142
|
-
timestamp: new Date(
|
|
143
|
-
(sleep.startTimeInSeconds + parseInt(offset, 10)) * 1000,
|
|
144
|
-
).toISOString(),
|
|
145
|
-
percentage: pct,
|
|
146
|
-
}))
|
|
147
|
-
: undefined;
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
breaths_data:
|
|
151
|
-
hasBreathSummary || (breathSamples && breathSamples.length > 0)
|
|
152
|
-
? {
|
|
153
|
-
avg_breaths_per_min: sleep.averageRespirationInBreathsPerMinute,
|
|
154
|
-
min_breaths_per_min: sleep.lowestRespirationInBreathsPerMinute,
|
|
155
|
-
max_breaths_per_min: sleep.highestRespirationInBreathsPerMinute,
|
|
156
|
-
samples:
|
|
157
|
-
breathSamples && breathSamples.length > 0
|
|
158
|
-
? breathSamples
|
|
159
|
-
: undefined,
|
|
160
|
-
}
|
|
161
|
-
: undefined,
|
|
162
|
-
oxygen_saturation_data:
|
|
163
|
-
spo2Samples && spo2Samples.length > 0
|
|
164
|
-
? {
|
|
165
|
-
avg_saturation_percentage: sleep.averageSpo2Value,
|
|
166
|
-
samples: spo2Samples,
|
|
167
|
-
}
|
|
168
|
-
: undefined,
|
|
169
|
-
};
|
|
170
|
-
}
|
package/src/garmin/sync.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
// ─── Garmin Sync Helpers ─────────────────────────────────────────────────────
|
|
2
|
-
// High-level functions that combine the Garmin client, transformers,
|
|
3
|
-
// and Soma ingestion. Designed to be used inside a Convex action.
|
|
4
|
-
|
|
5
|
-
import type { Soma } from "../client/index.js";
|
|
6
|
-
import type { ActionCtx } from "../client/types.js";
|
|
7
|
-
import type { GarminClient } from "./client.js";
|
|
8
|
-
import type { TimeRangeParams } from "./client.js";
|
|
9
|
-
import { transformActivity } from "./activity.js";
|
|
10
|
-
import { transformDaily } from "./daily.js";
|
|
11
|
-
import { transformSleep } from "./sleep.js";
|
|
12
|
-
import { transformBody } from "./body.js";
|
|
13
|
-
import { transformMenstruation } from "./menstruation.js";
|
|
14
|
-
|
|
15
|
-
// ─── Shared Types ────────────────────────────────────────────────────────────
|
|
16
|
-
|
|
17
|
-
export interface SyncOptions {
|
|
18
|
-
client: GarminClient;
|
|
19
|
-
soma: Soma;
|
|
20
|
-
ctx: ActionCtx;
|
|
21
|
-
connectionId: string;
|
|
22
|
-
userId: string;
|
|
23
|
-
timeRange: TimeRangeParams;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface SyncResult {
|
|
27
|
-
synced: number;
|
|
28
|
-
errors: Array<{ id: string; error: string }>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface SyncAllResult {
|
|
32
|
-
activities: SyncResult;
|
|
33
|
-
dailies: SyncResult;
|
|
34
|
-
sleep: SyncResult;
|
|
35
|
-
body: SyncResult;
|
|
36
|
-
menstruation: SyncResult;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ─── Sync All ────────────────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Sync all data types from Garmin for a given time range.
|
|
43
|
-
*
|
|
44
|
-
* Runs each sync independently so a failure in one type doesn't
|
|
45
|
-
* block the others.
|
|
46
|
-
*/
|
|
47
|
-
export async function syncAll(opts: SyncOptions): Promise<SyncAllResult> {
|
|
48
|
-
const [activities, dailies, sleep, body, menstruation] = await Promise.all([
|
|
49
|
-
syncActivities(opts),
|
|
50
|
-
syncDailies(opts),
|
|
51
|
-
syncSleep(opts),
|
|
52
|
-
syncBody(opts),
|
|
53
|
-
syncMenstruation(opts),
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
return { activities, dailies, sleep, body, menstruation };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ─── Activities ──────────────────────────────────────────────────────────────
|
|
60
|
-
|
|
61
|
-
export async function syncActivities(opts: SyncOptions): Promise<SyncResult> {
|
|
62
|
-
const { client, soma, ctx, connectionId, userId, timeRange } = opts;
|
|
63
|
-
let synced = 0;
|
|
64
|
-
const errors: SyncResult["errors"] = [];
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const activities = await client.getActivities(timeRange);
|
|
68
|
-
|
|
69
|
-
for (const activity of activities) {
|
|
70
|
-
try {
|
|
71
|
-
const data = transformActivity(activity);
|
|
72
|
-
await soma.ingestActivity(ctx, { connectionId, userId, ...data });
|
|
73
|
-
synced++;
|
|
74
|
-
} catch (err) {
|
|
75
|
-
errors.push({
|
|
76
|
-
id: activity.summaryId ?? String(activity.activityId),
|
|
77
|
-
error: err instanceof Error ? err.message : String(err),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} catch (err) {
|
|
82
|
-
errors.push({
|
|
83
|
-
id: "fetch",
|
|
84
|
-
error: err instanceof Error ? err.message : String(err),
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return { synced, errors };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ─── Dailies ─────────────────────────────────────────────────────────────────
|
|
92
|
-
|
|
93
|
-
export async function syncDailies(opts: SyncOptions): Promise<SyncResult> {
|
|
94
|
-
const { client, soma, ctx, connectionId, userId, timeRange } = opts;
|
|
95
|
-
let synced = 0;
|
|
96
|
-
const errors: SyncResult["errors"] = [];
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
const dailies = await client.getDailies(timeRange);
|
|
100
|
-
|
|
101
|
-
for (const daily of dailies) {
|
|
102
|
-
try {
|
|
103
|
-
const data = transformDaily(daily);
|
|
104
|
-
await soma.ingestDaily(ctx, { connectionId, userId, ...data });
|
|
105
|
-
synced++;
|
|
106
|
-
} catch (err) {
|
|
107
|
-
errors.push({
|
|
108
|
-
id: daily.summaryId ?? daily.calendarDate,
|
|
109
|
-
error: err instanceof Error ? err.message : String(err),
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
} catch (err) {
|
|
114
|
-
errors.push({
|
|
115
|
-
id: "fetch",
|
|
116
|
-
error: err instanceof Error ? err.message : String(err),
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return { synced, errors };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ─── Sleep ───────────────────────────────────────────────────────────────────
|
|
124
|
-
|
|
125
|
-
export async function syncSleep(opts: SyncOptions): Promise<SyncResult> {
|
|
126
|
-
const { client, soma, ctx, connectionId, userId, timeRange } = opts;
|
|
127
|
-
let synced = 0;
|
|
128
|
-
const errors: SyncResult["errors"] = [];
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
const sleeps = await client.getSleeps(timeRange);
|
|
132
|
-
|
|
133
|
-
for (const sleep of sleeps) {
|
|
134
|
-
try {
|
|
135
|
-
const data = transformSleep(sleep);
|
|
136
|
-
await soma.ingestSleep(ctx, { connectionId, userId, ...data });
|
|
137
|
-
synced++;
|
|
138
|
-
} catch (err) {
|
|
139
|
-
errors.push({
|
|
140
|
-
id: sleep.summaryId ?? sleep.calendarDate,
|
|
141
|
-
error: err instanceof Error ? err.message : String(err),
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (err) {
|
|
146
|
-
errors.push({
|
|
147
|
-
id: "fetch",
|
|
148
|
-
error: err instanceof Error ? err.message : String(err),
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return { synced, errors };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// ─── Body Composition ────────────────────────────────────────────────────────
|
|
156
|
-
|
|
157
|
-
export async function syncBody(opts: SyncOptions): Promise<SyncResult> {
|
|
158
|
-
const { client, soma, ctx, connectionId, userId, timeRange } = opts;
|
|
159
|
-
let synced = 0;
|
|
160
|
-
const errors: SyncResult["errors"] = [];
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
const bodyComps = await client.getBodyCompositions(timeRange);
|
|
164
|
-
|
|
165
|
-
for (const body of bodyComps) {
|
|
166
|
-
try {
|
|
167
|
-
const data = transformBody(body);
|
|
168
|
-
await soma.ingestBody(ctx, { connectionId, userId, ...data });
|
|
169
|
-
synced++;
|
|
170
|
-
} catch (err) {
|
|
171
|
-
errors.push({
|
|
172
|
-
id: body.summaryId ?? String(body.measurementTimeInSeconds),
|
|
173
|
-
error: err instanceof Error ? err.message : String(err),
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
} catch (err) {
|
|
178
|
-
errors.push({
|
|
179
|
-
id: "fetch",
|
|
180
|
-
error: err instanceof Error ? err.message : String(err),
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return { synced, errors };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// ─── Menstruation ────────────────────────────────────────────────────────────
|
|
188
|
-
|
|
189
|
-
export async function syncMenstruation(
|
|
190
|
-
opts: SyncOptions,
|
|
191
|
-
): Promise<SyncResult> {
|
|
192
|
-
const { client, soma, ctx, connectionId, userId, timeRange } = opts;
|
|
193
|
-
let synced = 0;
|
|
194
|
-
const errors: SyncResult["errors"] = [];
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
const records = await client.getMenstrualCycleData(timeRange);
|
|
198
|
-
|
|
199
|
-
for (const record of records) {
|
|
200
|
-
try {
|
|
201
|
-
const data = transformMenstruation(record);
|
|
202
|
-
await soma.ingestMenstruation(ctx, {
|
|
203
|
-
connectionId,
|
|
204
|
-
userId,
|
|
205
|
-
...data,
|
|
206
|
-
});
|
|
207
|
-
synced++;
|
|
208
|
-
} catch (err) {
|
|
209
|
-
errors.push({
|
|
210
|
-
id: record.summaryId ?? record.calendarDate,
|
|
211
|
-
error: err instanceof Error ? err.message : String(err),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
} catch (err) {
|
|
216
|
-
errors.push({
|
|
217
|
-
id: "fetch",
|
|
218
|
-
error: err instanceof Error ? err.message : String(err),
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return { synced, errors };
|
|
223
|
-
}
|