@contractspec/integration.providers-impls 3.8.8 → 3.8.10
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/analytics.js +1 -2
- package/dist/calendar.js +1 -2
- package/dist/database.js +1 -2
- package/dist/email.js +1 -2
- package/dist/embedding.js +1 -2
- package/dist/health.js +1 -2
- package/dist/impls/async-event-queue.js +1 -48
- package/dist/impls/composio-fallback-resolver.js +1 -579
- package/dist/impls/composio-mcp.js +1 -163
- package/dist/impls/composio-proxies.js +1 -310
- package/dist/impls/composio-sdk.js +1 -77
- package/dist/impls/composio-types.js +1 -53
- package/dist/impls/elevenlabs-voice.js +1 -104
- package/dist/impls/fal-voice.js +1 -117
- package/dist/impls/fathom-meeting-recorder.js +2 -289
- package/dist/impls/fathom-meeting-recorder.mapper.js +1 -107
- package/dist/impls/fathom-meeting-recorder.utils.js +1 -74
- package/dist/impls/fathom-meeting-recorder.webhooks.js +1 -31
- package/dist/impls/fireflies-meeting-recorder.js +5 -203
- package/dist/impls/fireflies-meeting-recorder.queries.js +4 -14
- package/dist/impls/fireflies-meeting-recorder.utils.js +1 -44
- package/dist/impls/gcs-storage.js +1 -99
- package/dist/impls/gmail-inbound.js +1 -229
- package/dist/impls/gmail-outbound.js +25 -137
- package/dist/impls/google-calendar.js +1 -193
- package/dist/impls/gradium-voice.js +1 -95
- package/dist/impls/granola-meeting-recorder.js +3 -514
- package/dist/impls/granola-meeting-recorder.mcp.js +1 -280
- package/dist/impls/health/base-health-provider.js +1 -617
- package/dist/impls/health/hybrid-health-providers.js +1 -1089
- package/dist/impls/health/official-health-providers.js +1 -969
- package/dist/impls/health/provider-normalizers.js +1 -288
- package/dist/impls/health/providers.js +1 -1095
- package/dist/impls/health-provider-factory.js +1 -1309
- package/dist/impls/index.js +42 -7448
- package/dist/impls/jira.js +1 -126
- package/dist/impls/linear.js +1 -85
- package/dist/impls/messaging-github.js +1 -111
- package/dist/impls/messaging-slack.js +1 -81
- package/dist/impls/messaging-telegram.js +1 -48
- package/dist/impls/messaging-whatsapp-meta.js +1 -53
- package/dist/impls/messaging-whatsapp-twilio.js +1 -83
- package/dist/impls/mistral-conversational.js +2 -477
- package/dist/impls/mistral-conversational.session.js +2 -207
- package/dist/impls/mistral-embedding.js +1 -45
- package/dist/impls/mistral-llm.js +1 -271
- package/dist/impls/mistral-stt.js +1 -168
- package/dist/impls/notion.js +1 -162
- package/dist/impls/posthog-reader.js +1 -161
- package/dist/impls/posthog-utils.js +1 -40
- package/dist/impls/posthog.js +1 -324
- package/dist/impls/postmark-email.js +1 -62
- package/dist/impls/powens-client.js +1 -197
- package/dist/impls/powens-openbanking.js +1 -428
- package/dist/impls/provider-factory.js +18 -6268
- package/dist/impls/qdrant-vector.js +1 -80
- package/dist/impls/stripe-payments.js +1 -230
- package/dist/impls/supabase-psql.js +1 -152
- package/dist/impls/supabase-vector.js +9 -298
- package/dist/impls/tldv-meeting-recorder.js +2 -147
- package/dist/impls/twilio-sms.js +1 -67
- package/dist/index.js +42 -7495
- package/dist/llm.js +1 -2
- package/dist/meeting-recorder.js +1 -2
- package/dist/messaging.js +1 -2
- package/dist/node/analytics.js +1 -2
- package/dist/node/calendar.js +1 -2
- package/dist/node/database.js +1 -2
- package/dist/node/email.js +1 -2
- package/dist/node/embedding.js +1 -2
- package/dist/node/health.js +1 -2
- package/dist/node/impls/async-event-queue.js +1 -49
- package/dist/node/impls/composio-fallback-resolver.js +1 -580
- package/dist/node/impls/composio-mcp.js +1 -164
- package/dist/node/impls/composio-proxies.js +1 -311
- package/dist/node/impls/composio-sdk.js +1 -78
- package/dist/node/impls/composio-types.js +1 -54
- package/dist/node/impls/elevenlabs-voice.js +1 -105
- package/dist/node/impls/fal-voice.js +1 -118
- package/dist/node/impls/fathom-meeting-recorder.js +2 -290
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +1 -108
- package/dist/node/impls/fathom-meeting-recorder.utils.js +1 -75
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +1 -32
- package/dist/node/impls/fireflies-meeting-recorder.js +5 -204
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +4 -15
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +1 -45
- package/dist/node/impls/gcs-storage.js +1 -100
- package/dist/node/impls/gmail-inbound.js +1 -230
- package/dist/node/impls/gmail-outbound.js +25 -138
- package/dist/node/impls/google-calendar.js +1 -194
- package/dist/node/impls/gradium-voice.js +1 -96
- package/dist/node/impls/granola-meeting-recorder.js +3 -515
- package/dist/node/impls/granola-meeting-recorder.mcp.js +1 -281
- package/dist/node/impls/health/base-health-provider.js +1 -618
- package/dist/node/impls/health/hybrid-health-providers.js +1 -1090
- package/dist/node/impls/health/official-health-providers.js +1 -970
- package/dist/node/impls/health/provider-normalizers.js +1 -289
- package/dist/node/impls/health/providers.js +1 -1096
- package/dist/node/impls/health-provider-factory.js +1 -1310
- package/dist/node/impls/index.js +42 -7449
- package/dist/node/impls/jira.js +1 -127
- package/dist/node/impls/linear.js +1 -86
- package/dist/node/impls/messaging-github.js +1 -112
- package/dist/node/impls/messaging-slack.js +1 -82
- package/dist/node/impls/messaging-telegram.js +1 -49
- package/dist/node/impls/messaging-whatsapp-meta.js +1 -54
- package/dist/node/impls/messaging-whatsapp-twilio.js +1 -84
- package/dist/node/impls/mistral-conversational.js +2 -478
- package/dist/node/impls/mistral-conversational.session.js +2 -208
- package/dist/node/impls/mistral-embedding.js +1 -46
- package/dist/node/impls/mistral-llm.js +1 -272
- package/dist/node/impls/mistral-stt.js +1 -169
- package/dist/node/impls/notion.js +1 -163
- package/dist/node/impls/posthog-reader.js +1 -162
- package/dist/node/impls/posthog-utils.js +1 -41
- package/dist/node/impls/posthog.js +1 -325
- package/dist/node/impls/postmark-email.js +1 -63
- package/dist/node/impls/powens-client.js +1 -198
- package/dist/node/impls/powens-openbanking.js +1 -429
- package/dist/node/impls/provider-factory.js +18 -6269
- package/dist/node/impls/qdrant-vector.js +1 -81
- package/dist/node/impls/stripe-payments.js +1 -231
- package/dist/node/impls/supabase-psql.js +1 -153
- package/dist/node/impls/supabase-vector.js +9 -299
- package/dist/node/impls/tldv-meeting-recorder.js +2 -148
- package/dist/node/impls/twilio-sms.js +1 -68
- package/dist/node/index.js +42 -7496
- package/dist/node/llm.js +1 -2
- package/dist/node/meeting-recorder.js +1 -2
- package/dist/node/messaging.js +1 -2
- package/dist/node/openbanking.js +1 -2
- package/dist/node/payments.js +1 -2
- package/dist/node/project-management.js +1 -2
- package/dist/node/secrets/provider.js +1 -14
- package/dist/node/sms.js +1 -2
- package/dist/node/storage.js +1 -2
- package/dist/node/vector-store.js +1 -2
- package/dist/node/voice.js +1 -2
- package/dist/openbanking.js +1 -2
- package/dist/payments.js +1 -2
- package/dist/project-management.js +1 -2
- package/dist/secrets/provider.js +1 -13
- package/dist/sms.js +1 -2
- package/dist/storage.js +1 -2
- package/dist/vector-store.js +1 -2
- package/dist/voice.js +1 -2
- package/package.json +17 -17
|
@@ -1,289 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
// src/impls/health/provider-normalizers.ts
|
|
5
|
-
var DEFAULT_LIST_KEYS = [
|
|
6
|
-
"items",
|
|
7
|
-
"data",
|
|
8
|
-
"records",
|
|
9
|
-
"activities",
|
|
10
|
-
"workouts",
|
|
11
|
-
"sleep",
|
|
12
|
-
"biometrics",
|
|
13
|
-
"nutrition"
|
|
14
|
-
];
|
|
15
|
-
function asRecord(value) {
|
|
16
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
function asArray(value) {
|
|
22
|
-
return Array.isArray(value) ? value : undefined;
|
|
23
|
-
}
|
|
24
|
-
function readString(record, keys) {
|
|
25
|
-
if (!record)
|
|
26
|
-
return;
|
|
27
|
-
for (const key of keys) {
|
|
28
|
-
const value = record[key];
|
|
29
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
function readNumber(record, keys) {
|
|
36
|
-
if (!record)
|
|
37
|
-
return;
|
|
38
|
-
for (const key of keys) {
|
|
39
|
-
const value = record[key];
|
|
40
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
44
|
-
const parsed = Number(value);
|
|
45
|
-
if (Number.isFinite(parsed)) {
|
|
46
|
-
return parsed;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
function readBoolean(record, keys) {
|
|
53
|
-
if (!record)
|
|
54
|
-
return;
|
|
55
|
-
for (const key of keys) {
|
|
56
|
-
const value = record[key];
|
|
57
|
-
if (typeof value === "boolean") {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
function extractList(payload, listKeys = DEFAULT_LIST_KEYS) {
|
|
64
|
-
const root = asRecord(payload);
|
|
65
|
-
if (!root) {
|
|
66
|
-
return asArray(payload)?.map((item) => asRecord(item)).filter((item) => Boolean(item)) ?? [];
|
|
67
|
-
}
|
|
68
|
-
for (const key of listKeys) {
|
|
69
|
-
const arrayValue = asArray(root[key]);
|
|
70
|
-
if (!arrayValue)
|
|
71
|
-
continue;
|
|
72
|
-
return arrayValue.map((item) => asRecord(item)).filter((item) => Boolean(item));
|
|
73
|
-
}
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
function extractPagination(payload) {
|
|
77
|
-
const root = asRecord(payload);
|
|
78
|
-
const nestedPagination = asRecord(root?.pagination);
|
|
79
|
-
const nextCursor = readString(nestedPagination, ["nextCursor", "next_cursor"]) ?? readString(root, [
|
|
80
|
-
"nextCursor",
|
|
81
|
-
"next_cursor",
|
|
82
|
-
"cursor",
|
|
83
|
-
"next_page_token"
|
|
84
|
-
]);
|
|
85
|
-
const hasMore = readBoolean(nestedPagination, ["hasMore", "has_more"]) ?? readBoolean(root, ["hasMore", "has_more"]);
|
|
86
|
-
return {
|
|
87
|
-
nextCursor,
|
|
88
|
-
hasMore: hasMore ?? Boolean(nextCursor)
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function toHealthActivity(item, context, fallbackType = "activity") {
|
|
92
|
-
const externalId = readString(item, ["external_id", "externalId", "uuid", "id"]) ?? `${context.providerKey}:${fallbackType}`;
|
|
93
|
-
const id = readString(item, ["id", "uuid", "workout_id"]) ?? `${context.providerKey}:activity:${externalId}`;
|
|
94
|
-
return {
|
|
95
|
-
id,
|
|
96
|
-
externalId,
|
|
97
|
-
tenantId: context.tenantId,
|
|
98
|
-
connectionId: context.connectionId ?? "unknown",
|
|
99
|
-
userId: readString(item, ["user_id", "userId", "athlete_id"]),
|
|
100
|
-
providerKey: context.providerKey,
|
|
101
|
-
activityType: readString(item, ["activity_type", "type", "sport_type", "sport"]) ?? fallbackType,
|
|
102
|
-
startedAt: readIsoDate(item, [
|
|
103
|
-
"started_at",
|
|
104
|
-
"start_time",
|
|
105
|
-
"start_date",
|
|
106
|
-
"created_at"
|
|
107
|
-
]),
|
|
108
|
-
endedAt: readIsoDate(item, ["ended_at", "end_time"]),
|
|
109
|
-
durationSeconds: readNumber(item, [
|
|
110
|
-
"duration_seconds",
|
|
111
|
-
"duration",
|
|
112
|
-
"elapsed_time"
|
|
113
|
-
]),
|
|
114
|
-
distanceMeters: readNumber(item, ["distance_meters", "distance"]),
|
|
115
|
-
caloriesKcal: readNumber(item, [
|
|
116
|
-
"calories_kcal",
|
|
117
|
-
"calories",
|
|
118
|
-
"active_kilocalories"
|
|
119
|
-
]),
|
|
120
|
-
steps: readNumber(item, ["steps"])?.valueOf(),
|
|
121
|
-
metadata: item
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function toHealthWorkout(item, context, fallbackType = "workout") {
|
|
125
|
-
const activity = toHealthActivity(item, context, fallbackType);
|
|
126
|
-
return {
|
|
127
|
-
id: activity.id,
|
|
128
|
-
externalId: activity.externalId,
|
|
129
|
-
tenantId: activity.tenantId,
|
|
130
|
-
connectionId: activity.connectionId,
|
|
131
|
-
userId: activity.userId,
|
|
132
|
-
providerKey: activity.providerKey,
|
|
133
|
-
workoutType: readString(item, [
|
|
134
|
-
"workout_type",
|
|
135
|
-
"sport_type",
|
|
136
|
-
"type",
|
|
137
|
-
"activity_type"
|
|
138
|
-
]) ?? fallbackType,
|
|
139
|
-
startedAt: activity.startedAt,
|
|
140
|
-
endedAt: activity.endedAt,
|
|
141
|
-
durationSeconds: activity.durationSeconds,
|
|
142
|
-
distanceMeters: activity.distanceMeters,
|
|
143
|
-
caloriesKcal: activity.caloriesKcal,
|
|
144
|
-
averageHeartRateBpm: readNumber(item, [
|
|
145
|
-
"average_heart_rate",
|
|
146
|
-
"avg_hr",
|
|
147
|
-
"average_heart_rate_bpm"
|
|
148
|
-
]),
|
|
149
|
-
maxHeartRateBpm: readNumber(item, [
|
|
150
|
-
"max_heart_rate",
|
|
151
|
-
"max_hr",
|
|
152
|
-
"max_heart_rate_bpm"
|
|
153
|
-
]),
|
|
154
|
-
metadata: item
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function toHealthSleep(item, context) {
|
|
158
|
-
const externalId = readString(item, ["external_id", "externalId", "uuid", "id"]) ?? `${context.providerKey}:sleep`;
|
|
159
|
-
const id = readString(item, ["id", "uuid"]) ?? `${context.providerKey}:sleep:${externalId}`;
|
|
160
|
-
const startedAt = readIsoDate(item, ["started_at", "start_time", "bedtime_start", "start"]) ?? new Date(0).toISOString();
|
|
161
|
-
const endedAt = readIsoDate(item, ["ended_at", "end_time", "bedtime_end", "end"]) ?? startedAt;
|
|
162
|
-
return {
|
|
163
|
-
id,
|
|
164
|
-
externalId,
|
|
165
|
-
tenantId: context.tenantId,
|
|
166
|
-
connectionId: context.connectionId ?? "unknown",
|
|
167
|
-
userId: readString(item, ["user_id", "userId"]),
|
|
168
|
-
providerKey: context.providerKey,
|
|
169
|
-
startedAt,
|
|
170
|
-
endedAt,
|
|
171
|
-
durationSeconds: readNumber(item, [
|
|
172
|
-
"duration_seconds",
|
|
173
|
-
"duration",
|
|
174
|
-
"total_sleep_duration"
|
|
175
|
-
]),
|
|
176
|
-
deepSleepSeconds: readNumber(item, [
|
|
177
|
-
"deep_sleep_seconds",
|
|
178
|
-
"deep_sleep_duration"
|
|
179
|
-
]),
|
|
180
|
-
lightSleepSeconds: readNumber(item, [
|
|
181
|
-
"light_sleep_seconds",
|
|
182
|
-
"light_sleep_duration"
|
|
183
|
-
]),
|
|
184
|
-
remSleepSeconds: readNumber(item, [
|
|
185
|
-
"rem_sleep_seconds",
|
|
186
|
-
"rem_sleep_duration"
|
|
187
|
-
]),
|
|
188
|
-
awakeSeconds: readNumber(item, ["awake_seconds", "awake_time"]),
|
|
189
|
-
sleepScore: readNumber(item, ["sleep_score", "score"]),
|
|
190
|
-
metadata: item
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function toHealthBiometric(item, context, metricTypeFallback = "metric") {
|
|
194
|
-
const externalId = readString(item, ["external_id", "externalId", "uuid", "id"]) ?? `${context.providerKey}:biometric`;
|
|
195
|
-
const id = readString(item, ["id", "uuid"]) ?? `${context.providerKey}:biometric:${externalId}`;
|
|
196
|
-
return {
|
|
197
|
-
id,
|
|
198
|
-
externalId,
|
|
199
|
-
tenantId: context.tenantId,
|
|
200
|
-
connectionId: context.connectionId ?? "unknown",
|
|
201
|
-
userId: readString(item, ["user_id", "userId"]),
|
|
202
|
-
providerKey: context.providerKey,
|
|
203
|
-
metricType: readString(item, ["metric_type", "metric", "type", "name"]) ?? metricTypeFallback,
|
|
204
|
-
value: readNumber(item, ["value", "score", "measurement"]) ?? 0,
|
|
205
|
-
unit: readString(item, ["unit"]),
|
|
206
|
-
measuredAt: readIsoDate(item, ["measured_at", "timestamp", "created_at"]) ?? new Date().toISOString(),
|
|
207
|
-
metadata: item
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function toHealthNutrition(item, context) {
|
|
211
|
-
const externalId = readString(item, ["external_id", "externalId", "uuid", "id"]) ?? `${context.providerKey}:nutrition`;
|
|
212
|
-
const id = readString(item, ["id", "uuid"]) ?? `${context.providerKey}:nutrition:${externalId}`;
|
|
213
|
-
return {
|
|
214
|
-
id,
|
|
215
|
-
externalId,
|
|
216
|
-
tenantId: context.tenantId,
|
|
217
|
-
connectionId: context.connectionId ?? "unknown",
|
|
218
|
-
userId: readString(item, ["user_id", "userId"]),
|
|
219
|
-
providerKey: context.providerKey,
|
|
220
|
-
loggedAt: readIsoDate(item, ["logged_at", "created_at", "date", "timestamp"]) ?? new Date().toISOString(),
|
|
221
|
-
caloriesKcal: readNumber(item, ["calories_kcal", "calories"]),
|
|
222
|
-
proteinGrams: readNumber(item, ["protein_grams", "protein"]),
|
|
223
|
-
carbsGrams: readNumber(item, ["carbs_grams", "carbs"]),
|
|
224
|
-
fatGrams: readNumber(item, ["fat_grams", "fat"]),
|
|
225
|
-
fiberGrams: readNumber(item, ["fiber_grams", "fiber"]),
|
|
226
|
-
hydrationMl: readNumber(item, ["hydration_ml", "water_ml", "water"]),
|
|
227
|
-
metadata: item
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
function toHealthConnectionStatus(payload, params, source) {
|
|
231
|
-
const record = asRecord(payload);
|
|
232
|
-
const rawStatus = readString(record, ["status", "connection_status", "health"]) ?? "healthy";
|
|
233
|
-
return {
|
|
234
|
-
tenantId: params.tenantId,
|
|
235
|
-
connectionId: params.connectionId,
|
|
236
|
-
status: rawStatus === "healthy" || rawStatus === "degraded" || rawStatus === "error" || rawStatus === "disconnected" ? rawStatus : "healthy",
|
|
237
|
-
source,
|
|
238
|
-
lastCheckedAt: readIsoDate(record, ["last_checked_at", "lastCheckedAt"]) ?? new Date().toISOString(),
|
|
239
|
-
errorCode: readString(record, ["error_code", "errorCode"]),
|
|
240
|
-
errorMessage: readString(record, ["error_message", "errorMessage"]),
|
|
241
|
-
metadata: asRecord(record?.metadata)
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function toHealthWebhookEvent(payload, providerKey, verified) {
|
|
245
|
-
const record = asRecord(payload);
|
|
246
|
-
const entityType = readString(record, ["entity_type", "entityType", "type"]);
|
|
247
|
-
const normalizedEntityType = entityType === "activity" || entityType === "workout" || entityType === "sleep" || entityType === "biometric" || entityType === "nutrition" ? entityType : undefined;
|
|
248
|
-
return {
|
|
249
|
-
providerKey,
|
|
250
|
-
eventType: readString(record, ["event_type", "eventType", "event"]),
|
|
251
|
-
externalEntityId: readString(record, [
|
|
252
|
-
"external_entity_id",
|
|
253
|
-
"externalEntityId",
|
|
254
|
-
"entity_id",
|
|
255
|
-
"entityId",
|
|
256
|
-
"id"
|
|
257
|
-
]),
|
|
258
|
-
entityType: normalizedEntityType,
|
|
259
|
-
receivedAt: new Date().toISOString(),
|
|
260
|
-
verified,
|
|
261
|
-
payload,
|
|
262
|
-
metadata: asRecord(record?.metadata)
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
function readIsoDate(record, keys) {
|
|
266
|
-
const value = readString(record, keys);
|
|
267
|
-
if (!value)
|
|
268
|
-
return;
|
|
269
|
-
const parsed = new Date(value);
|
|
270
|
-
if (Number.isNaN(parsed.getTime()))
|
|
271
|
-
return;
|
|
272
|
-
return parsed.toISOString();
|
|
273
|
-
}
|
|
274
|
-
export {
|
|
275
|
-
toHealthWorkout,
|
|
276
|
-
toHealthWebhookEvent,
|
|
277
|
-
toHealthSleep,
|
|
278
|
-
toHealthNutrition,
|
|
279
|
-
toHealthConnectionStatus,
|
|
280
|
-
toHealthBiometric,
|
|
281
|
-
toHealthActivity,
|
|
282
|
-
readString,
|
|
283
|
-
readNumber,
|
|
284
|
-
readBoolean,
|
|
285
|
-
extractPagination,
|
|
286
|
-
extractList,
|
|
287
|
-
asRecord,
|
|
288
|
-
asArray
|
|
289
|
-
};
|
|
2
|
+
var y=import.meta.require;var p=["items","data","records","activities","workouts","sleep","biometrics","nutrition"];function i(e){if(!e||typeof e!=="object"||Array.isArray(e))return;return e}function u(e){return Array.isArray(e)?e:void 0}function a(e,t){if(!e)return;for(let r of t){let n=e[r];if(typeof n==="string"&&n.trim().length>0)return n}return}function d(e,t){if(!e)return;for(let r of t){let n=e[r];if(typeof n==="number"&&Number.isFinite(n))return n;if(typeof n==="string"&&n.trim().length>0){let o=Number(n);if(Number.isFinite(o))return o}}return}function l(e,t){if(!e)return;for(let r of t){let n=e[r];if(typeof n==="boolean")return n}return}function h(e,t=p){let r=i(e);if(!r)return u(e)?.map((n)=>i(n)).filter((n)=>Boolean(n))??[];for(let n of t){let o=u(r[n]);if(!o)continue;return o.map((s)=>i(s)).filter((s)=>Boolean(s))}return[]}function I(e){let t=i(e),r=i(t?.pagination),n=a(r,["nextCursor","next_cursor"])??a(t,["nextCursor","next_cursor","cursor","next_page_token"]),o=l(r,["hasMore","has_more"])??l(t,["hasMore","has_more"]);return{nextCursor:n,hasMore:o??Boolean(n)}}function _(e,t,r="activity"){let n=a(e,["external_id","externalId","uuid","id"])??`${t.providerKey}:${r}`;return{id:a(e,["id","uuid","workout_id"])??`${t.providerKey}:activity:${n}`,externalId:n,tenantId:t.tenantId,connectionId:t.connectionId??"unknown",userId:a(e,["user_id","userId","athlete_id"]),providerKey:t.providerKey,activityType:a(e,["activity_type","type","sport_type","sport"])??r,startedAt:c(e,["started_at","start_time","start_date","created_at"]),endedAt:c(e,["ended_at","end_time"]),durationSeconds:d(e,["duration_seconds","duration","elapsed_time"]),distanceMeters:d(e,["distance_meters","distance"]),caloriesKcal:d(e,["calories_kcal","calories","active_kilocalories"]),steps:d(e,["steps"])?.valueOf(),metadata:e}}function k(e,t,r="workout"){let n=_(e,t,r);return{id:n.id,externalId:n.externalId,tenantId:n.tenantId,connectionId:n.connectionId,userId:n.userId,providerKey:n.providerKey,workoutType:a(e,["workout_type","sport_type","type","activity_type"])??r,startedAt:n.startedAt,endedAt:n.endedAt,durationSeconds:n.durationSeconds,distanceMeters:n.distanceMeters,caloriesKcal:n.caloriesKcal,averageHeartRateBpm:d(e,["average_heart_rate","avg_hr","average_heart_rate_bpm"]),maxHeartRateBpm:d(e,["max_heart_rate","max_hr","max_heart_rate_bpm"]),metadata:e}}function g(e,t){let r=a(e,["external_id","externalId","uuid","id"])??`${t.providerKey}:sleep`,n=a(e,["id","uuid"])??`${t.providerKey}:sleep:${r}`,o=c(e,["started_at","start_time","bedtime_start","start"])??new Date(0).toISOString(),s=c(e,["ended_at","end_time","bedtime_end","end"])??o;return{id:n,externalId:r,tenantId:t.tenantId,connectionId:t.connectionId??"unknown",userId:a(e,["user_id","userId"]),providerKey:t.providerKey,startedAt:o,endedAt:s,durationSeconds:d(e,["duration_seconds","duration","total_sleep_duration"]),deepSleepSeconds:d(e,["deep_sleep_seconds","deep_sleep_duration"]),lightSleepSeconds:d(e,["light_sleep_seconds","light_sleep_duration"]),remSleepSeconds:d(e,["rem_sleep_seconds","rem_sleep_duration"]),awakeSeconds:d(e,["awake_seconds","awake_time"]),sleepScore:d(e,["sleep_score","score"]),metadata:e}}function v(e,t,r="metric"){let n=a(e,["external_id","externalId","uuid","id"])??`${t.providerKey}:biometric`;return{id:a(e,["id","uuid"])??`${t.providerKey}:biometric:${n}`,externalId:n,tenantId:t.tenantId,connectionId:t.connectionId??"unknown",userId:a(e,["user_id","userId"]),providerKey:t.providerKey,metricType:a(e,["metric_type","metric","type","name"])??r,value:d(e,["value","score","measurement"])??0,unit:a(e,["unit"]),measuredAt:c(e,["measured_at","timestamp","created_at"])??new Date().toISOString(),metadata:e}}function w(e,t){let r=a(e,["external_id","externalId","uuid","id"])??`${t.providerKey}:nutrition`;return{id:a(e,["id","uuid"])??`${t.providerKey}:nutrition:${r}`,externalId:r,tenantId:t.tenantId,connectionId:t.connectionId??"unknown",userId:a(e,["user_id","userId"]),providerKey:t.providerKey,loggedAt:c(e,["logged_at","created_at","date","timestamp"])??new Date().toISOString(),caloriesKcal:d(e,["calories_kcal","calories"]),proteinGrams:d(e,["protein_grams","protein"]),carbsGrams:d(e,["carbs_grams","carbs"]),fatGrams:d(e,["fat_grams","fat"]),fiberGrams:d(e,["fiber_grams","fiber"]),hydrationMl:d(e,["hydration_ml","water_ml","water"]),metadata:e}}function m(e,t,r){let n=i(e),o=a(n,["status","connection_status","health"])??"healthy";return{tenantId:t.tenantId,connectionId:t.connectionId,status:o==="healthy"||o==="degraded"||o==="error"||o==="disconnected"?o:"healthy",source:r,lastCheckedAt:c(n,["last_checked_at","lastCheckedAt"])??new Date().toISOString(),errorCode:a(n,["error_code","errorCode"]),errorMessage:a(n,["error_message","errorMessage"]),metadata:i(n?.metadata)}}function S(e,t,r){let n=i(e),o=a(n,["entity_type","entityType","type"]),s=o==="activity"||o==="workout"||o==="sleep"||o==="biometric"||o==="nutrition"?o:void 0;return{providerKey:t,eventType:a(n,["event_type","eventType","event"]),externalEntityId:a(n,["external_entity_id","externalEntityId","entity_id","entityId","id"]),entityType:s,receivedAt:new Date().toISOString(),verified:r,payload:e,metadata:i(n?.metadata)}}function c(e,t){let r=a(e,t);if(!r)return;let n=new Date(r);if(Number.isNaN(n.getTime()))return;return n.toISOString()}export{k as toHealthWorkout,S as toHealthWebhookEvent,g as toHealthSleep,w as toHealthNutrition,m as toHealthConnectionStatus,v as toHealthBiometric,_ as toHealthActivity,a as readString,d as readNumber,l as readBoolean,I as extractPagination,h as extractList,i as asRecord,u as asArray};
|