@nativesquare/soma 0.10.0 → 0.10.2
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 +85 -163
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +109 -130
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +92 -35
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/garmin/private.d.ts +9 -0
- package/dist/component/garmin/private.d.ts.map +1 -1
- package/dist/component/garmin/private.js +49 -0
- package/dist/component/garmin/private.js.map +1 -1
- package/dist/component/garmin/public.d.ts +237 -62
- package/dist/component/garmin/public.d.ts.map +1 -1
- package/dist/component/garmin/public.js +683 -253
- package/dist/component/garmin/public.js.map +1 -1
- package/dist/component/garmin/utils.d.ts +8 -0
- package/dist/component/garmin/utils.d.ts.map +1 -1
- package/dist/component/garmin/utils.js +9 -0
- package/dist/component/garmin/utils.js.map +1 -1
- package/dist/component/strava/public.d.ts +12 -52
- package/dist/component/strava/public.d.ts.map +1 -1
- package/dist/component/strava/public.js +16 -92
- package/dist/component/strava/public.js.map +1 -1
- package/dist/component/strava/transform/activity.js +15 -9
- package/dist/component/strava/transform/activity.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +210 -158
- package/src/component/_generated/component.ts +165 -31
- package/src/component/garmin/private.ts +84 -0
- package/src/component/garmin/public.ts +804 -347
- package/src/component/garmin/utils.ts +17 -0
- package/src/component/strava/public.ts +17 -123
|
@@ -2,17 +2,13 @@ import type { Id } from "../_generated/dataModel";
|
|
|
2
2
|
/**
|
|
3
3
|
* Generate a Garmin OAuth 2.0 authorization URL with PKCE.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* flow when using `registerRoutes`.
|
|
9
|
-
*
|
|
10
|
-
* If `userId` is omitted, the host app must store the returned `codeVerifier`
|
|
11
|
-
* itself and pass it to `connectGarmin` manually.
|
|
5
|
+
* The PKCE code verifier and state are stored in the component's
|
|
6
|
+
* `pendingOAuth` table so that `completeGarminOAuth` can look them up
|
|
7
|
+
* automatically when the callback fires via `registerRoutes`.
|
|
12
8
|
*/
|
|
13
9
|
export declare const getGarminAuthUrl: import("convex/server").RegisteredAction<"public", {
|
|
14
|
-
userId?: string | undefined;
|
|
15
10
|
redirectUri?: string | undefined;
|
|
11
|
+
userId: string;
|
|
16
12
|
clientId: string;
|
|
17
13
|
}, Promise<{
|
|
18
14
|
authUrl: string;
|
|
@@ -20,52 +16,240 @@ export declare const getGarminAuthUrl: import("convex/server").RegisteredAction<
|
|
|
20
16
|
codeVerifier: string;
|
|
21
17
|
}>>;
|
|
22
18
|
/**
|
|
23
|
-
*
|
|
19
|
+
* Complete a Garmin OAuth 2.0 flow using stored pending state.
|
|
24
20
|
*
|
|
25
|
-
*
|
|
26
|
-
* and
|
|
21
|
+
* Called internally by `registerRoutes` — the callback handler calls
|
|
22
|
+
* this with the `code` and `state` from the redirect. The action looks
|
|
23
|
+
* up the pending state (codeVerifier, userId) stored during
|
|
24
|
+
* `getGarminAuthUrl`, exchanges for tokens, creates the connection,
|
|
25
|
+
* stores tokens, and cleans up the pending entry.
|
|
26
|
+
*
|
|
27
|
+
* The host app is responsible for calling `syncGarmin` afterwards.
|
|
27
28
|
*/
|
|
28
|
-
export declare const
|
|
29
|
+
export declare const completeGarminOAuth: import("convex/server").RegisteredAction<"public", {
|
|
29
30
|
redirectUri?: string | undefined;
|
|
30
|
-
|
|
31
|
+
state: string;
|
|
31
32
|
clientId: string;
|
|
32
33
|
clientSecret: string;
|
|
33
34
|
code: string;
|
|
34
|
-
codeVerifier: string;
|
|
35
35
|
}, Promise<{
|
|
36
36
|
connectionId: Id<"connections">;
|
|
37
37
|
userId: string;
|
|
38
|
-
synced: Record<string, number>;
|
|
39
|
-
errors: Array<{
|
|
40
|
-
type: string;
|
|
41
|
-
id: string;
|
|
42
|
-
error: string;
|
|
43
|
-
}>;
|
|
44
38
|
}>>;
|
|
45
39
|
/**
|
|
46
|
-
*
|
|
40
|
+
* Disconnect a user from Garmin.
|
|
47
41
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* state (codeVerifier, userId) stored during `getGarminAuthUrl`,
|
|
51
|
-
* exchanges for tokens, creates the connection, syncs data, and
|
|
52
|
-
* cleans up the pending entry.
|
|
42
|
+
* Deregisters the user via the Garmin API (best-effort), deletes stored
|
|
43
|
+
* tokens, and sets the connection to inactive.
|
|
53
44
|
*/
|
|
54
|
-
export declare const
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
export declare const disconnectGarmin: import("convex/server").RegisteredAction<"public", {
|
|
46
|
+
userId: string;
|
|
47
|
+
}, Promise<null>>;
|
|
48
|
+
export declare const pullActivities: import("convex/server").RegisteredAction<"public", {
|
|
49
|
+
endTimeInSeconds?: number | undefined;
|
|
50
|
+
startTimeInSeconds?: number | undefined;
|
|
51
|
+
userId: string;
|
|
57
52
|
clientId: string;
|
|
58
53
|
clientSecret: string;
|
|
59
|
-
code: string;
|
|
60
54
|
}, Promise<{
|
|
61
|
-
|
|
55
|
+
synced: {
|
|
56
|
+
activities: number;
|
|
57
|
+
};
|
|
58
|
+
errors: {
|
|
59
|
+
type: "activity";
|
|
60
|
+
id: string;
|
|
61
|
+
error: string;
|
|
62
|
+
}[];
|
|
63
|
+
}>>;
|
|
64
|
+
export declare const pullDailies: import("convex/server").RegisteredAction<"public", {
|
|
65
|
+
endTimeInSeconds?: number | undefined;
|
|
66
|
+
startTimeInSeconds?: number | undefined;
|
|
67
|
+
userId: string;
|
|
68
|
+
clientId: string;
|
|
69
|
+
clientSecret: string;
|
|
70
|
+
}, Promise<{
|
|
71
|
+
synced: {
|
|
72
|
+
dailies: number;
|
|
73
|
+
};
|
|
74
|
+
errors: {
|
|
75
|
+
type: string;
|
|
76
|
+
id: string;
|
|
77
|
+
error: string;
|
|
78
|
+
}[];
|
|
79
|
+
}>>;
|
|
80
|
+
export declare const pullSleep: import("convex/server").RegisteredAction<"public", {
|
|
81
|
+
endTimeInSeconds?: number | undefined;
|
|
82
|
+
startTimeInSeconds?: number | undefined;
|
|
83
|
+
userId: string;
|
|
84
|
+
clientId: string;
|
|
85
|
+
clientSecret: string;
|
|
86
|
+
}, Promise<{
|
|
87
|
+
synced: {
|
|
88
|
+
sleep: number;
|
|
89
|
+
};
|
|
90
|
+
errors: {
|
|
91
|
+
type: string;
|
|
92
|
+
id: string;
|
|
93
|
+
error: string;
|
|
94
|
+
}[];
|
|
95
|
+
}>>;
|
|
96
|
+
export declare const pullBody: import("convex/server").RegisteredAction<"public", {
|
|
97
|
+
endTimeInSeconds?: number | undefined;
|
|
98
|
+
startTimeInSeconds?: number | undefined;
|
|
99
|
+
userId: string;
|
|
100
|
+
clientId: string;
|
|
101
|
+
clientSecret: string;
|
|
102
|
+
}, Promise<{
|
|
103
|
+
synced: {
|
|
104
|
+
body: number;
|
|
105
|
+
};
|
|
106
|
+
errors: {
|
|
107
|
+
type: string;
|
|
108
|
+
id: string;
|
|
109
|
+
error: string;
|
|
110
|
+
}[];
|
|
111
|
+
}>>;
|
|
112
|
+
export declare const pullMenstruation: import("convex/server").RegisteredAction<"public", {
|
|
113
|
+
endTimeInSeconds?: number | undefined;
|
|
114
|
+
startTimeInSeconds?: number | undefined;
|
|
115
|
+
userId: string;
|
|
116
|
+
clientId: string;
|
|
117
|
+
clientSecret: string;
|
|
118
|
+
}, Promise<{
|
|
119
|
+
synced: {
|
|
120
|
+
menstruation: number;
|
|
121
|
+
};
|
|
122
|
+
errors: {
|
|
123
|
+
type: string;
|
|
124
|
+
id: string;
|
|
125
|
+
error: string;
|
|
126
|
+
}[];
|
|
127
|
+
}>>;
|
|
128
|
+
export declare const pullBloodPressures: import("convex/server").RegisteredAction<"public", {
|
|
129
|
+
endTimeInSeconds?: number | undefined;
|
|
130
|
+
startTimeInSeconds?: number | undefined;
|
|
131
|
+
userId: string;
|
|
132
|
+
clientId: string;
|
|
133
|
+
clientSecret: string;
|
|
134
|
+
}, Promise<{
|
|
135
|
+
synced: {
|
|
136
|
+
bloodPressures: number;
|
|
137
|
+
};
|
|
138
|
+
errors: {
|
|
139
|
+
type: string;
|
|
140
|
+
id: string;
|
|
141
|
+
error: string;
|
|
142
|
+
}[];
|
|
143
|
+
}>>;
|
|
144
|
+
export declare const pullSkinTemperature: import("convex/server").RegisteredAction<"public", {
|
|
145
|
+
endTimeInSeconds?: number | undefined;
|
|
146
|
+
startTimeInSeconds?: number | undefined;
|
|
147
|
+
userId: string;
|
|
148
|
+
clientId: string;
|
|
149
|
+
clientSecret: string;
|
|
150
|
+
}, Promise<{
|
|
151
|
+
synced: {
|
|
152
|
+
skinTemp: number;
|
|
153
|
+
};
|
|
154
|
+
errors: {
|
|
155
|
+
type: string;
|
|
156
|
+
id: string;
|
|
157
|
+
error: string;
|
|
158
|
+
}[];
|
|
159
|
+
}>>;
|
|
160
|
+
export declare const pullUserMetrics: import("convex/server").RegisteredAction<"public", {
|
|
161
|
+
endTimeInSeconds?: number | undefined;
|
|
162
|
+
startTimeInSeconds?: number | undefined;
|
|
62
163
|
userId: string;
|
|
164
|
+
clientId: string;
|
|
165
|
+
clientSecret: string;
|
|
166
|
+
}, Promise<{
|
|
167
|
+
synced: {
|
|
168
|
+
userMetrics: number;
|
|
169
|
+
};
|
|
170
|
+
errors: {
|
|
171
|
+
type: string;
|
|
172
|
+
id: string;
|
|
173
|
+
error: string;
|
|
174
|
+
}[];
|
|
175
|
+
}>>;
|
|
176
|
+
export declare const pullHRV: import("convex/server").RegisteredAction<"public", {
|
|
177
|
+
endTimeInSeconds?: number | undefined;
|
|
178
|
+
startTimeInSeconds?: number | undefined;
|
|
179
|
+
userId: string;
|
|
180
|
+
clientId: string;
|
|
181
|
+
clientSecret: string;
|
|
182
|
+
}, Promise<{
|
|
183
|
+
synced: {
|
|
184
|
+
hrv: number;
|
|
185
|
+
};
|
|
186
|
+
errors: {
|
|
187
|
+
type: string;
|
|
188
|
+
id: string;
|
|
189
|
+
error: string;
|
|
190
|
+
}[];
|
|
191
|
+
}>>;
|
|
192
|
+
export declare const pullStressDetails: import("convex/server").RegisteredAction<"public", {
|
|
193
|
+
endTimeInSeconds?: number | undefined;
|
|
194
|
+
startTimeInSeconds?: number | undefined;
|
|
195
|
+
userId: string;
|
|
196
|
+
clientId: string;
|
|
197
|
+
clientSecret: string;
|
|
198
|
+
}, Promise<{
|
|
199
|
+
synced: {
|
|
200
|
+
stressDetails: number;
|
|
201
|
+
};
|
|
202
|
+
errors: {
|
|
203
|
+
type: string;
|
|
204
|
+
id: string;
|
|
205
|
+
error: string;
|
|
206
|
+
}[];
|
|
207
|
+
}>>;
|
|
208
|
+
export declare const pullPulseOx: import("convex/server").RegisteredAction<"public", {
|
|
209
|
+
endTimeInSeconds?: number | undefined;
|
|
210
|
+
startTimeInSeconds?: number | undefined;
|
|
211
|
+
userId: string;
|
|
212
|
+
clientId: string;
|
|
213
|
+
clientSecret: string;
|
|
214
|
+
}, Promise<{
|
|
215
|
+
synced: {
|
|
216
|
+
pulseOx: number;
|
|
217
|
+
};
|
|
218
|
+
errors: {
|
|
219
|
+
type: string;
|
|
220
|
+
id: string;
|
|
221
|
+
error: string;
|
|
222
|
+
}[];
|
|
223
|
+
}>>;
|
|
224
|
+
export declare const pullRespiration: import("convex/server").RegisteredAction<"public", {
|
|
225
|
+
endTimeInSeconds?: number | undefined;
|
|
226
|
+
startTimeInSeconds?: number | undefined;
|
|
227
|
+
userId: string;
|
|
228
|
+
clientId: string;
|
|
229
|
+
clientSecret: string;
|
|
230
|
+
}, Promise<{
|
|
231
|
+
synced: {
|
|
232
|
+
respiration: number;
|
|
233
|
+
};
|
|
234
|
+
errors: {
|
|
235
|
+
type: string;
|
|
236
|
+
id: string;
|
|
237
|
+
error: string;
|
|
238
|
+
}[];
|
|
239
|
+
}>>;
|
|
240
|
+
export declare const pullAll: import("convex/server").RegisteredAction<"public", {
|
|
241
|
+
endTimeInSeconds?: number | undefined;
|
|
242
|
+
startTimeInSeconds?: number | undefined;
|
|
243
|
+
userId: string;
|
|
244
|
+
clientId: string;
|
|
245
|
+
clientSecret: string;
|
|
246
|
+
}, Promise<{
|
|
63
247
|
synced: Record<string, number>;
|
|
64
|
-
errors:
|
|
248
|
+
errors: {
|
|
65
249
|
type: string;
|
|
66
250
|
id: string;
|
|
67
251
|
error: string;
|
|
68
|
-
}
|
|
252
|
+
}[];
|
|
69
253
|
}>>;
|
|
70
254
|
/**
|
|
71
255
|
* Incremental Garmin sync for an already-connected user.
|
|
@@ -87,38 +271,10 @@ export declare const syncGarmin: import("convex/server").RegisteredAction<"publi
|
|
|
87
271
|
error: string;
|
|
88
272
|
}>;
|
|
89
273
|
}>>;
|
|
90
|
-
/**
|
|
91
|
-
* Disconnect a user from Garmin.
|
|
92
|
-
*
|
|
93
|
-
* Deregisters the user via the Garmin API (best-effort), deletes stored
|
|
94
|
-
* tokens, and sets the connection to inactive.
|
|
95
|
-
*/
|
|
96
|
-
export declare const disconnectGarmin: import("convex/server").RegisteredAction<"public", {
|
|
97
|
-
userId: string;
|
|
98
|
-
}, Promise<null>>;
|
|
99
|
-
/**
|
|
100
|
-
* Push a planned workout from Soma's DB to Garmin Connect.
|
|
101
|
-
*
|
|
102
|
-
* Reads the planned workout document, transforms it to Garmin Training API V2
|
|
103
|
-
* format, creates the workout at Garmin, and optionally schedules it if a
|
|
104
|
-
* `planned_date` is set in the metadata.
|
|
105
|
-
*
|
|
106
|
-
* Returns the Garmin workout ID and schedule ID (if scheduled).
|
|
107
|
-
*/
|
|
108
|
-
export declare const pushPlannedWorkout: import("convex/server").RegisteredAction<"public", {
|
|
109
|
-
workoutProvider?: string | undefined;
|
|
110
|
-
userId: string;
|
|
111
|
-
clientId: string;
|
|
112
|
-
clientSecret: string;
|
|
113
|
-
plannedWorkoutId: string;
|
|
114
|
-
}, Promise<{
|
|
115
|
-
garminWorkoutId: number;
|
|
116
|
-
garminScheduleId: number | null;
|
|
117
|
-
}>>;
|
|
118
274
|
/**
|
|
119
275
|
* Fetch and ingest all Garmin wellness data types for a time range.
|
|
120
276
|
*
|
|
121
|
-
* Called by
|
|
277
|
+
* Called by syncGarmin after obtaining a valid access token.
|
|
122
278
|
* after obtaining a valid access token.
|
|
123
279
|
*/
|
|
124
280
|
export declare const syncAllTypes: import("convex/server").RegisteredAction<"public", {
|
|
@@ -148,4 +304,23 @@ export declare const syncAllTypes: import("convex/server").RegisteredAction<"pub
|
|
|
148
304
|
error: string;
|
|
149
305
|
}[];
|
|
150
306
|
}>>;
|
|
307
|
+
/**
|
|
308
|
+
* Push a planned workout from Soma's DB to Garmin Connect.
|
|
309
|
+
*
|
|
310
|
+
* Reads the planned workout document, transforms it to Garmin Training API V2
|
|
311
|
+
* format, creates the workout at Garmin, and optionally schedules it if a
|
|
312
|
+
* `planned_date` is set in the metadata.
|
|
313
|
+
*
|
|
314
|
+
* Returns the Garmin workout ID and schedule ID (if scheduled).
|
|
315
|
+
*/
|
|
316
|
+
export declare const pushPlannedWorkout: import("convex/server").RegisteredAction<"public", {
|
|
317
|
+
workoutProvider?: string | undefined;
|
|
318
|
+
userId: string;
|
|
319
|
+
clientId: string;
|
|
320
|
+
clientSecret: string;
|
|
321
|
+
plannedWorkoutId: string;
|
|
322
|
+
}, Promise<{
|
|
323
|
+
garminWorkoutId: number;
|
|
324
|
+
garminScheduleId: number | null;
|
|
325
|
+
}>>;
|
|
151
326
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/garmin/public.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAO,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAyDvD
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/garmin/public.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAO,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAyDvD;;;;;;GAMG;A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