@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.
Files changed (390) hide show
  1. package/dist/client/index.d.ts +17 -55
  2. package/dist/client/index.d.ts.map +1 -1
  3. package/dist/client/index.js +63 -13
  4. package/dist/client/index.js.map +1 -1
  5. package/dist/component/_generated/api.d.ts +80 -4
  6. package/dist/component/_generated/api.d.ts.map +1 -1
  7. package/dist/component/_generated/api.js.map +1 -1
  8. package/dist/component/_generated/component.d.ts +153 -120
  9. package/dist/component/_generated/component.d.ts.map +1 -1
  10. package/dist/component/garmin/private.d.ts +475 -0
  11. package/dist/component/garmin/private.d.ts.map +1 -0
  12. package/dist/component/garmin/private.js +1614 -0
  13. package/dist/component/garmin/private.js.map +1 -0
  14. package/dist/component/{garmin.d.ts → garmin/public.d.ts} +25 -52
  15. package/dist/component/garmin/public.d.ts.map +1 -0
  16. package/dist/component/{garmin.js → garmin/public.js} +301 -215
  17. package/dist/component/garmin/public.js.map +1 -0
  18. package/dist/component/garmin/schemas/activity.d.ts +94 -0
  19. package/dist/component/garmin/schemas/activity.d.ts.map +1 -0
  20. package/dist/component/garmin/schemas/activity.js +27 -0
  21. package/dist/component/garmin/schemas/activity.js.map +1 -0
  22. package/dist/component/garmin/schemas/activityDetails.d.ts +146 -0
  23. package/dist/component/garmin/schemas/activityDetails.d.ts.map +1 -0
  24. package/dist/component/garmin/schemas/activityDetails.js +27 -0
  25. package/dist/component/garmin/schemas/activityDetails.js.map +1 -0
  26. package/dist/component/garmin/schemas/bloodPressure.d.ts +38 -0
  27. package/dist/component/garmin/schemas/bloodPressure.d.ts.map +1 -0
  28. package/dist/component/garmin/schemas/bloodPressure.js +27 -0
  29. package/dist/component/garmin/schemas/bloodPressure.js.map +1 -0
  30. package/dist/component/garmin/schemas/bodyCompositions.d.ts +42 -0
  31. package/dist/component/garmin/schemas/bodyCompositions.d.ts.map +1 -0
  32. package/dist/component/garmin/schemas/bodyCompositions.js +27 -0
  33. package/dist/component/garmin/schemas/bodyCompositions.js.map +1 -0
  34. package/dist/component/garmin/schemas/dailies.d.ts +98 -0
  35. package/dist/component/garmin/schemas/dailies.d.ts.map +1 -0
  36. package/dist/component/garmin/schemas/dailies.js +27 -0
  37. package/dist/component/garmin/schemas/dailies.js.map +1 -0
  38. package/dist/component/garmin/schemas/epochs.d.ts +54 -0
  39. package/dist/component/garmin/schemas/epochs.d.ts.map +1 -0
  40. package/dist/component/garmin/schemas/epochs.js +27 -0
  41. package/dist/component/garmin/schemas/epochs.js.map +1 -0
  42. package/dist/component/garmin/schemas/healthSnapshot.d.ts +48 -0
  43. package/dist/component/garmin/schemas/healthSnapshot.d.ts.map +1 -0
  44. package/dist/component/garmin/schemas/healthSnapshot.js +27 -0
  45. package/dist/component/garmin/schemas/healthSnapshot.js.map +1 -0
  46. package/dist/component/garmin/schemas/hrvSummary.d.ts +40 -0
  47. package/dist/component/garmin/schemas/hrvSummary.d.ts.map +1 -0
  48. package/dist/component/garmin/schemas/hrvSummary.js +27 -0
  49. package/dist/component/garmin/schemas/hrvSummary.js.map +1 -0
  50. package/dist/component/garmin/schemas/manuallyUpdatedActivities.d.ts +94 -0
  51. package/dist/component/garmin/schemas/manuallyUpdatedActivities.d.ts.map +1 -0
  52. package/dist/component/garmin/schemas/manuallyUpdatedActivities.js +27 -0
  53. package/dist/component/garmin/schemas/manuallyUpdatedActivities.js.map +1 -0
  54. package/dist/component/garmin/schemas/menstrualCycleTracking.d.ts +100 -0
  55. package/dist/component/garmin/schemas/menstrualCycleTracking.d.ts.map +1 -0
  56. package/dist/component/garmin/schemas/menstrualCycleTracking.js +28 -0
  57. package/dist/component/garmin/schemas/menstrualCycleTracking.js.map +1 -0
  58. package/dist/component/garmin/schemas/moveIQ.d.ts +40 -0
  59. package/dist/component/garmin/schemas/moveIQ.d.ts.map +1 -0
  60. package/dist/component/garmin/schemas/moveIQ.js +27 -0
  61. package/dist/component/garmin/schemas/moveIQ.js.map +1 -0
  62. package/dist/component/garmin/schemas/pulseOx.d.ts +38 -0
  63. package/dist/component/garmin/schemas/pulseOx.d.ts.map +1 -0
  64. package/dist/component/garmin/schemas/pulseOx.js +28 -0
  65. package/dist/component/garmin/schemas/pulseOx.js.map +1 -0
  66. package/dist/component/garmin/schemas/respiration.d.ts +34 -0
  67. package/dist/component/garmin/schemas/respiration.d.ts.map +1 -0
  68. package/dist/component/garmin/schemas/respiration.js +28 -0
  69. package/dist/component/garmin/schemas/respiration.js.map +1 -0
  70. package/dist/component/garmin/schemas/skinTemperature.d.ts +36 -0
  71. package/dist/component/garmin/schemas/skinTemperature.d.ts.map +1 -0
  72. package/dist/component/garmin/schemas/skinTemperature.js +28 -0
  73. package/dist/component/garmin/schemas/skinTemperature.js.map +1 -0
  74. package/dist/component/garmin/schemas/sleeps.d.ts +88 -0
  75. package/dist/component/garmin/schemas/sleeps.d.ts.map +1 -0
  76. package/dist/component/garmin/schemas/sleeps.js +27 -0
  77. package/dist/component/garmin/schemas/sleeps.js.map +1 -0
  78. package/dist/component/garmin/schemas/stress.d.ts +70 -0
  79. package/dist/component/garmin/schemas/stress.d.ts.map +1 -0
  80. package/dist/component/garmin/schemas/stress.js +28 -0
  81. package/dist/component/garmin/schemas/stress.js.map +1 -0
  82. package/dist/component/garmin/schemas/userMetrics.d.ts +36 -0
  83. package/dist/component/garmin/schemas/userMetrics.d.ts.map +1 -0
  84. package/dist/component/garmin/schemas/userMetrics.js +28 -0
  85. package/dist/component/garmin/schemas/userMetrics.js.map +1 -0
  86. package/dist/component/garmin/transform/activity.d.ts +13 -0
  87. package/dist/component/garmin/transform/activity.d.ts.map +1 -0
  88. package/dist/component/garmin/transform/activity.js +111 -0
  89. package/dist/component/garmin/transform/activity.js.map +1 -0
  90. package/dist/component/garmin/transform/activityDetails.d.ts +13 -0
  91. package/dist/component/garmin/transform/activityDetails.d.ts.map +1 -0
  92. package/dist/component/garmin/transform/activityDetails.js +173 -0
  93. package/dist/component/garmin/transform/activityDetails.js.map +1 -0
  94. package/dist/component/garmin/transform/bloodPressure.d.ts +12 -0
  95. package/dist/component/garmin/transform/bloodPressure.d.ts.map +1 -0
  96. package/dist/component/garmin/transform/bloodPressure.js +33 -0
  97. package/dist/component/garmin/transform/bloodPressure.js.map +1 -0
  98. package/dist/component/garmin/transform/bodyCompositions.d.ts +12 -0
  99. package/dist/component/garmin/transform/bodyCompositions.d.ts.map +1 -0
  100. package/dist/component/garmin/transform/bodyCompositions.js +42 -0
  101. package/dist/component/garmin/transform/bodyCompositions.js.map +1 -0
  102. package/dist/component/garmin/transform/dailies.d.ts +12 -0
  103. package/dist/component/garmin/transform/dailies.d.ts.map +1 -0
  104. package/dist/component/garmin/transform/dailies.js +132 -0
  105. package/dist/component/garmin/transform/dailies.js.map +1 -0
  106. package/dist/component/garmin/transform/epochs.d.ts +13 -0
  107. package/dist/component/garmin/transform/epochs.d.ts.map +1 -0
  108. package/dist/component/garmin/transform/epochs.js +76 -0
  109. package/dist/component/garmin/transform/epochs.js.map +1 -0
  110. package/dist/component/garmin/transform/healthSnapshot.d.ts +12 -0
  111. package/dist/component/garmin/transform/healthSnapshot.d.ts.map +1 -0
  112. package/dist/component/garmin/transform/healthSnapshot.js +111 -0
  113. package/dist/component/garmin/transform/healthSnapshot.js.map +1 -0
  114. package/dist/component/garmin/transform/hrvSummary.d.ts +12 -0
  115. package/dist/component/garmin/transform/hrvSummary.d.ts.map +1 -0
  116. package/dist/component/garmin/transform/hrvSummary.js +45 -0
  117. package/dist/component/garmin/transform/hrvSummary.js.map +1 -0
  118. package/dist/component/garmin/transform/manuallyUpdatedActivities.d.ts +11 -0
  119. package/dist/component/garmin/transform/manuallyUpdatedActivities.d.ts.map +1 -0
  120. package/dist/component/garmin/transform/manuallyUpdatedActivities.js +20 -0
  121. package/dist/component/garmin/transform/manuallyUpdatedActivities.js.map +1 -0
  122. package/dist/component/garmin/transform/menstrualCycleTracking.d.ts +10 -0
  123. package/dist/component/garmin/transform/menstrualCycleTracking.d.ts.map +1 -0
  124. package/dist/component/garmin/transform/menstrualCycleTracking.js +43 -0
  125. package/dist/component/garmin/transform/menstrualCycleTracking.js.map +1 -0
  126. package/dist/component/garmin/transform/moveIQ.d.ts +17 -0
  127. package/dist/component/garmin/transform/moveIQ.d.ts.map +1 -0
  128. package/dist/component/garmin/transform/moveIQ.js +41 -0
  129. package/dist/component/garmin/transform/moveIQ.js.map +1 -0
  130. package/dist/component/garmin/transform/pulseOx.d.ts +12 -0
  131. package/dist/component/garmin/transform/pulseOx.d.ts.map +1 -0
  132. package/dist/component/garmin/transform/pulseOx.js +46 -0
  133. package/dist/component/garmin/transform/pulseOx.js.map +1 -0
  134. package/dist/component/garmin/transform/respiration.d.ts +12 -0
  135. package/dist/component/garmin/transform/respiration.d.ts.map +1 -0
  136. package/dist/component/garmin/transform/respiration.js +54 -0
  137. package/dist/component/garmin/transform/respiration.js.map +1 -0
  138. package/dist/component/garmin/transform/skinTemperature.d.ts +12 -0
  139. package/dist/component/garmin/transform/skinTemperature.d.ts.map +1 -0
  140. package/dist/component/garmin/transform/skinTemperature.js +38 -0
  141. package/dist/component/garmin/transform/skinTemperature.js.map +1 -0
  142. package/dist/component/garmin/transform/sleeps.d.ts +55 -0
  143. package/dist/component/garmin/transform/sleeps.d.ts.map +1 -0
  144. package/dist/component/garmin/transform/sleeps.js +120 -0
  145. package/dist/component/garmin/transform/sleeps.js.map +1 -0
  146. package/dist/component/garmin/transform/stress.d.ts +12 -0
  147. package/dist/component/garmin/transform/stress.d.ts.map +1 -0
  148. package/dist/component/garmin/transform/stress.js +56 -0
  149. package/dist/component/garmin/transform/stress.js.map +1 -0
  150. package/dist/component/garmin/transform/userMetrics.d.ts +12 -0
  151. package/dist/component/garmin/transform/userMetrics.d.ts.map +1 -0
  152. package/dist/component/garmin/transform/userMetrics.js +48 -0
  153. package/dist/component/garmin/transform/userMetrics.js.map +1 -0
  154. package/dist/component/garmin/types/garmin.d.ts +21 -0
  155. package/dist/component/garmin/types/garmin.d.ts.map +1 -0
  156. package/dist/component/garmin/types/garmin.js +6 -0
  157. package/dist/component/garmin/types/garmin.js.map +1 -0
  158. package/dist/component/garmin/types/zod/zod.gen.d.ts +1319 -0
  159. package/dist/component/garmin/types/zod/zod.gen.d.ts.map +1 -0
  160. package/dist/component/garmin/types/zod/zod.gen.js +784 -0
  161. package/dist/component/garmin/types/zod/zod.gen.js.map +1 -0
  162. package/dist/component/garmin/webhooks.d.ts +141 -0
  163. package/dist/component/garmin/webhooks.d.ts.map +1 -0
  164. package/dist/component/garmin/webhooks.js +766 -0
  165. package/dist/component/garmin/webhooks.js.map +1 -0
  166. package/dist/component/private.d.ts +20 -2
  167. package/dist/component/private.d.ts.map +1 -1
  168. package/dist/component/private.js +18 -0
  169. package/dist/component/private.js.map +1 -1
  170. package/dist/component/public.d.ts +433 -387
  171. package/dist/component/public.d.ts.map +1 -1
  172. package/dist/component/public.js +12 -2
  173. package/dist/component/public.js.map +1 -1
  174. package/dist/component/schema.d.ts +217 -162
  175. package/dist/component/schema.d.ts.map +1 -1
  176. package/dist/component/schema.js +2 -1
  177. package/dist/component/schema.js.map +1 -1
  178. package/dist/component/strava/private.d.ts +30 -0
  179. package/dist/component/strava/private.d.ts.map +1 -0
  180. package/dist/component/strava/private.js +71 -0
  181. package/dist/component/strava/private.js.map +1 -0
  182. package/dist/component/{strava.d.ts → strava/public.d.ts} +3 -31
  183. package/dist/component/strava/public.d.ts.map +1 -0
  184. package/dist/component/{strava.js → strava/public.js} +22 -101
  185. package/dist/component/strava/public.js.map +1 -0
  186. package/dist/component/validators/activity.d.ts +6 -0
  187. package/dist/component/validators/activity.d.ts.map +1 -1
  188. package/dist/component/validators/activity.js.map +1 -1
  189. package/dist/component/validators/body.d.ts +20 -14
  190. package/dist/component/validators/body.d.ts.map +1 -1
  191. package/dist/component/validators/body.js.map +1 -1
  192. package/dist/component/validators/connection.d.ts +1 -0
  193. package/dist/component/validators/connection.d.ts.map +1 -1
  194. package/dist/component/validators/connection.js +2 -0
  195. package/dist/component/validators/connection.js.map +1 -1
  196. package/dist/component/validators/daily.d.ts +46 -5
  197. package/dist/component/validators/daily.d.ts.map +1 -1
  198. package/dist/component/validators/daily.js +10 -1
  199. package/dist/component/validators/daily.js.map +1 -1
  200. package/dist/component/validators/enums.d.ts +2 -2
  201. package/dist/component/validators/menstruation.d.ts +5 -0
  202. package/dist/component/validators/menstruation.d.ts.map +1 -1
  203. package/dist/component/validators/menstruation.js.map +1 -1
  204. package/dist/component/validators/plannedWorkout.d.ts +5 -1
  205. package/dist/component/validators/plannedWorkout.d.ts.map +1 -1
  206. package/dist/component/validators/plannedWorkout.js +4 -0
  207. package/dist/component/validators/plannedWorkout.js.map +1 -1
  208. package/dist/component/validators/sleep.d.ts +8 -8
  209. package/dist/garmin/bloodPressure.d.ts +28 -0
  210. package/dist/garmin/bloodPressure.d.ts.map +1 -0
  211. package/dist/garmin/bloodPressure.js +34 -0
  212. package/dist/garmin/bloodPressure.js.map +1 -0
  213. package/dist/garmin/body.js +1 -1
  214. package/dist/garmin/body.js.map +1 -1
  215. package/dist/garmin/client.d.ts +117 -17
  216. package/dist/garmin/client.d.ts.map +1 -1
  217. package/dist/garmin/client.js +337 -43
  218. package/dist/garmin/client.js.map +1 -1
  219. package/dist/garmin/daily.d.ts.map +1 -1
  220. package/dist/garmin/daily.js +3 -3
  221. package/dist/garmin/daily.js.map +1 -1
  222. package/dist/garmin/hrv.d.ts +30 -0
  223. package/dist/garmin/hrv.d.ts.map +1 -0
  224. package/dist/garmin/hrv.js +45 -0
  225. package/dist/garmin/hrv.js.map +1 -0
  226. package/dist/garmin/index.d.ts +16 -4
  227. package/dist/garmin/index.d.ts.map +1 -1
  228. package/dist/garmin/index.js +8 -2
  229. package/dist/garmin/index.js.map +1 -1
  230. package/dist/garmin/maps/activity-type.d.ts +1 -2
  231. package/dist/garmin/maps/activity-type.d.ts.map +1 -1
  232. package/dist/garmin/maps/activity-type.js +1 -0
  233. package/dist/garmin/maps/activity-type.js.map +1 -1
  234. package/dist/garmin/menstruation.d.ts +6 -4
  235. package/dist/garmin/menstruation.d.ts.map +1 -1
  236. package/dist/garmin/menstruation.js +12 -8
  237. package/dist/garmin/menstruation.js.map +1 -1
  238. package/dist/garmin/pulseOx.d.ts +24 -0
  239. package/dist/garmin/pulseOx.d.ts.map +1 -0
  240. package/dist/garmin/pulseOx.js +33 -0
  241. package/dist/garmin/pulseOx.js.map +1 -0
  242. package/dist/garmin/respiration.d.ts +29 -0
  243. package/dist/garmin/respiration.d.ts.map +1 -0
  244. package/dist/garmin/respiration.js +42 -0
  245. package/dist/garmin/respiration.js.map +1 -0
  246. package/dist/garmin/skinTemp.d.ts +27 -0
  247. package/dist/garmin/skinTemp.d.ts.map +1 -0
  248. package/dist/garmin/skinTemp.js +35 -0
  249. package/dist/garmin/skinTemp.js.map +1 -0
  250. package/dist/garmin/sleep.d.ts +4 -4
  251. package/dist/garmin/sleep.d.ts.map +1 -1
  252. package/dist/garmin/sleep.js +15 -9
  253. package/dist/garmin/sleep.js.map +1 -1
  254. package/dist/garmin/stressDetails.d.ts +30 -0
  255. package/dist/garmin/stressDetails.d.ts.map +1 -0
  256. package/dist/garmin/stressDetails.js +49 -0
  257. package/dist/garmin/stressDetails.js.map +1 -0
  258. package/dist/garmin/sync.d.ts +14 -0
  259. package/dist/garmin/sync.d.ts.map +1 -1
  260. package/dist/garmin/sync.js +290 -7
  261. package/dist/garmin/sync.js.map +1 -1
  262. package/dist/garmin/types.d.ts +77 -186
  263. package/dist/garmin/types.d.ts.map +1 -1
  264. package/dist/garmin/types.js +4 -2
  265. package/dist/garmin/types.js.map +1 -1
  266. package/dist/garmin/userMetrics.d.ts +23 -0
  267. package/dist/garmin/userMetrics.d.ts.map +1 -0
  268. package/dist/garmin/userMetrics.js +41 -0
  269. package/dist/garmin/userMetrics.js.map +1 -0
  270. package/dist/validators.d.ts +138 -56
  271. package/dist/validators.d.ts.map +1 -1
  272. package/dist/validators.js +2 -2
  273. package/dist/validators.js.map +1 -1
  274. package/package.json +130 -124
  275. package/src/client/index.ts +86 -18
  276. package/src/component/_generated/api.ts +96 -4
  277. package/src/component/_generated/component.ts +271 -144
  278. package/src/{garmin → component/garmin}/auth.ts +8 -1
  279. package/src/component/garmin/client.ts +39 -0
  280. package/src/component/garmin/private.ts +1798 -0
  281. package/src/component/garmin/public.ts +938 -0
  282. package/src/component/garmin/schemas/activity.ts +40 -0
  283. package/src/component/garmin/schemas/activityDetails.ts +45 -0
  284. package/src/component/garmin/schemas/bloodPressure.ts +38 -0
  285. package/src/component/garmin/schemas/bodyCompositions.ts +38 -0
  286. package/src/component/garmin/schemas/dailies.ts +38 -0
  287. package/src/component/garmin/schemas/epochs.ts +38 -0
  288. package/src/component/garmin/schemas/healthSnapshot.ts +38 -0
  289. package/src/component/garmin/schemas/hrvSummary.ts +38 -0
  290. package/src/component/garmin/schemas/manuallyUpdatedActivities.ts +49 -0
  291. package/src/component/garmin/schemas/menstrualCycleTracking.ts +39 -0
  292. package/src/component/garmin/schemas/moveIQ.ts +38 -0
  293. package/src/component/garmin/schemas/pulseOx.ts +39 -0
  294. package/src/component/garmin/schemas/respiration.ts +39 -0
  295. package/src/component/garmin/schemas/skinTemperature.ts +39 -0
  296. package/src/component/garmin/schemas/sleeps.ts +38 -0
  297. package/src/component/garmin/schemas/stress.ts +43 -0
  298. package/src/component/garmin/schemas/userMetrics.ts +39 -0
  299. package/src/component/garmin/transform/activity.ts +143 -0
  300. package/src/component/garmin/transform/activityDetails.ts +236 -0
  301. package/src/component/garmin/transform/bloodPressure.ts +39 -0
  302. package/src/component/garmin/transform/bodyCompositions.ts +51 -0
  303. package/src/component/garmin/transform/dailies.ts +179 -0
  304. package/src/component/garmin/transform/epochs.ts +94 -0
  305. package/src/component/garmin/transform/healthSnapshot.ts +152 -0
  306. package/src/component/garmin/transform/hrvSummary.ts +56 -0
  307. package/src/component/garmin/transform/manuallyUpdatedActivities.ts +27 -0
  308. package/src/{garmin/maps/activity-type.ts → component/garmin/transform/maps/activityType.ts} +116 -116
  309. package/src/{garmin/maps/sleep-level.ts → component/garmin/transform/maps/sleepLevel.ts} +22 -22
  310. package/src/component/garmin/transform/menstrualCycleTracking.ts +48 -0
  311. package/src/component/garmin/transform/moveIQ.ts +48 -0
  312. package/src/{garmin → component/garmin/transform}/plannedWorkout.ts +328 -333
  313. package/src/component/garmin/transform/pulseOx.ts +64 -0
  314. package/src/component/garmin/transform/respiration.ts +73 -0
  315. package/src/component/garmin/transform/skinTemperature.ts +44 -0
  316. package/src/component/garmin/transform/sleeps.ts +159 -0
  317. package/src/component/garmin/transform/stress.ts +78 -0
  318. package/src/component/garmin/transform/userMetrics.ts +56 -0
  319. package/src/component/garmin/types/specs/training-api-workouts.json +699 -0
  320. package/src/component/garmin/types/specs/wellness-api.json +1 -0
  321. package/src/component/garmin/types/trainingApiWorkouts/client/client.gen.ts +290 -0
  322. package/src/component/garmin/types/trainingApiWorkouts/client/index.ts +25 -0
  323. package/src/component/garmin/types/trainingApiWorkouts/client/types.gen.ts +214 -0
  324. package/src/component/garmin/types/trainingApiWorkouts/client/utils.gen.ts +316 -0
  325. package/src/component/garmin/types/trainingApiWorkouts/client.gen.ts +16 -0
  326. package/src/component/garmin/types/trainingApiWorkouts/core/auth.gen.ts +41 -0
  327. package/src/component/garmin/types/trainingApiWorkouts/core/bodySerializer.gen.ts +82 -0
  328. package/src/component/garmin/types/trainingApiWorkouts/core/params.gen.ts +169 -0
  329. package/src/component/garmin/types/trainingApiWorkouts/core/pathSerializer.gen.ts +171 -0
  330. package/src/component/garmin/types/trainingApiWorkouts/core/queryKeySerializer.gen.ts +117 -0
  331. package/src/component/garmin/types/trainingApiWorkouts/core/serverSentEvents.gen.ts +243 -0
  332. package/src/component/garmin/types/trainingApiWorkouts/core/types.gen.ts +104 -0
  333. package/src/component/garmin/types/trainingApiWorkouts/core/utils.gen.ts +140 -0
  334. package/src/component/garmin/types/trainingApiWorkouts/index.ts +4 -0
  335. package/src/component/garmin/types/trainingApiWorkouts/sdk.gen.ts +126 -0
  336. package/src/component/garmin/types/trainingApiWorkouts/types.gen.ts +387 -0
  337. package/src/component/garmin/types/trainingApiWorkouts/zod.gen.ts +423 -0
  338. package/src/component/garmin/types/wellnessApi/client/client.gen.ts +290 -0
  339. package/src/component/garmin/types/wellnessApi/client/index.ts +25 -0
  340. package/src/component/garmin/types/wellnessApi/client/types.gen.ts +214 -0
  341. package/src/component/garmin/types/wellnessApi/client/utils.gen.ts +316 -0
  342. package/src/component/garmin/types/wellnessApi/client.gen.ts +16 -0
  343. package/src/component/garmin/types/wellnessApi/core/auth.gen.ts +41 -0
  344. package/src/component/garmin/types/wellnessApi/core/bodySerializer.gen.ts +82 -0
  345. package/src/component/garmin/types/wellnessApi/core/params.gen.ts +169 -0
  346. package/src/component/garmin/types/wellnessApi/core/pathSerializer.gen.ts +171 -0
  347. package/src/component/garmin/types/wellnessApi/core/queryKeySerializer.gen.ts +117 -0
  348. package/src/component/garmin/types/wellnessApi/core/serverSentEvents.gen.ts +243 -0
  349. package/src/component/garmin/types/wellnessApi/core/types.gen.ts +104 -0
  350. package/src/component/garmin/types/wellnessApi/core/utils.gen.ts +140 -0
  351. package/src/component/garmin/types/wellnessApi/index.ts +4 -0
  352. package/src/component/garmin/types/wellnessApi/sdk.gen.ts +207 -0
  353. package/src/component/garmin/types/wellnessApi/types.gen.ts +2942 -0
  354. package/src/component/garmin/types/wellnessApi/zod.gen.ts +878 -0
  355. package/src/component/garmin/utils.ts +25 -0
  356. package/src/component/garmin/webhooks.ts +852 -0
  357. package/src/component/private.ts +21 -0
  358. package/src/component/public.ts +11 -2
  359. package/src/component/schema.ts +2 -1
  360. package/src/component/strava/private.ts +89 -0
  361. package/src/component/{strava.ts → strava/public.ts} +341 -404
  362. package/src/component/validators/activity.ts +5 -0
  363. package/src/component/validators/body.ts +5 -0
  364. package/src/component/validators/connection.ts +2 -0
  365. package/src/component/validators/daily.ts +20 -0
  366. package/src/component/validators/menstruation.ts +5 -1
  367. package/src/component/validators/plannedWorkout.ts +9 -0
  368. package/src/validators.ts +12 -2
  369. package/dist/component/garmin.d.ts.map +0 -1
  370. package/dist/component/garmin.js.map +0 -1
  371. package/dist/component/strava.d.ts.map +0 -1
  372. package/dist/component/strava.js.map +0 -1
  373. package/dist/garmin/activity.d.ts +0 -101
  374. package/dist/garmin/activity.d.ts.map +0 -1
  375. package/dist/garmin/activity.js +0 -207
  376. package/dist/garmin/activity.js.map +0 -1
  377. package/src/component/garmin.ts +0 -850
  378. package/src/garmin/activity.test.ts +0 -178
  379. package/src/garmin/activity.ts +0 -272
  380. package/src/garmin/auth.test.ts +0 -103
  381. package/src/garmin/body.ts +0 -59
  382. package/src/garmin/client.ts +0 -407
  383. package/src/garmin/daily.ts +0 -211
  384. package/src/garmin/index.ts +0 -75
  385. package/src/garmin/maps/activity-type.test.ts +0 -78
  386. package/src/garmin/menstruation.ts +0 -42
  387. package/src/garmin/sleep.test.ts +0 -110
  388. package/src/garmin/sleep.ts +0 -170
  389. package/src/garmin/sync.ts +0 -223
  390. package/src/garmin/types.ts +0 -480
