@nativesquare/soma 0.9.4 → 0.10.1
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 +124 -144
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +157 -134
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +18 -0
- 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 +113 -22
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/garmin/auth.d.ts +0 -4
- package/dist/component/garmin/auth.d.ts.map +1 -1
- package/dist/component/garmin/auth.js +0 -8
- package/dist/component/garmin/auth.js.map +1 -1
- package/dist/component/garmin/private.d.ts +10 -1
- package/dist/component/garmin/private.d.ts.map +1 -1
- package/dist/component/garmin/private.js +49 -9
- 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 +689 -254
- 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/schema.d.ts +2 -2
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +5 -3
- package/dist/component/schema.js.map +1 -1
- package/dist/{strava → component/strava}/auth.d.ts +15 -48
- package/dist/component/strava/auth.d.ts.map +1 -0
- package/dist/{strava → component/strava}/auth.js +4 -39
- package/dist/component/strava/auth.js.map +1 -0
- package/dist/component/strava/client.d.ts +8 -0
- package/dist/component/strava/client.d.ts.map +1 -0
- package/dist/component/strava/client.js +18 -0
- package/dist/component/strava/client.js.map +1 -0
- package/dist/component/strava/private.d.ts +19 -0
- package/dist/component/strava/private.d.ts.map +1 -1
- package/dist/component/strava/private.js +52 -2
- package/dist/component/strava/private.js.map +1 -1
- package/dist/component/strava/public.d.ts +54 -19
- package/dist/component/strava/public.d.ts.map +1 -1
- package/dist/component/strava/public.js +159 -109
- package/dist/component/strava/public.js.map +1 -1
- package/dist/component/strava/transform/activity.d.ts +19 -0
- package/dist/component/strava/transform/activity.d.ts.map +1 -0
- package/dist/{strava → component/strava/transform}/activity.js +31 -45
- package/dist/component/strava/transform/activity.js.map +1 -0
- package/dist/{strava → component/strava/transform}/athlete.d.ts +4 -10
- package/dist/component/strava/transform/athlete.d.ts.map +1 -0
- package/dist/{strava → component/strava/transform}/athlete.js +2 -8
- package/dist/component/strava/transform/athlete.js.map +1 -0
- package/dist/component/strava/transform/maps/sportType.d.ts +7 -0
- package/dist/component/strava/transform/maps/sportType.d.ts.map +1 -0
- package/dist/{strava/maps/sport-type.js → component/strava/transform/maps/sportType.js} +4 -2
- package/dist/component/strava/transform/maps/sportType.js.map +1 -0
- package/dist/component/strava/types/stravaApi/client/client.gen.d.ts +3 -0
- package/dist/component/strava/types/stravaApi/client/client.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/client/client.gen.js +236 -0
- package/dist/component/strava/types/stravaApi/client/client.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/client/index.d.ts +9 -0
- package/dist/component/strava/types/stravaApi/client/index.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/client/index.js +7 -0
- package/dist/component/strava/types/stravaApi/client/index.js.map +1 -0
- package/dist/component/strava/types/stravaApi/client/types.gen.d.ts +118 -0
- package/dist/component/strava/types/stravaApi/client/types.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/client/types.gen.js +3 -0
- package/dist/component/strava/types/stravaApi/client/types.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/client/utils.gen.d.ts +34 -0
- package/dist/component/strava/types/stravaApi/client/utils.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/client/utils.gen.js +229 -0
- package/dist/component/strava/types/stravaApi/client/utils.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/client.gen.d.ts +13 -0
- package/dist/component/strava/types/stravaApi/client.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/client.gen.js +4 -0
- package/dist/component/strava/types/stravaApi/client.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/auth.gen.d.ts +19 -0
- package/dist/component/strava/types/stravaApi/core/auth.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/auth.gen.js +15 -0
- package/dist/component/strava/types/stravaApi/core/auth.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/bodySerializer.gen.d.ts +26 -0
- package/dist/component/strava/types/stravaApi/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/bodySerializer.gen.js +58 -0
- package/dist/component/strava/types/stravaApi/core/bodySerializer.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/params.gen.d.ts +44 -0
- package/dist/component/strava/types/stravaApi/core/params.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/params.gen.js +101 -0
- package/dist/component/strava/types/stravaApi/core/params.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/pathSerializer.gen.d.ts +34 -0
- package/dist/component/strava/types/stravaApi/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/pathSerializer.gen.js +107 -0
- package/dist/component/strava/types/stravaApi/core/pathSerializer.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/component/strava/types/stravaApi/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/queryKeySerializer.gen.js +93 -0
- package/dist/component/strava/types/stravaApi/core/queryKeySerializer.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/component/strava/types/stravaApi/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/serverSentEvents.gen.js +134 -0
- package/dist/component/strava/types/stravaApi/core/serverSentEvents.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/types.gen.d.ts +79 -0
- package/dist/component/strava/types/stravaApi/core/types.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/types.gen.js +3 -0
- package/dist/component/strava/types/stravaApi/core/types.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/core/utils.gen.d.ts +20 -0
- package/dist/component/strava/types/stravaApi/core/utils.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/core/utils.gen.js +88 -0
- package/dist/component/strava/types/stravaApi/core/utils.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/index.d.ts +3 -0
- package/dist/component/strava/types/stravaApi/index.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/index.js +3 -0
- package/dist/component/strava/types/stravaApi/index.js.map +1 -0
- package/dist/component/strava/types/stravaApi/sdk.gen.d.ts +224 -0
- package/dist/component/strava/types/stravaApi/sdk.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/sdk.gen.js +361 -0
- package/dist/component/strava/types/stravaApi/sdk.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/types.gen.d.ts +2209 -0
- package/dist/component/strava/types/stravaApi/types.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/types.gen.js +3 -0
- package/dist/component/strava/types/stravaApi/types.gen.js.map +1 -0
- package/dist/component/strava/types/stravaApi/zod.gen.d.ts +5332 -0
- package/dist/component/strava/types/stravaApi/zod.gen.d.ts.map +1 -0
- package/dist/component/strava/types/stravaApi/zod.gen.js +1009 -0
- package/dist/component/strava/types/stravaApi/zod.gen.js.map +1 -0
- package/dist/component/strava/utils.d.ts +15 -0
- package/dist/component/strava/utils.d.ts.map +1 -0
- package/dist/component/strava/utils.js +36 -0
- package/dist/component/strava/utils.js.map +1 -0
- package/dist/component/utils.d.ts +5 -0
- package/dist/component/utils.d.ts.map +1 -0
- package/dist/component/utils.js +11 -0
- package/dist/component/utils.js.map +1 -0
- package/package.json +131 -130
- package/src/client/index.ts +285 -164
- package/src/component/_generated/api.ts +18 -0
- package/src/component/_generated/component.ts +191 -24
- package/src/component/garmin/auth.ts +0 -9
- package/src/component/garmin/private.ts +84 -12
- package/src/component/garmin/public.ts +812 -348
- package/src/component/garmin/utils.ts +17 -0
- package/src/component/schema.ts +5 -3
- package/src/{strava → component/strava}/auth.ts +143 -185
- package/src/component/strava/client.ts +20 -0
- package/src/component/strava/private.ts +147 -89
- package/src/component/strava/public.ts +191 -139
- package/src/{strava → component/strava/transform}/activity.ts +256 -276
- package/src/{strava → component/strava/transform}/athlete.ts +41 -47
- package/src/{strava/maps/sport-type.ts → component/strava/transform/maps/sportType.ts} +100 -99
- package/src/component/strava/types/specs/strava-api.json +4796 -0
- package/src/component/strava/types/stravaApi/client/client.gen.ts +290 -0
- package/src/component/strava/types/stravaApi/client/index.ts +25 -0
- package/src/component/strava/types/stravaApi/client/types.gen.ts +214 -0
- package/src/component/strava/types/stravaApi/client/utils.gen.ts +316 -0
- package/src/component/strava/types/stravaApi/client.gen.ts +16 -0
- package/src/component/strava/types/stravaApi/core/auth.gen.ts +41 -0
- package/src/component/strava/types/stravaApi/core/bodySerializer.gen.ts +82 -0
- package/src/component/strava/types/stravaApi/core/params.gen.ts +169 -0
- package/src/component/strava/types/stravaApi/core/pathSerializer.gen.ts +171 -0
- package/src/component/strava/types/stravaApi/core/queryKeySerializer.gen.ts +117 -0
- package/src/component/strava/types/stravaApi/core/serverSentEvents.gen.ts +243 -0
- package/src/component/strava/types/stravaApi/core/types.gen.ts +104 -0
- package/src/component/strava/types/stravaApi/core/utils.gen.ts +140 -0
- package/src/component/strava/types/stravaApi/index.ts +4 -0
- package/src/component/strava/types/stravaApi/sdk.gen.ts +410 -0
- package/src/component/strava/types/stravaApi/types.gen.ts +2435 -0
- package/src/component/strava/types/stravaApi/zod.gen.ts +1132 -0
- package/src/component/strava/utils.ts +52 -0
- package/src/component/utils.ts +11 -0
- package/dist/strava/activity.d.ts +0 -121
- package/dist/strava/activity.d.ts.map +0 -1
- package/dist/strava/activity.js.map +0 -1
- package/dist/strava/athlete.d.ts.map +0 -1
- package/dist/strava/athlete.js.map +0 -1
- package/dist/strava/auth.d.ts.map +0 -1
- package/dist/strava/auth.js.map +0 -1
- package/dist/strava/client.d.ts +0 -93
- package/dist/strava/client.d.ts.map +0 -1
- package/dist/strava/client.js +0 -158
- package/dist/strava/client.js.map +0 -1
- package/dist/strava/index.d.ts +0 -13
- package/dist/strava/index.d.ts.map +0 -1
- package/dist/strava/index.js +0 -17
- package/dist/strava/index.js.map +0 -1
- package/dist/strava/maps/sport-type.d.ts +0 -7
- package/dist/strava/maps/sport-type.d.ts.map +0 -1
- package/dist/strava/maps/sport-type.js.map +0 -1
- package/dist/strava/sync.d.ts +0 -104
- package/dist/strava/sync.d.ts.map +0 -1
- package/dist/strava/sync.js +0 -87
- package/dist/strava/sync.js.map +0 -1
- package/dist/strava/types.d.ts +0 -266
- package/dist/strava/types.d.ts.map +0 -1
- package/dist/strava/types.js +0 -8
- package/dist/strava/types.js.map +0 -1
- package/src/strava/activity.test.ts +0 -415
- package/src/strava/athlete.test.ts +0 -139
- package/src/strava/auth.test.ts +0 -78
- package/src/strava/client.ts +0 -212
- package/src/strava/index.ts +0 -54
- package/src/strava/maps/sport-type.test.ts +0 -69
- package/src/strava/sync.ts +0 -168
- package/src/strava/types.ts +0 -361
|
@@ -57,8 +57,17 @@ import type * as garmin_utils from "../garmin/utils.js";
|
|
|
57
57
|
import type * as garmin_webhooks from "../garmin/webhooks.js";
|
|
58
58
|
import type * as private_ from "../private.js";
|
|
59
59
|
import type * as public_ from "../public.js";
|
|
60
|
+
import type * as strava_auth from "../strava/auth.js";
|
|
61
|
+
import type * as strava_client from "../strava/client.js";
|
|
60
62
|
import type * as strava_private from "../strava/private.js";
|
|
61
63
|
import type * as strava_public from "../strava/public.js";
|
|
64
|
+
import type * as strava_transform_activity from "../strava/transform/activity.js";
|
|
65
|
+
import type * as strava_transform_athlete from "../strava/transform/athlete.js";
|
|
66
|
+
import type * as strava_transform_maps_sportType from "../strava/transform/maps/sportType.js";
|
|
67
|
+
import type * as strava_types_stravaApi_client_index from "../strava/types/stravaApi/client/index.js";
|
|
68
|
+
import type * as strava_types_stravaApi_index from "../strava/types/stravaApi/index.js";
|
|
69
|
+
import type * as strava_utils from "../strava/utils.js";
|
|
70
|
+
import type * as utils from "../utils.js";
|
|
62
71
|
import type * as validators_activity from "../validators/activity.js";
|
|
63
72
|
import type * as validators_athlete from "../validators/athlete.js";
|
|
64
73
|
import type * as validators_body from "../validators/body.js";
|
|
@@ -130,8 +139,17 @@ const fullApi: ApiFromModules<{
|
|
|
130
139
|
"garmin/webhooks": typeof garmin_webhooks;
|
|
131
140
|
private: typeof private_;
|
|
132
141
|
public: typeof public_;
|
|
142
|
+
"strava/auth": typeof strava_auth;
|
|
143
|
+
"strava/client": typeof strava_client;
|
|
133
144
|
"strava/private": typeof strava_private;
|
|
134
145
|
"strava/public": typeof strava_public;
|
|
146
|
+
"strava/transform/activity": typeof strava_transform_activity;
|
|
147
|
+
"strava/transform/athlete": typeof strava_transform_athlete;
|
|
148
|
+
"strava/transform/maps/sportType": typeof strava_transform_maps_sportType;
|
|
149
|
+
"strava/types/stravaApi/client/index": typeof strava_types_stravaApi_client_index;
|
|
150
|
+
"strava/types/stravaApi/index": typeof strava_types_stravaApi_index;
|
|
151
|
+
"strava/utils": typeof strava_utils;
|
|
152
|
+
utils: typeof utils;
|
|
135
153
|
"validators/activity": typeof validators_activity;
|
|
136
154
|
"validators/athlete": typeof validators_athlete;
|
|
137
155
|
"validators/body": typeof validators_body;
|
|
@@ -38,31 +38,186 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
38
38
|
any,
|
|
39
39
|
Name
|
|
40
40
|
>;
|
|
41
|
-
|
|
41
|
+
disconnectGarmin: FunctionReference<
|
|
42
|
+
"action",
|
|
43
|
+
"internal",
|
|
44
|
+
{ userId: string },
|
|
45
|
+
any,
|
|
46
|
+
Name
|
|
47
|
+
>;
|
|
48
|
+
getGarminAuthUrl: FunctionReference<
|
|
49
|
+
"action",
|
|
50
|
+
"internal",
|
|
51
|
+
{ clientId: string; redirectUri?: string; userId: string },
|
|
52
|
+
any,
|
|
53
|
+
Name
|
|
54
|
+
>;
|
|
55
|
+
pullActivities: FunctionReference<
|
|
42
56
|
"action",
|
|
43
57
|
"internal",
|
|
44
58
|
{
|
|
45
59
|
clientId: string;
|
|
46
60
|
clientSecret: string;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
redirectUri?: string;
|
|
61
|
+
endTimeInSeconds?: number;
|
|
62
|
+
startTimeInSeconds?: number;
|
|
50
63
|
userId: string;
|
|
51
64
|
},
|
|
52
65
|
any,
|
|
53
66
|
Name
|
|
54
67
|
>;
|
|
55
|
-
|
|
68
|
+
pullAll: FunctionReference<
|
|
56
69
|
"action",
|
|
57
70
|
"internal",
|
|
58
|
-
{
|
|
71
|
+
{
|
|
72
|
+
clientId: string;
|
|
73
|
+
clientSecret: string;
|
|
74
|
+
endTimeInSeconds?: number;
|
|
75
|
+
startTimeInSeconds?: number;
|
|
76
|
+
userId: string;
|
|
77
|
+
},
|
|
59
78
|
any,
|
|
60
79
|
Name
|
|
61
80
|
>;
|
|
62
|
-
|
|
81
|
+
pullBloodPressures: FunctionReference<
|
|
82
|
+
"action",
|
|
83
|
+
"internal",
|
|
84
|
+
{
|
|
85
|
+
clientId: string;
|
|
86
|
+
clientSecret: string;
|
|
87
|
+
endTimeInSeconds?: number;
|
|
88
|
+
startTimeInSeconds?: number;
|
|
89
|
+
userId: string;
|
|
90
|
+
},
|
|
91
|
+
any,
|
|
92
|
+
Name
|
|
93
|
+
>;
|
|
94
|
+
pullBody: FunctionReference<
|
|
95
|
+
"action",
|
|
96
|
+
"internal",
|
|
97
|
+
{
|
|
98
|
+
clientId: string;
|
|
99
|
+
clientSecret: string;
|
|
100
|
+
endTimeInSeconds?: number;
|
|
101
|
+
startTimeInSeconds?: number;
|
|
102
|
+
userId: string;
|
|
103
|
+
},
|
|
104
|
+
any,
|
|
105
|
+
Name
|
|
106
|
+
>;
|
|
107
|
+
pullDailies: FunctionReference<
|
|
63
108
|
"action",
|
|
64
109
|
"internal",
|
|
65
|
-
{
|
|
110
|
+
{
|
|
111
|
+
clientId: string;
|
|
112
|
+
clientSecret: string;
|
|
113
|
+
endTimeInSeconds?: number;
|
|
114
|
+
startTimeInSeconds?: number;
|
|
115
|
+
userId: string;
|
|
116
|
+
},
|
|
117
|
+
any,
|
|
118
|
+
Name
|
|
119
|
+
>;
|
|
120
|
+
pullHRV: FunctionReference<
|
|
121
|
+
"action",
|
|
122
|
+
"internal",
|
|
123
|
+
{
|
|
124
|
+
clientId: string;
|
|
125
|
+
clientSecret: string;
|
|
126
|
+
endTimeInSeconds?: number;
|
|
127
|
+
startTimeInSeconds?: number;
|
|
128
|
+
userId: string;
|
|
129
|
+
},
|
|
130
|
+
any,
|
|
131
|
+
Name
|
|
132
|
+
>;
|
|
133
|
+
pullMenstruation: FunctionReference<
|
|
134
|
+
"action",
|
|
135
|
+
"internal",
|
|
136
|
+
{
|
|
137
|
+
clientId: string;
|
|
138
|
+
clientSecret: string;
|
|
139
|
+
endTimeInSeconds?: number;
|
|
140
|
+
startTimeInSeconds?: number;
|
|
141
|
+
userId: string;
|
|
142
|
+
},
|
|
143
|
+
any,
|
|
144
|
+
Name
|
|
145
|
+
>;
|
|
146
|
+
pullPulseOx: FunctionReference<
|
|
147
|
+
"action",
|
|
148
|
+
"internal",
|
|
149
|
+
{
|
|
150
|
+
clientId: string;
|
|
151
|
+
clientSecret: string;
|
|
152
|
+
endTimeInSeconds?: number;
|
|
153
|
+
startTimeInSeconds?: number;
|
|
154
|
+
userId: string;
|
|
155
|
+
},
|
|
156
|
+
any,
|
|
157
|
+
Name
|
|
158
|
+
>;
|
|
159
|
+
pullRespiration: FunctionReference<
|
|
160
|
+
"action",
|
|
161
|
+
"internal",
|
|
162
|
+
{
|
|
163
|
+
clientId: string;
|
|
164
|
+
clientSecret: string;
|
|
165
|
+
endTimeInSeconds?: number;
|
|
166
|
+
startTimeInSeconds?: number;
|
|
167
|
+
userId: string;
|
|
168
|
+
},
|
|
169
|
+
any,
|
|
170
|
+
Name
|
|
171
|
+
>;
|
|
172
|
+
pullSkinTemperature: FunctionReference<
|
|
173
|
+
"action",
|
|
174
|
+
"internal",
|
|
175
|
+
{
|
|
176
|
+
clientId: string;
|
|
177
|
+
clientSecret: string;
|
|
178
|
+
endTimeInSeconds?: number;
|
|
179
|
+
startTimeInSeconds?: number;
|
|
180
|
+
userId: string;
|
|
181
|
+
},
|
|
182
|
+
any,
|
|
183
|
+
Name
|
|
184
|
+
>;
|
|
185
|
+
pullSleep: FunctionReference<
|
|
186
|
+
"action",
|
|
187
|
+
"internal",
|
|
188
|
+
{
|
|
189
|
+
clientId: string;
|
|
190
|
+
clientSecret: string;
|
|
191
|
+
endTimeInSeconds?: number;
|
|
192
|
+
startTimeInSeconds?: number;
|
|
193
|
+
userId: string;
|
|
194
|
+
},
|
|
195
|
+
any,
|
|
196
|
+
Name
|
|
197
|
+
>;
|
|
198
|
+
pullStressDetails: FunctionReference<
|
|
199
|
+
"action",
|
|
200
|
+
"internal",
|
|
201
|
+
{
|
|
202
|
+
clientId: string;
|
|
203
|
+
clientSecret: string;
|
|
204
|
+
endTimeInSeconds?: number;
|
|
205
|
+
startTimeInSeconds?: number;
|
|
206
|
+
userId: string;
|
|
207
|
+
},
|
|
208
|
+
any,
|
|
209
|
+
Name
|
|
210
|
+
>;
|
|
211
|
+
pullUserMetrics: FunctionReference<
|
|
212
|
+
"action",
|
|
213
|
+
"internal",
|
|
214
|
+
{
|
|
215
|
+
clientId: string;
|
|
216
|
+
clientSecret: string;
|
|
217
|
+
endTimeInSeconds?: number;
|
|
218
|
+
startTimeInSeconds?: number;
|
|
219
|
+
userId: string;
|
|
220
|
+
},
|
|
66
221
|
any,
|
|
67
222
|
Name
|
|
68
223
|
>;
|
|
@@ -1647,34 +1802,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
1647
1802
|
};
|
|
1648
1803
|
strava: {
|
|
1649
1804
|
public: {
|
|
1650
|
-
|
|
1805
|
+
completeStravaOAuth: FunctionReference<
|
|
1651
1806
|
"action",
|
|
1652
1807
|
"internal",
|
|
1653
1808
|
{
|
|
1654
|
-
baseUrl?: string;
|
|
1655
1809
|
clientId: string;
|
|
1656
1810
|
clientSecret: string;
|
|
1657
1811
|
code: string;
|
|
1658
|
-
|
|
1659
|
-
userId: string;
|
|
1660
|
-
},
|
|
1661
|
-
{
|
|
1662
|
-
connectionId: string;
|
|
1663
|
-
errors: Array<{ activityId: number; error: string }>;
|
|
1664
|
-
synced: number;
|
|
1812
|
+
state: string;
|
|
1665
1813
|
},
|
|
1814
|
+
{ connectionId: string; userId: string },
|
|
1666
1815
|
Name
|
|
1667
1816
|
>;
|
|
1668
1817
|
disconnectStrava: FunctionReference<
|
|
1818
|
+
"action",
|
|
1819
|
+
"internal",
|
|
1820
|
+
{ clientId: string; clientSecret: string; userId: string },
|
|
1821
|
+
null,
|
|
1822
|
+
Name
|
|
1823
|
+
>;
|
|
1824
|
+
getStravaAuthUrl: FunctionReference<
|
|
1669
1825
|
"action",
|
|
1670
1826
|
"internal",
|
|
1671
1827
|
{
|
|
1672
|
-
baseUrl?: string;
|
|
1673
1828
|
clientId: string;
|
|
1674
|
-
|
|
1829
|
+
redirectUri: string;
|
|
1830
|
+
scope?: string;
|
|
1675
1831
|
userId: string;
|
|
1676
1832
|
},
|
|
1677
|
-
|
|
1833
|
+
any,
|
|
1834
|
+
Name
|
|
1835
|
+
>;
|
|
1836
|
+
syncAllTypes: FunctionReference<
|
|
1837
|
+
"action",
|
|
1838
|
+
"internal",
|
|
1839
|
+
{
|
|
1840
|
+
accessToken: string;
|
|
1841
|
+
after?: number;
|
|
1842
|
+
before?: number;
|
|
1843
|
+
connectionId: string;
|
|
1844
|
+
userId: string;
|
|
1845
|
+
},
|
|
1846
|
+
any,
|
|
1678
1847
|
Name
|
|
1679
1848
|
>;
|
|
1680
1849
|
syncStrava: FunctionReference<
|
|
@@ -1682,15 +1851,13 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
1682
1851
|
"internal",
|
|
1683
1852
|
{
|
|
1684
1853
|
after?: number;
|
|
1685
|
-
baseUrl?: string;
|
|
1686
1854
|
clientId: string;
|
|
1687
1855
|
clientSecret: string;
|
|
1688
|
-
includeStreams?: boolean;
|
|
1689
1856
|
userId: string;
|
|
1690
1857
|
},
|
|
1691
1858
|
{
|
|
1692
|
-
errors: Array<{
|
|
1693
|
-
synced: number;
|
|
1859
|
+
errors: Array<{ error: string; id: string; type: string }>;
|
|
1860
|
+
synced: { activities: number; athletes: number };
|
|
1694
1861
|
},
|
|
1695
1862
|
Name
|
|
1696
1863
|
>;
|
|
@@ -32,15 +32,6 @@ export function generateCodeVerifier(length = 64): string {
|
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* Generate a random state parameter for CSRF protection.
|
|
37
|
-
*/
|
|
38
|
-
export function generateState(): string {
|
|
39
|
-
const bytes = new Uint8Array(32);
|
|
40
|
-
crypto.getRandomValues(bytes);
|
|
41
|
-
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
35
|
/**
|
|
45
36
|
* Compute the S256 code challenge from a code verifier.
|
|
46
37
|
* Returns `base64url(sha256(verifier))`.
|
|
@@ -94,6 +94,10 @@ import {
|
|
|
94
94
|
garminMenstrualCycleTrackingPushPayloadSchema,
|
|
95
95
|
} from "./schemas/menstrualCycleTracking.js";
|
|
96
96
|
import { transformMenstrualCycleTracking } from "./transform/menstrualCycleTracking.js";
|
|
97
|
+
import { refreshToken } from "./auth";
|
|
98
|
+
import type { Doc, Id } from "../_generated/dataModel";
|
|
99
|
+
|
|
100
|
+
const REFRESH_BUFFER_SECONDS = 600;
|
|
97
101
|
// ─── Internal Pending OAuth CRUD ─────────────────────────────────────────────
|
|
98
102
|
// Temporary storage for in-progress Garmin OAuth 2.0 PKCE flows.
|
|
99
103
|
// Bridges getGarminAuthUrl and completeGarminOAuth.
|
|
@@ -117,18 +121,6 @@ export const storePendingOAuth = internalMutation({
|
|
|
117
121
|
|
|
118
122
|
export const getPendingOAuth = internalQuery({
|
|
119
123
|
args: { state: v.string() },
|
|
120
|
-
returns: v.union(
|
|
121
|
-
v.object({
|
|
122
|
-
_id: v.id("pendingOAuth"),
|
|
123
|
-
_creationTime: v.number(),
|
|
124
|
-
provider: v.string(),
|
|
125
|
-
state: v.string(),
|
|
126
|
-
codeVerifier: v.string(),
|
|
127
|
-
userId: v.string(),
|
|
128
|
-
createdAt: v.number(),
|
|
129
|
-
}),
|
|
130
|
-
v.null(),
|
|
131
|
-
),
|
|
132
124
|
handler: async (ctx, args) => {
|
|
133
125
|
return await ctx.db
|
|
134
126
|
.query("pendingOAuth")
|
|
@@ -152,6 +144,84 @@ export const deletePendingOAuth = internalMutation({
|
|
|
152
144
|
},
|
|
153
145
|
});
|
|
154
146
|
|
|
147
|
+
export const resolveConnectionAndAccessToken = internalAction({
|
|
148
|
+
args: {
|
|
149
|
+
userId: v.string(),
|
|
150
|
+
clientId: v.string(),
|
|
151
|
+
clientSecret: v.string(),
|
|
152
|
+
},
|
|
153
|
+
handler: async (ctx, args): Promise<{
|
|
154
|
+
connectionId: Id<"connections">;
|
|
155
|
+
accessToken: string;
|
|
156
|
+
}> => {
|
|
157
|
+
const connection: Doc<"connections"> | null = await ctx.runQuery(
|
|
158
|
+
internal.private.getConnectionByProvider,
|
|
159
|
+
{ userId: args.userId, provider: "GARMIN" },
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
if (!connection) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`No Garmin connection found for user "${args.userId}". ` +
|
|
165
|
+
"Connect to Garmin first via getGarminAuthUrl.",
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!connection.active) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Garmin connection for user "${args.userId}" is inactive. Reconnect first.`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const connectionId = connection._id;
|
|
176
|
+
|
|
177
|
+
const tokenDoc: Doc<"providerTokens"> | null = await ctx.runQuery(
|
|
178
|
+
internal.garmin.private.getTokens,
|
|
179
|
+
{ connectionId },
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
if (!tokenDoc) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
"No Garmin tokens found for this connection. " +
|
|
185
|
+
"The connection may have been created before token storage was available.",
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let accessToken = tokenDoc.accessToken;
|
|
190
|
+
|
|
191
|
+
// Refresh the token if it's expired or about to expire
|
|
192
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
193
|
+
if (
|
|
194
|
+
tokenDoc.expiresAt &&
|
|
195
|
+
tokenDoc.refreshToken &&
|
|
196
|
+
nowSeconds >= tokenDoc.expiresAt - REFRESH_BUFFER_SECONDS
|
|
197
|
+
) {
|
|
198
|
+
const refreshed = await refreshToken({
|
|
199
|
+
clientId: args.clientId,
|
|
200
|
+
clientSecret: args.clientSecret,
|
|
201
|
+
refreshToken: tokenDoc.refreshToken,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
accessToken = refreshed.access_token;
|
|
205
|
+
const newExpiresAt = nowSeconds + refreshed.expires_in;
|
|
206
|
+
|
|
207
|
+
const _refreshed: null = await ctx.runMutation(
|
|
208
|
+
internal.garmin.private.storeTokens,
|
|
209
|
+
{
|
|
210
|
+
connectionId,
|
|
211
|
+
accessToken: refreshed.access_token,
|
|
212
|
+
refreshToken: refreshed.refresh_token,
|
|
213
|
+
expiresAt: newExpiresAt,
|
|
214
|
+
},
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
connectionId,
|
|
220
|
+
accessToken,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
155
225
|
// ─── Internal Token CRUD ─────────────────────────────────────────────────────
|
|
156
226
|
|
|
157
227
|
/**
|
|
@@ -240,6 +310,8 @@ export const deleteTokens = internalMutation({
|
|
|
240
310
|
},
|
|
241
311
|
});
|
|
242
312
|
|
|
313
|
+
|
|
314
|
+
|
|
243
315
|
// ─── Activity Push Processing ───────────────────────────────────────────────
|
|
244
316
|
|
|
245
317
|
/**
|