@nativesquare/soma 0.10.2 → 0.12.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.
@@ -0,0 +1,287 @@
1
+ import type { SomaComponent } from "./index.js";
2
+ import type { ActionCtx, SomaGarminConfig } from "./types.js";
3
+ export declare class SomaGarmin {
4
+ private component;
5
+ private requireConfig;
6
+ constructor(component: SomaComponent, requireConfig: () => SomaGarminConfig);
7
+ /**
8
+ * Generate a Garmin OAuth 2.0 authorization URL with PKCE.
9
+ *
10
+ * The state and code verifier are stored inside the component automatically,
11
+ * and the callback handler registered by `registerRoutes` completes
12
+ * the flow without further host-app intervention.
13
+ *
14
+ * @param ctx - Action context from the host app
15
+ * @param opts.userId - The host app's user identifier
16
+ * @param opts.redirectUri - Optional override for the OAuth callback URL
17
+ * @returns `{ authUrl, state }`
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const { authUrl } = await soma.garmin.getAuthUrl(ctx, {
22
+ * userId: "user_123",
23
+ * redirectUri: "https://your-app.convex.site/api/garmin/callback",
24
+ * });
25
+ * // Redirect user to authUrl — the callback is handled automatically
26
+ * ```
27
+ */
28
+ getAuthUrl(ctx: ActionCtx, opts: {
29
+ userId: string;
30
+ redirectUri?: string;
31
+ }): Promise<any>;
32
+ /**
33
+ * Disconnect a user from Garmin.
34
+ *
35
+ * Deregisters the user at Garmin (best-effort), deletes stored tokens,
36
+ * and sets the connection to inactive.
37
+ *
38
+ * @param ctx - Action context from the host app
39
+ * @param args.userId - The host app's user identifier
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * await soma.garmin.disconnect(ctx, { userId: "user_123" });
44
+ * ```
45
+ */
46
+ disconnect(ctx: ActionCtx, args: {
47
+ userId: string;
48
+ }): Promise<any>;
49
+ /**
50
+ * Pull activity summaries from Garmin.
51
+ *
52
+ * Fetches activities, transforms them into the normalized Soma schema,
53
+ * and ingests them with automatic deduplication.
54
+ *
55
+ * @param ctx - Action context from the host app
56
+ * @param args.userId - The host app's user identifier
57
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
58
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
59
+ */
60
+ pullActivities(ctx: ActionCtx, args: {
61
+ userId: string;
62
+ startTimeInSeconds?: number;
63
+ endTimeInSeconds?: number;
64
+ }): Promise<any>;
65
+ /**
66
+ * Pull daily wellness summaries from Garmin.
67
+ *
68
+ * @param ctx - Action context from the host app
69
+ * @param args.userId - The host app's user identifier
70
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
71
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
72
+ */
73
+ pullDailies(ctx: ActionCtx, args: {
74
+ userId: string;
75
+ startTimeInSeconds?: number;
76
+ endTimeInSeconds?: number;
77
+ }): Promise<any>;
78
+ /**
79
+ * Pull sleep summaries from Garmin.
80
+ *
81
+ * @param ctx - Action context from the host app
82
+ * @param args.userId - The host app's user identifier
83
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
84
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
85
+ */
86
+ pullSleep(ctx: ActionCtx, args: {
87
+ userId: string;
88
+ startTimeInSeconds?: number;
89
+ endTimeInSeconds?: number;
90
+ }): Promise<any>;
91
+ /**
92
+ * Pull body composition data from Garmin.
93
+ *
94
+ * @param ctx - Action context from the host app
95
+ * @param args.userId - The host app's user identifier
96
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
97
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
98
+ */
99
+ pullBody(ctx: ActionCtx, args: {
100
+ userId: string;
101
+ startTimeInSeconds?: number;
102
+ endTimeInSeconds?: number;
103
+ }): Promise<any>;
104
+ /**
105
+ * Pull menstrual cycle tracking data from Garmin.
106
+ *
107
+ * @param ctx - Action context from the host app
108
+ * @param args.userId - The host app's user identifier
109
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
110
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
111
+ */
112
+ pullMenstruation(ctx: ActionCtx, args: {
113
+ userId: string;
114
+ startTimeInSeconds?: number;
115
+ endTimeInSeconds?: number;
116
+ }): Promise<any>;
117
+ /**
118
+ * Pull blood pressure readings from Garmin.
119
+ *
120
+ * @param ctx - Action context from the host app
121
+ * @param args.userId - The host app's user identifier
122
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
123
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
124
+ */
125
+ pullBloodPressures(ctx: ActionCtx, args: {
126
+ userId: string;
127
+ startTimeInSeconds?: number;
128
+ endTimeInSeconds?: number;
129
+ }): Promise<any>;
130
+ /**
131
+ * Pull skin temperature data from Garmin.
132
+ *
133
+ * @param ctx - Action context from the host app
134
+ * @param args.userId - The host app's user identifier
135
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
136
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
137
+ */
138
+ pullSkinTemperature(ctx: ActionCtx, args: {
139
+ userId: string;
140
+ startTimeInSeconds?: number;
141
+ endTimeInSeconds?: number;
142
+ }): Promise<any>;
143
+ /**
144
+ * Pull user metrics (VO2 max, fitness age, etc.) from Garmin.
145
+ *
146
+ * @param ctx - Action context from the host app
147
+ * @param args.userId - The host app's user identifier
148
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
149
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
150
+ */
151
+ pullUserMetrics(ctx: ActionCtx, args: {
152
+ userId: string;
153
+ startTimeInSeconds?: number;
154
+ endTimeInSeconds?: number;
155
+ }): Promise<any>;
156
+ /**
157
+ * Pull heart rate variability (HRV) summaries from Garmin.
158
+ *
159
+ * @param ctx - Action context from the host app
160
+ * @param args.userId - The host app's user identifier
161
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
162
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
163
+ */
164
+ pullHRV(ctx: ActionCtx, args: {
165
+ userId: string;
166
+ startTimeInSeconds?: number;
167
+ endTimeInSeconds?: number;
168
+ }): Promise<any>;
169
+ /**
170
+ * Pull stress detail data from Garmin.
171
+ *
172
+ * @param ctx - Action context from the host app
173
+ * @param args.userId - The host app's user identifier
174
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
175
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
176
+ */
177
+ pullStressDetails(ctx: ActionCtx, args: {
178
+ userId: string;
179
+ startTimeInSeconds?: number;
180
+ endTimeInSeconds?: number;
181
+ }): Promise<any>;
182
+ /**
183
+ * Pull pulse oximetry (SpO2) data from Garmin.
184
+ *
185
+ * @param ctx - Action context from the host app
186
+ * @param args.userId - The host app's user identifier
187
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
188
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
189
+ */
190
+ pullPulseOx(ctx: ActionCtx, args: {
191
+ userId: string;
192
+ startTimeInSeconds?: number;
193
+ endTimeInSeconds?: number;
194
+ }): Promise<any>;
195
+ /**
196
+ * Pull respiration (breathing rate) data from Garmin.
197
+ *
198
+ * @param ctx - Action context from the host app
199
+ * @param args.userId - The host app's user identifier
200
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
201
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
202
+ */
203
+ pullRespiration(ctx: ActionCtx, args: {
204
+ userId: string;
205
+ startTimeInSeconds?: number;
206
+ endTimeInSeconds?: number;
207
+ }): Promise<any>;
208
+ /**
209
+ * Pull all supported data types from Garmin in a single call.
210
+ *
211
+ * Equivalent to calling every individual `pull*` method. Automatically
212
+ * refreshes the access token if expired.
213
+ *
214
+ * @param ctx - Action context from the host app
215
+ * @param args.userId - The host app's user identifier
216
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
217
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * await soma.garmin.pullAll(ctx, { userId: "user_123" });
222
+ * ```
223
+ */
224
+ pullAll(ctx: ActionCtx, args: {
225
+ userId: string;
226
+ startTimeInSeconds?: number;
227
+ endTimeInSeconds?: number;
228
+ }): Promise<any>;
229
+ /**
230
+ * Push a planned workout to Garmin Connect.
231
+ *
232
+ * Creates the workout on the user's Garmin account from a planned
233
+ * workout stored in Soma.
234
+ *
235
+ * @param ctx - Action context from the host app
236
+ * @param args.userId - The host app's user identifier
237
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
238
+ * @param args.workoutProvider - Optional provider identifier for the workout source
239
+ */
240
+ pushWorkout(ctx: ActionCtx, args: {
241
+ userId: string;
242
+ plannedWorkoutId: string;
243
+ workoutProvider?: string;
244
+ }): Promise<any>;
245
+ /**
246
+ * Schedule a planned workout on the user's Garmin calendar.
247
+ *
248
+ * The workout must already exist on Garmin (via `pushWorkout`).
249
+ *
250
+ * @param ctx - Action context from the host app
251
+ * @param args.userId - The host app's user identifier
252
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
253
+ * @param args.date - Optional target date (YYYY-MM-DD); defaults to the workout's planned_date
254
+ */
255
+ pushSchedule(ctx: ActionCtx, args: {
256
+ userId: string;
257
+ plannedWorkoutId: string;
258
+ date?: string;
259
+ }): Promise<any>;
260
+ /**
261
+ * Delete a planned workout from Garmin Connect.
262
+ *
263
+ * Removes the workout from the user's Garmin account.
264
+ *
265
+ * @param ctx - Action context from the host app
266
+ * @param args.userId - The host app's user identifier
267
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
268
+ */
269
+ deleteWorkout(ctx: ActionCtx, args: {
270
+ userId: string;
271
+ plannedWorkoutId: string;
272
+ }): Promise<any>;
273
+ /**
274
+ * Remove a scheduled workout from the user's Garmin calendar.
275
+ *
276
+ * Unschedules the workout without deleting the workout itself.
277
+ *
278
+ * @param ctx - Action context from the host app
279
+ * @param args.userId - The host app's user identifier
280
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
281
+ */
282
+ deleteSchedule(ctx: ActionCtx, args: {
283
+ userId: string;
284
+ plannedWorkoutId: string;
285
+ }): Promise<any>;
286
+ }
287
+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AC1B;CASJ"}
@@ -0,0 +1,345 @@
1
+ export class SomaGarmin {
2
+ component;
3
+ requireConfig;
4
+ constructor(component, requireConfig) {
5
+ this.component = component;
6
+ this.requireConfig = requireConfig;
7
+ }
8
+ /**
9
+ * Generate a Garmin OAuth 2.0 authorization URL with PKCE.
10
+ *
11
+ * The state and code verifier are stored inside the component automatically,
12
+ * and the callback handler registered by `registerRoutes` completes
13
+ * the flow without further host-app intervention.
14
+ *
15
+ * @param ctx - Action context from the host app
16
+ * @param opts.userId - The host app's user identifier
17
+ * @param opts.redirectUri - Optional override for the OAuth callback URL
18
+ * @returns `{ authUrl, state }`
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const { authUrl } = await soma.garmin.getAuthUrl(ctx, {
23
+ * userId: "user_123",
24
+ * redirectUri: "https://your-app.convex.site/api/garmin/callback",
25
+ * });
26
+ * // Redirect user to authUrl — the callback is handled automatically
27
+ * ```
28
+ */
29
+ async getAuthUrl(ctx, opts) {
30
+ const config = this.requireConfig();
31
+ return await ctx.runAction(this.component.garmin.public.getGarminAuthUrl, {
32
+ clientId: config.clientId,
33
+ redirectUri: opts.redirectUri,
34
+ userId: opts.userId,
35
+ });
36
+ }
37
+ /**
38
+ * Disconnect a user from Garmin.
39
+ *
40
+ * Deregisters the user at Garmin (best-effort), deletes stored tokens,
41
+ * and sets the connection to inactive.
42
+ *
43
+ * @param ctx - Action context from the host app
44
+ * @param args.userId - The host app's user identifier
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * await soma.garmin.disconnect(ctx, { userId: "user_123" });
49
+ * ```
50
+ */
51
+ async disconnect(ctx, args) {
52
+ return await ctx.runAction(this.component.garmin.public.disconnectGarmin, args);
53
+ }
54
+ /**
55
+ * Pull activity summaries from Garmin.
56
+ *
57
+ * Fetches activities, transforms them into the normalized Soma schema,
58
+ * and ingests them with automatic deduplication.
59
+ *
60
+ * @param ctx - Action context from the host app
61
+ * @param args.userId - The host app's user identifier
62
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
63
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
64
+ */
65
+ async pullActivities(ctx, args) {
66
+ const config = this.requireConfig();
67
+ return await ctx.runAction(this.component.garmin.public.pullActivities, {
68
+ ...args,
69
+ clientId: config.clientId,
70
+ clientSecret: config.clientSecret,
71
+ });
72
+ }
73
+ /**
74
+ * Pull daily wellness summaries from Garmin.
75
+ *
76
+ * @param ctx - Action context from the host app
77
+ * @param args.userId - The host app's user identifier
78
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
79
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
80
+ */
81
+ async pullDailies(ctx, args) {
82
+ const config = this.requireConfig();
83
+ return await ctx.runAction(this.component.garmin.public.pullDailies, {
84
+ ...args,
85
+ clientId: config.clientId,
86
+ clientSecret: config.clientSecret,
87
+ });
88
+ }
89
+ /**
90
+ * Pull sleep summaries from Garmin.
91
+ *
92
+ * @param ctx - Action context from the host app
93
+ * @param args.userId - The host app's user identifier
94
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
95
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
96
+ */
97
+ async pullSleep(ctx, args) {
98
+ const config = this.requireConfig();
99
+ return await ctx.runAction(this.component.garmin.public.pullSleep, {
100
+ ...args,
101
+ clientId: config.clientId,
102
+ clientSecret: config.clientSecret,
103
+ });
104
+ }
105
+ /**
106
+ * Pull body composition data from Garmin.
107
+ *
108
+ * @param ctx - Action context from the host app
109
+ * @param args.userId - The host app's user identifier
110
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
111
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
112
+ */
113
+ async pullBody(ctx, args) {
114
+ const config = this.requireConfig();
115
+ return await ctx.runAction(this.component.garmin.public.pullBody, {
116
+ ...args,
117
+ clientId: config.clientId,
118
+ clientSecret: config.clientSecret,
119
+ });
120
+ }
121
+ /**
122
+ * Pull menstrual cycle tracking data from Garmin.
123
+ *
124
+ * @param ctx - Action context from the host app
125
+ * @param args.userId - The host app's user identifier
126
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
127
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
128
+ */
129
+ async pullMenstruation(ctx, args) {
130
+ const config = this.requireConfig();
131
+ return await ctx.runAction(this.component.garmin.public.pullMenstruation, {
132
+ ...args,
133
+ clientId: config.clientId,
134
+ clientSecret: config.clientSecret,
135
+ });
136
+ }
137
+ /**
138
+ * Pull blood pressure readings from Garmin.
139
+ *
140
+ * @param ctx - Action context from the host app
141
+ * @param args.userId - The host app's user identifier
142
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
143
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
144
+ */
145
+ async pullBloodPressures(ctx, args) {
146
+ const config = this.requireConfig();
147
+ return await ctx.runAction(this.component.garmin.public.pullBloodPressures, {
148
+ ...args,
149
+ clientId: config.clientId,
150
+ clientSecret: config.clientSecret,
151
+ });
152
+ }
153
+ /**
154
+ * Pull skin temperature data from Garmin.
155
+ *
156
+ * @param ctx - Action context from the host app
157
+ * @param args.userId - The host app's user identifier
158
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
159
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
160
+ */
161
+ async pullSkinTemperature(ctx, args) {
162
+ const config = this.requireConfig();
163
+ return await ctx.runAction(this.component.garmin.public.pullSkinTemperature, {
164
+ ...args,
165
+ clientId: config.clientId,
166
+ clientSecret: config.clientSecret,
167
+ });
168
+ }
169
+ /**
170
+ * Pull user metrics (VO2 max, fitness age, etc.) from Garmin.
171
+ *
172
+ * @param ctx - Action context from the host app
173
+ * @param args.userId - The host app's user identifier
174
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
175
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
176
+ */
177
+ async pullUserMetrics(ctx, args) {
178
+ const config = this.requireConfig();
179
+ return await ctx.runAction(this.component.garmin.public.pullUserMetrics, {
180
+ ...args,
181
+ clientId: config.clientId,
182
+ clientSecret: config.clientSecret,
183
+ });
184
+ }
185
+ /**
186
+ * Pull heart rate variability (HRV) summaries from Garmin.
187
+ *
188
+ * @param ctx - Action context from the host app
189
+ * @param args.userId - The host app's user identifier
190
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
191
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
192
+ */
193
+ async pullHRV(ctx, args) {
194
+ const config = this.requireConfig();
195
+ return await ctx.runAction(this.component.garmin.public.pullHRV, {
196
+ ...args,
197
+ clientId: config.clientId,
198
+ clientSecret: config.clientSecret,
199
+ });
200
+ }
201
+ /**
202
+ * Pull stress detail data from Garmin.
203
+ *
204
+ * @param ctx - Action context from the host app
205
+ * @param args.userId - The host app's user identifier
206
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
207
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
208
+ */
209
+ async pullStressDetails(ctx, args) {
210
+ const config = this.requireConfig();
211
+ return await ctx.runAction(this.component.garmin.public.pullStressDetails, {
212
+ ...args,
213
+ clientId: config.clientId,
214
+ clientSecret: config.clientSecret,
215
+ });
216
+ }
217
+ /**
218
+ * Pull pulse oximetry (SpO2) data from Garmin.
219
+ *
220
+ * @param ctx - Action context from the host app
221
+ * @param args.userId - The host app's user identifier
222
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
223
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
224
+ */
225
+ async pullPulseOx(ctx, args) {
226
+ const config = this.requireConfig();
227
+ return await ctx.runAction(this.component.garmin.public.pullPulseOx, {
228
+ ...args,
229
+ clientId: config.clientId,
230
+ clientSecret: config.clientSecret,
231
+ });
232
+ }
233
+ /**
234
+ * Pull respiration (breathing rate) data from Garmin.
235
+ *
236
+ * @param ctx - Action context from the host app
237
+ * @param args.userId - The host app's user identifier
238
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
239
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
240
+ */
241
+ async pullRespiration(ctx, args) {
242
+ const config = this.requireConfig();
243
+ return await ctx.runAction(this.component.garmin.public.pullRespiration, {
244
+ ...args,
245
+ clientId: config.clientId,
246
+ clientSecret: config.clientSecret,
247
+ });
248
+ }
249
+ /**
250
+ * Pull all supported data types from Garmin in a single call.
251
+ *
252
+ * Equivalent to calling every individual `pull*` method. Automatically
253
+ * refreshes the access token if expired.
254
+ *
255
+ * @param ctx - Action context from the host app
256
+ * @param args.userId - The host app's user identifier
257
+ * @param args.startTimeInSeconds - Optional Unix epoch lower bound
258
+ * @param args.endTimeInSeconds - Optional Unix epoch upper bound
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * await soma.garmin.pullAll(ctx, { userId: "user_123" });
263
+ * ```
264
+ */
265
+ async pullAll(ctx, args) {
266
+ const config = this.requireConfig();
267
+ return await ctx.runAction(this.component.garmin.public.pullAll, {
268
+ ...args,
269
+ clientId: config.clientId,
270
+ clientSecret: config.clientSecret,
271
+ });
272
+ }
273
+ /**
274
+ * Push a planned workout to Garmin Connect.
275
+ *
276
+ * Creates the workout on the user's Garmin account from a planned
277
+ * workout stored in Soma.
278
+ *
279
+ * @param ctx - Action context from the host app
280
+ * @param args.userId - The host app's user identifier
281
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
282
+ * @param args.workoutProvider - Optional provider identifier for the workout source
283
+ */
284
+ async pushWorkout(ctx, args) {
285
+ const config = this.requireConfig();
286
+ return await ctx.runAction(this.component.garmin.public.pushWorkout, {
287
+ ...args,
288
+ clientId: config.clientId,
289
+ clientSecret: config.clientSecret,
290
+ });
291
+ }
292
+ /**
293
+ * Schedule a planned workout on the user's Garmin calendar.
294
+ *
295
+ * The workout must already exist on Garmin (via `pushWorkout`).
296
+ *
297
+ * @param ctx - Action context from the host app
298
+ * @param args.userId - The host app's user identifier
299
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
300
+ * @param args.date - Optional target date (YYYY-MM-DD); defaults to the workout's planned_date
301
+ */
302
+ async pushSchedule(ctx, args) {
303
+ const config = this.requireConfig();
304
+ return await ctx.runAction(this.component.garmin.public.pushSchedule, {
305
+ ...args,
306
+ clientId: config.clientId,
307
+ clientSecret: config.clientSecret,
308
+ });
309
+ }
310
+ /**
311
+ * Delete a planned workout from Garmin Connect.
312
+ *
313
+ * Removes the workout from the user's Garmin account.
314
+ *
315
+ * @param ctx - Action context from the host app
316
+ * @param args.userId - The host app's user identifier
317
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
318
+ */
319
+ async deleteWorkout(ctx, args) {
320
+ const config = this.requireConfig();
321
+ return await ctx.runAction(this.component.garmin.public.deleteWorkout, {
322
+ ...args,
323
+ clientId: config.clientId,
324
+ clientSecret: config.clientSecret,
325
+ });
326
+ }
327
+ /**
328
+ * Remove a scheduled workout from the user's Garmin calendar.
329
+ *
330
+ * Unschedules the workout without deleting the workout itself.
331
+ *
332
+ * @param ctx - Action context from the host app
333
+ * @param args.userId - The host app's user identifier
334
+ * @param args.plannedWorkoutId - The Soma planned workout document ID
335
+ */
336
+ async deleteSchedule(ctx, args) {
337
+ const config = this.requireConfig();
338
+ return await ctx.runAction(this.component.garmin.public.deleteSchedule, {
339
+ ...args,
340
+ clientId: config.clientId,
341
+ clientSecret: config.clientSecret,
342
+ });
343
+ }
344
+ }
345
+ //# sourceMappingURL=garmin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"garmin.js","sourceRoot":"","sources":["../../src/client/garmin.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,UAAU;IAEX;IACA;IAFV,YACU,SAAwB,EACxB,aAAqC;QADrC,cAAS,GAAT,SAAS,CAAe;QACxB,kBAAa,GAAb,aAAa,CAAwB;IAC5C,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,UAAU,CACd,GAAc,EACd,IAA8C;QAE9C,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO,MAAM,GAAG,CAAC,SAAS,CAAC,IAA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