@@ -1,333 +1,328 @@
1
- // ─── Soma Garmin Training API V2 Transformer ─────────────────────────────
2
- // Maps Soma's Terra-style planned workout model to the Garmin Training API V2
3
- // JSON format for workout creation and scheduling.
4
-
5
- import type {
6
- GarminWorkout,
7
- GarminWorkoutSegment,
8
- GarminWorkoutStep,
9
- GarminWorkoutRepeatStep,
10
- GarminWorkoutSport,
11
- GarminStepIntensity,
12
- GarminDurationType,
13
- GarminTargetType,
14
- } from "./types.js";
15
-
16
- // ─── Public API ──────────────────────────────────────────────────────────────
17
-
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- type SomaPlannedWorkout = Record<string, any>;
20
-
21
- /**
22
- * Transform a Soma planned workout document into a Garmin Training API V2
23
- * workout payload ready for `POST /workoutportal/workout/v2`.
24
- *
25
- * @param somaWorkout - The planned workout document from the Soma DB
26
- * @param providerName - Name shown to the user in Garmin Connect (20 chars max)
27
- */
28
- export function transformPlannedWorkoutToGarmin(
29
- somaWorkout: SomaPlannedWorkout,
30
- providerName: string,
31
- ): GarminWorkout {
32
- const metadata = somaWorkout.metadata ?? {};
33
- const sport = mapSportType(metadata.type);
34
- const steps = transformSteps(somaWorkout.steps ?? []);
35
-
36
- const segment: GarminWorkoutSegment = {
37
- segmentOrder: 1,
38
- sport,
39
- poolLength: metadata.pool_length_meters ?? null,
40
- poolLengthUnit: metadata.pool_length_meters != null ? "METER" : null,
41
- estimatedDurationInSecs: null,
42
- estimatedDistanceInMeters: null,
43
- steps,
44
- };
45
-
46
- return {
47
- workoutName: metadata.name ?? "Workout",
48
- description: metadata.description ?? null,
49
- sport,
50
- estimatedDurationInSecs: null,
51
- estimatedDistanceInMeters: null,
52
- poolLength: metadata.pool_length_meters ?? null,
53
- poolLengthUnit: metadata.pool_length_meters != null ? "METER" : null,
54
- workoutProvider: providerName.slice(0, 20),
55
- workoutSourceId: providerName.slice(0, 20),
56
- isSessionTransitionEnabled: false,
57
- segments: [segment],
58
- };
59
- }
60
-
61
- // ─── Step Transformation ─────────────────────────────────────────────────────
62
-
63
- function transformSteps(
64
- somaSteps: Array<Record<string, unknown>>,
65
- ): Array<GarminWorkoutStep | GarminWorkoutRepeatStep> {
66
- const result: Array<GarminWorkoutStep | GarminWorkoutRepeatStep> = [];
67
- let order = 1;
68
-
69
- for (const step of somaSteps) {
70
- const stepType = String(step.type ?? "STEP").toUpperCase();
71
-
72
- if (stepType === "REPEAT_STEP") {
73
- const nestedSteps = Array.isArray(step.steps) ? step.steps : [];
74
- const reps = extractRepeatCount(step);
75
-
76
- const repeatStep: GarminWorkoutRepeatStep = {
77
- type: "WorkoutRepeatStep",
78
- stepOrder: order++,
79
- repeatType: "REPEAT_UNTIL_STEPS_CMPLT",
80
- repeatValue: reps,
81
- steps: transformSteps(nestedSteps),
82
- };
83
- result.push(repeatStep);
84
- } else {
85
- const workoutStep = transformSingleStep(step, order++);
86
- result.push(workoutStep);
87
- }
88
- }
89
-
90
- return result;
91
- }
92
-
93
- function transformSingleStep(
94
- step: Record<string, unknown>,
95
- stepOrder: number,
96
- ): GarminWorkoutStep {
97
- const { durationType, durationValue, durationValueType } =
98
- extractDuration(step);
99
- const { targetType, targetValueLow, targetValueHigh, targetValueType } =
100
- extractTarget(step);
101
-
102
- return {
103
- type: "WorkoutStep",
104
- stepOrder,
105
- intensity: mapIntensity(step.intensity),
106
- description: (step.description as string) ?? null,
107
- durationType,
108
- durationValue,
109
- durationValueType,
110
- targetType,
111
- targetValue: null,
112
- targetValueLow,
113
- targetValueHigh,
114
- targetValueType,
115
- secondaryTargetType: null,
116
- secondaryTargetValue: null,
117
- secondaryTargetValueLow: null,
118
- secondaryTargetValueHigh: null,
119
- secondaryTargetValueType: null,
120
- strokeType: (step.stroke_type as string) ?? null,
121
- drillType: null,
122
- equipmentType: (step.equipment_type as string) ?? null,
123
- exerciseCategory: (step.exercise_category as string) ?? null,
124
- exerciseName: (step.exercise_name as string) ?? null,
125
- weightValue: (step.weight_kg as number) ?? null,
126
- weightDisplayUnit: step.weight_kg != null ? "KILOGRAM" : null,
127
- };
128
- }
129
-
130
- // ─── Duration Extraction ─────────────────────────────────────────────────────
131
-
132
- interface DurationResult {
133
- durationType: GarminDurationType;
134
- durationValue: number | null;
135
- durationValueType: string | null;
136
- }
137
-
138
- function extractDuration(step: Record<string, unknown>): DurationResult {
139
- const durations = step.durations as Array<Record<string, unknown>> | undefined;
140
- if (!durations || durations.length === 0) {
141
- return { durationType: "OPEN", durationValue: null, durationValueType: null };
142
- }
143
-
144
- const dur = durations[0];
145
- const type = String(dur.duration_type ?? "OPEN").toUpperCase();
146
-
147
- switch (type) {
148
- case "TIME":
149
- return {
150
- durationType: "TIME",
151
- durationValue: (dur.seconds as number) ?? null,
152
- durationValueType: null,
153
- };
154
- case "DISTANCE_METERS":
155
- case "DISTANCE":
156
- return {
157
- durationType: "DISTANCE",
158
- durationValue: (dur.distance_meters as number) ?? null,
159
- durationValueType: null,
160
- };
161
- case "HR_LESS_THAN":
162
- return {
163
- durationType: "HR_LESS_THAN",
164
- durationValue: (dur.hr_below_bpm as number) ?? null,
165
- durationValueType: null,
166
- };
167
- case "HR_GREATER_THAN":
168
- return {
169
- durationType: "HR_GREATER_THAN",
170
- durationValue: (dur.hr_above_bpm as number) ?? null,
171
- durationValueType: null,
172
- };
173
- case "CALORIES":
174
- return {
175
- durationType: "CALORIES",
176
- durationValue: (dur.calories as number) ?? null,
177
- durationValueType: null,
178
- };
179
- case "POWER_LESS_THAN":
180
- return {
181
- durationType: "POWER_LESS_THAN",
182
- durationValue: (dur.power_below_watts as number) ?? null,
183
- durationValueType: null,
184
- };
185
- case "POWER_GREATER_THAN":
186
- return {
187
- durationType: "POWER_GREATER_THAN",
188
- durationValue: (dur.power_above_watts as number) ?? null,
189
- durationValueType: null,
190
- };
191
- case "REPS":
192
- return {
193
- durationType: "REPS",
194
- durationValue: (dur.reps as number) ?? null,
195
- durationValueType: null,
196
- };
197
- case "FIXED_REST":
198
- return {
199
- durationType: "FIXED_REST",
200
- durationValue: (dur.rest_seconds as number) ?? (dur.seconds as number) ?? null,
201
- durationValueType: null,
202
- };
203
- default:
204
- return { durationType: "OPEN", durationValue: null, durationValueType: null };
205
- }
206
- }
207
-
208
- // ─── Target Extraction ───────────────────────────────────────────────────────
209
-
210
- interface TargetResult {
211
- targetType: GarminTargetType | null;
212
- targetValueLow: number | null;
213
- targetValueHigh: number | null;
214
- targetValueType: string | null;
215
- }
216
-
217
- function extractTarget(step: Record<string, unknown>): TargetResult {
218
- const targets = step.targets as Array<Record<string, unknown>> | undefined;
219
- if (!targets || targets.length === 0) {
220
- return { targetType: null, targetValueLow: null, targetValueHigh: null, targetValueType: null };
221
- }
222
-
223
- const target = targets[0];
224
- const type = String(target.target_type ?? "OPEN").toUpperCase();
225
-
226
- switch (type) {
227
- case "HEART_RATE":
228
- if (target.hr_percentage_low != null || target.hr_percentage_high != null) {
229
- return {
230
- targetType: "HEART_RATE",
231
- targetValueLow: (target.hr_percentage_low as number) ?? null,
232
- targetValueHigh: (target.hr_percentage_high as number) ?? null,
233
- targetValueType: "PERCENT",
234
- };
235
- }
236
- return {
237
- targetType: "HEART_RATE",
238
- targetValueLow: (target.hr_bpm_low as number) ?? null,
239
- targetValueHigh: (target.hr_bpm_high as number) ?? null,
240
- targetValueType: null,
241
- };
242
-
243
- case "SPEED":
244
- case "PACE":
245
- return {
246
- targetType: "SPEED",
247
- targetValueLow: (target.speed_meters_per_second as number) ?? null,
248
- targetValueHigh: (target.speed_meters_per_second as number) ?? null,
249
- targetValueType: null,
250
- };
251
-
252
- case "CADENCE":
253
- return {
254
- targetType: "CADENCE",
255
- targetValueLow: (target.cadence_low as number) ?? (target.cadence as number) ?? null,
256
- targetValueHigh: (target.cadence_high as number) ?? (target.cadence as number) ?? null,
257
- targetValueType: null,
258
- };
259
-
260
- case "POWER":
261
- if (target.power_percentage_low != null || target.power_percentage_high != null) {
262
- return {
263
- targetType: "POWER",
264
- targetValueLow: (target.power_percentage_low as number) ?? null,
265
- targetValueHigh: (target.power_percentage_high as number) ?? null,
266
- targetValueType: "PERCENT",
267
- };
268
- }
269
- return {
270
- targetType: "POWER",
271
- targetValueLow: (target.power_watt_low as number) ?? (target.power_watt as number) ?? null,
272
- targetValueHigh: (target.power_watt_high as number) ?? (target.power_watt as number) ?? null,
273
- targetValueType: null,
274
- };
275
-
276
- case "OPEN":
277
- return { targetType: "OPEN", targetValueLow: null, targetValueHigh: null, targetValueType: null };
278
-
279
- default:
280
- return { targetType: null, targetValueLow: null, targetValueHigh: null, targetValueType: null };
281
- }
282
- }
283
-
284
- // ─── Enum Mapping ────────────────────────────────────────────────────────────
285
-
286
- const SPORT_MAP: Record<string, GarminWorkoutSport> = {
287
- RUNNING: "RUNNING",
288
- BIKING: "CYCLING",
289
- CYCLING: "CYCLING",
290
- SWIMMING: "LAP_SWIMMING",
291
- LAP_SWIMMING: "LAP_SWIMMING",
292
- STRENGTH_TRAINING: "STRENGTH_TRAINING",
293
- STRENGTH: "STRENGTH_TRAINING",
294
- CARDIO: "CARDIO_TRAINING",
295
- CARDIO_TRAINING: "CARDIO_TRAINING",
296
- YOGA: "YOGA",
297
- PILATES: "PILATES",
298
- MULTI_SPORT: "MULTI_SPORT",
299
- GENERIC: "GENERIC",
300
- HIIT: "CARDIO_TRAINING",
301
- };
302
-
303
- function mapSportType(type: string | undefined): GarminWorkoutSport {
304
- if (!type) return "RUNNING";
305
- return SPORT_MAP[type.toUpperCase()] ?? "GENERIC";
306
- }
307
-
308
- const INTENSITY_MAP: Record<string, GarminStepIntensity> = {
309
- REST: "REST",
310
- WARMUP: "WARMUP",
311
- WARM_UP: "WARMUP",
312
- COOLDOWN: "COOLDOWN",
313
- COOL_DOWN: "COOLDOWN",
314
- RECOVERY: "RECOVERY",
315
- ACTIVE: "ACTIVE",
316
- INTERVAL: "INTERVAL",
317
- MAIN: "MAIN",
318
- };
319
-
320
- function mapIntensity(value: unknown): GarminStepIntensity {
321
- if (value == null) return "ACTIVE";
322
- const str = String(value).toUpperCase();
323
- return INTENSITY_MAP[str] ?? "ACTIVE";
324
- }
325
-
326
- function extractRepeatCount(step: Record<string, unknown>): number {
327
- const durations = step.durations as Array<Record<string, unknown>> | undefined;
328
- if (durations && durations.length > 0) {
329
- const reps = durations[0].reps as number | undefined;
330
- if (reps != null) return reps;
331
- }
332
- return 1;
333
- }
1
+ // ─── Planned Workout Transformer ─────────────────────────────────────────────
2
+ // Transforms a Soma planned workout document into a Garmin Training API V2
3
+ // workout payload ready for `POST /workoutportal/workout/v2`.
4
+
5
+ import type { SomaPlannedWorkout } from "../../validators/plannedWorkout.js";
6
+ import type {
7
+ WorkoutV2,
8
+ Segment,
9
+ WorkoutStep,
10
+ WorkoutRepeatStep,
11
+ } from "../types/trainingApiWorkouts/types.gen.js";
12
+
13
+ // ─── Public API ──────────────────────────────────────────────────────────────
14
+
15
+ /**
16
+ * Transform a Soma planned workout document into a Garmin Training API V2
17
+ * workout payload ready for `POST /workoutportal/workout/v2`.
18
+ *
19
+ * @param somaWorkout - The planned workout document from the Soma DB
20
+ * @param providerName - Name shown to the user in Garmin Connect (20 chars max)
21
+ */
22
+ export function transformPlannedWorkoutToGarmin(
23
+ somaWorkout: SomaPlannedWorkout,
24
+ providerName: string,
25
+ ): WorkoutV2 {
26
+ const metadata = somaWorkout.metadata;
27
+ const sport = mapSportType(metadata.type);
28
+ const steps = transformSteps(somaWorkout.steps ?? []);
29
+
30
+ const segment: Segment = {
31
+ segmentOrder: 1,
32
+ sport,
33
+ poolLength: metadata.pool_length_meters ?? undefined,
34
+ poolLengthUnit: metadata.pool_length_meters != null ? "METER" : undefined,
35
+ steps,
36
+ };
37
+
38
+ return {
39
+ workoutName: metadata.name ?? "Workout",
40
+ description: metadata.description ?? undefined,
41
+ sport,
42
+ poolLength: metadata.pool_length_meters ?? undefined,
43
+ poolLengthUnit: metadata.pool_length_meters != null ? "METER" : undefined,
44
+ workoutProvider: providerName.slice(0, 20),
45
+ workoutSourceId: providerName.slice(0, 20),
46
+ isSessionTransitionEnabled: false,
47
+ segments: [segment],
48
+ };
49
+ }
50
+
51
+ // ─── Step Transformation ─────────────────────────────────────────────────────
52
+
53
+ type SomaStep = NonNullable<SomaPlannedWorkout["steps"]>[number];
54
+
55
+ function transformSteps(
56
+ somaSteps: SomaStep[],
57
+ ): Array<WorkoutStep | WorkoutRepeatStep> {
58
+ const result: Array<WorkoutStep | WorkoutRepeatStep> = [];
59
+ let order = 1;
60
+
61
+ for (const step of somaSteps) {
62
+ const stepType = String(step.type ?? "STEP").toUpperCase();
63
+
64
+ if (stepType === "REPEAT_STEP") {
65
+ const nestedSteps = Array.isArray(step.steps) ? step.steps : [];
66
+ const reps = extractRepeatCount(step);
67
+
68
+ const repeatStep: WorkoutRepeatStep = {
69
+ type: "WorkoutRepeatStep",
70
+ stepOrder: order++,
71
+ repeatType: "REPEAT_UNTIL_STEPS_CMPLT",
72
+ repeatValue: reps,
73
+ };
74
+ result.push(repeatStep);
75
+
76
+ // Flatten nested steps after the repeat step
77
+ for (const nested of transformSteps(nestedSteps as SomaStep[])) {
78
+ result.push(nested);
79
+ }
80
+ } else {
81
+ const workoutStep = transformSingleStep(step, order++);
82
+ result.push(workoutStep);
83
+ }
84
+ }
85
+
86
+ return result;
87
+ }
88
+
89
+ function transformSingleStep(
90
+ step: SomaStep,
91
+ stepOrder: number,
92
+ ): WorkoutStep {
93
+ const { durationType, durationValue, durationValueType } =
94
+ extractDuration(step);
95
+ const { targetType, targetValueLow, targetValueHigh, targetValueType } =
96
+ extractTarget(step);
97
+
98
+ return {
99
+ type: "WorkoutStep",
100
+ stepOrder,
101
+ intensity: mapIntensity(step.intensity),
102
+ description: step.description ?? undefined,
103
+ durationType,
104
+ durationValue,
105
+ durationValueType,
106
+ targetType,
107
+ targetValueLow,
108
+ targetValueHigh,
109
+ targetValueType,
110
+ strokeType: step.stroke_type as WorkoutStep["strokeType"],
111
+ equipmentType: step.equipment_type as WorkoutStep["equipmentType"],
112
+ exerciseCategory: step.exercise_category ?? undefined,
113
+ exerciseName: step.exercise_name ?? undefined,
114
+ weightValue: step.weight_kg ?? undefined,
115
+ weightDisplayUnit: step.weight_kg != null ? "KILOGRAM" : undefined,
116
+ };
117
+ }
118
+
119
+ // ─── Duration Extraction ─────────────────────────────────────────────────────
120
+
121
+ type DurationType = NonNullable<WorkoutStep["durationType"]>;
122
+
123
+ interface DurationResult {
124
+ durationType: DurationType;
125
+ durationValue: number | undefined;
126
+ durationValueType: WorkoutStep["durationValueType"];
127
+ }
128
+
129
+ function extractDuration(step: SomaStep): DurationResult {
130
+ const durations = step.durations;
131
+ if (!durations || durations.length === 0) {
132
+ return { durationType: "OPEN", durationValue: undefined, durationValueType: undefined };
133
+ }
134
+
135
+ const dur = durations[0];
136
+ const type = String(dur.duration_type ?? "OPEN").toUpperCase();
137
+
138
+ switch (type) {
139
+ case "TIME":
140
+ return {
141
+ durationType: "TIME",
142
+ durationValue: dur.seconds ?? undefined,
143
+ durationValueType: undefined,
144
+ };
145
+ case "DISTANCE_METERS":
146
+ case "DISTANCE":
147
+ return {
148
+ durationType: "DISTANCE",
149
+ durationValue: dur.distance_meters ?? undefined,
150
+ durationValueType: undefined,
151
+ };
152
+ case "HR_LESS_THAN":
153
+ return {
154
+ durationType: "HR_LESS_THAN",
155
+ durationValue: dur.hr_below_bpm ?? undefined,
156
+ durationValueType: undefined,
157
+ };
158
+ case "HR_GREATER_THAN":
159
+ return {
160
+ durationType: "HR_GREATER_THAN",
161
+ durationValue: dur.hr_above_bpm ?? undefined,
162
+ durationValueType: undefined,
163
+ };
164
+ case "CALORIES":
165
+ return {
166
+ durationType: "CALORIES",
167
+ durationValue: dur.calories ?? undefined,
168
+ durationValueType: undefined,
169
+ };
170
+ case "POWER_LESS_THAN":
171
+ return {
172
+ durationType: "POWER_LESS_THAN",
173
+ durationValue: dur.power_below_watts ?? undefined,
174
+ durationValueType: undefined,
175
+ };
176
+ case "POWER_GREATER_THAN":
177
+ return {
178
+ durationType: "POWER_GREATER_THAN",
179
+ durationValue: dur.power_above_watts ?? undefined,
180
+ durationValueType: undefined,
181
+ };
182
+ case "REPS":
183
+ return {
184
+ durationType: "REPS",
185
+ durationValue: dur.reps ?? undefined,
186
+ durationValueType: undefined,
187
+ };
188
+ case "FIXED_REST":
189
+ return {
190
+ durationType: "FIXED_REST",
191
+ durationValue: dur.rest_seconds ?? dur.seconds ?? undefined,
192
+ durationValueType: undefined,
193
+ };
194
+ default:
195
+ return { durationType: "OPEN", durationValue: undefined, durationValueType: undefined };
196
+ }
197
+ }
198
+
199
+ // ─── Target Extraction ───────────────────────────────────────────────────────
200
+
201
+ interface TargetResult {
202
+ targetType: WorkoutStep["targetType"];
203
+ targetValueLow: number | undefined;
204
+ targetValueHigh: number | undefined;
205
+ targetValueType: WorkoutStep["targetValueType"];
206
+ }
207
+
208
+ function extractTarget(step: SomaStep): TargetResult {
209
+ const targets = step.targets;
210
+ if (!targets || targets.length === 0) {
211
+ return { targetType: undefined, targetValueLow: undefined, targetValueHigh: undefined, targetValueType: undefined };
212
+ }
213
+
214
+ const target = targets[0];
215
+ const type = String(target.target_type ?? "OPEN").toUpperCase();
216
+
217
+ switch (type) {
218
+ case "HEART_RATE":
219
+ if (target.hr_percentage_low != null || target.hr_percentage_high != null) {
220
+ return {
221
+ targetType: "HEART_RATE",
222
+ targetValueLow: target.hr_percentage_low ?? undefined,
223
+ targetValueHigh: target.hr_percentage_high ?? undefined,
224
+ targetValueType: "PERCENT",
225
+ };
226
+ }
227
+ return {
228
+ targetType: "HEART_RATE",
229
+ targetValueLow: target.hr_bpm_low ?? undefined,
230
+ targetValueHigh: target.hr_bpm_high ?? undefined,
231
+ targetValueType: undefined,
232
+ };
233
+
234
+ case "SPEED":
235
+ case "PACE":
236
+ return {
237
+ targetType: "SPEED",
238
+ targetValueLow: target.speed_meters_per_second ?? undefined,
239
+ targetValueHigh: target.speed_meters_per_second ?? undefined,
240
+ targetValueType: undefined,
241
+ };
242
+
243
+ case "CADENCE":
244
+ return {
245
+ targetType: "CADENCE",
246
+ targetValueLow: target.cadence_low ?? target.cadence ?? undefined,
247
+ targetValueHigh: target.cadence_high ?? target.cadence ?? undefined,
248
+ targetValueType: undefined,
249
+ };
250
+
251
+ case "POWER":
252
+ if (target.power_percentage_low != null || target.power_percentage_high != null) {
253
+ return {
254
+ targetType: "POWER",
255
+ targetValueLow: target.power_percentage_low ?? undefined,
256
+ targetValueHigh: target.power_percentage_high ?? undefined,
257
+ targetValueType: "PERCENT",
258
+ };
259
+ }
260
+ return {
261
+ targetType: "POWER",
262
+ targetValueLow: target.power_watt_low ?? target.power_watt ?? undefined,
263
+ targetValueHigh: target.power_watt_high ?? target.power_watt ?? undefined,
264
+ targetValueType: undefined,
265
+ };
266
+
267
+ case "OPEN":
268
+ return { targetType: "OPEN", targetValueLow: undefined, targetValueHigh: undefined, targetValueType: undefined };
269
+
270
+ default:
271
+ return { targetType: undefined, targetValueLow: undefined, targetValueHigh: undefined, targetValueType: undefined };
272
+ }
273
+ }
274
+
275
+ // ─── Enum Mapping ────────────────────────────────────────────────────────────
276
+
277
+ type GarminSport = NonNullable<WorkoutV2["sport"]>;
278
+
279
+ const SPORT_MAP: Record<string, GarminSport> = {
280
+ RUNNING: "RUNNING",
281
+ BIKING: "CYCLING",
282
+ CYCLING: "CYCLING",
283
+ SWIMMING: "LAP_SWIMMING",
284
+ LAP_SWIMMING: "LAP_SWIMMING",
285
+ STRENGTH_TRAINING: "STRENGTH_TRAINING",
286
+ STRENGTH: "STRENGTH_TRAINING",
287
+ CARDIO: "CARDIO_TRAINING",
288
+ CARDIO_TRAINING: "CARDIO_TRAINING",
289
+ YOGA: "YOGA",
290
+ PILATES: "PILATES",
291
+ MULTI_SPORT: "MULTI_SPORT",
292
+ GENERIC: "GENERIC",
293
+ HIIT: "HIIT",
294
+ };
295
+
296
+ function mapSportType(type: string | undefined): GarminSport {
297
+ if (!type) return "RUNNING";
298
+ return SPORT_MAP[type.toUpperCase()] ?? "GENERIC";
299
+ }
300
+
301
+ type GarminIntensity = NonNullable<WorkoutStep["intensity"]>;
302
+
303
+ const INTENSITY_MAP: Record<string, GarminIntensity> = {
304
+ REST: "REST",
305
+ WARMUP: "WARMUP",
306
+ WARM_UP: "WARMUP",
307
+ COOLDOWN: "COOLDOWN",
308
+ COOL_DOWN: "COOLDOWN",
309
+ RECOVERY: "RECOVERY",
310
+ ACTIVE: "ACTIVE",
311
+ INTERVAL: "INTERVAL",
312
+ MAIN: "MAIN",
313
+ };
314
+
315
+ function mapIntensity(value: string | number | undefined): GarminIntensity {
316
+ if (value == null) return "ACTIVE";
317
+ const str = String(value).toUpperCase();
318
+ return INTENSITY_MAP[str] ?? "ACTIVE";
319
+ }
320
+
321
+ function extractRepeatCount(step: SomaStep): number {
322
+ const durations = step.durations;
323
+ if (durations && durations.length > 0) {
324
+ const reps = durations[0].reps;
325
+ if (reps != null) return reps;
326
+ }
327
+ return 1;
328
+ }