@nativesquare/soma 0.16.3 → 0.16.5
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/healthkit.d.ts +1 -1
- package/dist/client/healthkit.js +1 -1
- package/dist/client/index.d.ts +150 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +30 -0
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +123 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/healthkit/public.d.ts +1 -1
- package/dist/component/healthkit/public.js +3 -3
- package/dist/component/healthkit/public.js.map +1 -1
- package/dist/component/private.d.ts +90 -0
- package/dist/component/private.d.ts.map +1 -1
- package/dist/component/public.d.ts +118 -6
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +91 -21
- package/dist/component/public.js.map +1 -1
- package/dist/component/schema.d.ts +111 -1
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/utils.d.ts +27 -0
- package/dist/component/utils.d.ts.map +1 -1
- package/dist/component/utils.js +64 -0
- package/dist/component/utils.js.map +1 -1
- package/dist/component/validators/connection.d.ts +160 -0
- package/dist/component/validators/connection.d.ts.map +1 -1
- package/dist/component/validators/connection.js +17 -1
- package/dist/component/validators/connection.js.map +1 -1
- package/dist/validators.d.ts +80 -0
- package/dist/validators.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/healthkit.ts +1 -1
- package/src/client/index.ts +34 -0
- package/src/component/_generated/component.ts +42 -0
- package/src/component/healthkit/public.ts +597 -597
- package/src/component/public.ts +130 -21
- package/src/component/utils.ts +116 -22
- package/src/component/validators/connection.ts +19 -1
package/src/client/index.ts
CHANGED
|
@@ -207,6 +207,40 @@ export class Soma {
|
|
|
207
207
|
);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Get per-table row counts and oldest-data timestamps for a user–provider pair.
|
|
212
|
+
*
|
|
213
|
+
* Returns an object with one entry per data table (activities, sleep, body,
|
|
214
|
+
* daily, nutrition, menstruation, plannedWorkouts). Each entry has a `count`
|
|
215
|
+
* and an `oldest` timestamp (ISO-8601 for time-series tables, YYYY-MM-DD for
|
|
216
|
+
* plannedWorkouts). `oldest` is `null` when the table has no rows.
|
|
217
|
+
*
|
|
218
|
+
* Stats are maintained automatically by ingest mutations, so this is an O(1)
|
|
219
|
+
* read regardless of how much data has been ingested.
|
|
220
|
+
*
|
|
221
|
+
* Returns `null` if the user has never connected to that provider.
|
|
222
|
+
*
|
|
223
|
+
* @param ctx - Query context from the host app
|
|
224
|
+
* @param args.userId - The host app's user identifier
|
|
225
|
+
* @param args.provider - The wearable provider name
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* const stats = await soma.getProviderStats(ctx, {
|
|
230
|
+
* userId: "user_123",
|
|
231
|
+
* provider: "GARMIN",
|
|
232
|
+
* });
|
|
233
|
+
* // { activities: { count: 1203, oldest: "2023-02-14T06:12:00Z" },
|
|
234
|
+
* // sleep: { count: 412, oldest: "2023-02-14T23:01:00Z" }, ... }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
async getProviderStats(
|
|
238
|
+
ctx: QueryCtx,
|
|
239
|
+
args: { userId: string; provider: string },
|
|
240
|
+
) {
|
|
241
|
+
return await ctx.runQuery(this.component.public.getProviderStats, args);
|
|
242
|
+
}
|
|
243
|
+
|
|
210
244
|
/**
|
|
211
245
|
* List all connections for a user (active and inactive).
|
|
212
246
|
*
|
|
@@ -866,6 +866,15 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
866
866
|
lastDataUpdate?: string;
|
|
867
867
|
provider: string;
|
|
868
868
|
providerUserId?: string;
|
|
869
|
+
stats?: {
|
|
870
|
+
activities: { count: number; oldest: string | null };
|
|
871
|
+
body: { count: number; oldest: string | null };
|
|
872
|
+
daily: { count: number; oldest: string | null };
|
|
873
|
+
menstruation: { count: number; oldest: string | null };
|
|
874
|
+
nutrition: { count: number; oldest: string | null };
|
|
875
|
+
plannedWorkouts: { count: number; oldest: string | null };
|
|
876
|
+
sleep: { count: number; oldest: string | null };
|
|
877
|
+
};
|
|
869
878
|
userId: string;
|
|
870
879
|
},
|
|
871
880
|
Name
|
|
@@ -881,6 +890,15 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
881
890
|
lastDataUpdate?: string;
|
|
882
891
|
provider: string;
|
|
883
892
|
providerUserId?: string;
|
|
893
|
+
stats?: {
|
|
894
|
+
activities: { count: number; oldest: string | null };
|
|
895
|
+
body: { count: number; oldest: string | null };
|
|
896
|
+
daily: { count: number; oldest: string | null };
|
|
897
|
+
menstruation: { count: number; oldest: string | null };
|
|
898
|
+
nutrition: { count: number; oldest: string | null };
|
|
899
|
+
plannedWorkouts: { count: number; oldest: string | null };
|
|
900
|
+
sleep: { count: number; oldest: string | null };
|
|
901
|
+
};
|
|
884
902
|
userId: string;
|
|
885
903
|
},
|
|
886
904
|
Name
|
|
@@ -892,6 +910,21 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
892
910
|
any,
|
|
893
911
|
Name
|
|
894
912
|
>;
|
|
913
|
+
getProviderStats: FunctionReference<
|
|
914
|
+
"query",
|
|
915
|
+
"internal",
|
|
916
|
+
{ provider: string; userId: string },
|
|
917
|
+
null | {
|
|
918
|
+
activities: { count: number; oldest: string | null };
|
|
919
|
+
body: { count: number; oldest: string | null };
|
|
920
|
+
daily: { count: number; oldest: string | null };
|
|
921
|
+
menstruation: { count: number; oldest: string | null };
|
|
922
|
+
nutrition: { count: number; oldest: string | null };
|
|
923
|
+
plannedWorkouts: { count: number; oldest: string | null };
|
|
924
|
+
sleep: { count: number; oldest: string | null };
|
|
925
|
+
},
|
|
926
|
+
Name
|
|
927
|
+
>;
|
|
895
928
|
ingestActivity: FunctionReference<
|
|
896
929
|
"mutation",
|
|
897
930
|
"internal",
|
|
@@ -2021,6 +2054,15 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
2021
2054
|
lastDataUpdate?: string;
|
|
2022
2055
|
provider: string;
|
|
2023
2056
|
providerUserId?: string;
|
|
2057
|
+
stats?: {
|
|
2058
|
+
activities: { count: number; oldest: string | null };
|
|
2059
|
+
body: { count: number; oldest: string | null };
|
|
2060
|
+
daily: { count: number; oldest: string | null };
|
|
2061
|
+
menstruation: { count: number; oldest: string | null };
|
|
2062
|
+
nutrition: { count: number; oldest: string | null };
|
|
2063
|
+
plannedWorkouts: { count: number; oldest: string | null };
|
|
2064
|
+
sleep: { count: number; oldest: string | null };
|
|
2065
|
+
};
|
|
2024
2066
|
userId: string;
|
|
2025
2067
|
}>,
|
|
2026
2068
|
Name
|