@d4l/collect-lib 1.49.0 → 1.51.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.
package/dist/index.mjs CHANGED
@@ -749,7 +749,7 @@ var BLE_PSMS_ANNOTATION_ITEM_PPG_IR = {
749
749
  };
750
750
  var BLE_PSMS_ANNOTATION_ITEM_ACCELERATION = {
751
751
  type: "samsungSdkAcceleration",
752
- size: 12,
752
+ size: 6,
753
753
  format: "signedInt",
754
754
  littleEndian: true,
755
755
  channels: 3,
@@ -922,6 +922,33 @@ var GARMIN_ANNOTATION_ITEM_BLOOD_PRESSURE = {
922
922
  var GARMIN_BLOOD_PRESSURE_ANNOTATION = [
923
923
  GARMIN_ANNOTATION_ITEM_BLOOD_PRESSURE
924
924
  ];
925
+ var GARMIN_ANNOTATION_ITEM_ACTIVITY_LEVEL = {
926
+ type: "activityLevel",
927
+ size: 1,
928
+ format: "unsignedInt",
929
+ note: "0=sedentary, 1=active, 2=highly active (Garmin epoch intensity)"
930
+ };
931
+ var GARMIN_ANNOTATION_ITEM_ACTIVITY_METS = {
932
+ type: "averageMetabolicEquivalent",
933
+ size: 4,
934
+ format: "float32",
935
+ littleEndian: true,
936
+ unit: "MET",
937
+ note: "average METs over the epoch; 0 when Garmin sent none"
938
+ };
939
+ var GARMIN_ANNOTATION_ITEM_ACTIVITY_ACTIVE_TIME = {
940
+ type: "duration",
941
+ size: 2,
942
+ format: "unsignedInt",
943
+ littleEndian: true,
944
+ unit: "s",
945
+ note: "active seconds within the 15-minute epoch"
946
+ };
947
+ var GARMIN_ACTIVITY_ANNOTATION = [
948
+ GARMIN_ANNOTATION_ITEM_ACTIVITY_LEVEL,
949
+ GARMIN_ANNOTATION_ITEM_ACTIVITY_METS,
950
+ GARMIN_ANNOTATION_ITEM_ACTIVITY_ACTIVE_TIME
951
+ ];
925
952
  var GARMIN_SIGNAL_TYPE_ANNOTATIONS = {
926
953
  heartRate: FITBIT_HEART_RATE_ANNOTATION,
927
954
  hrv: FITBIT_HEART_RATE_VARIABILITY_ANNOTATION,
@@ -942,7 +969,8 @@ var GARMIN_SIGNAL_TYPE_ANNOTATIONS = {
942
969
  sleepScore: GARMIN_SLEEP_SCORE_ANNOTATION,
943
970
  vo2max: GARMIN_VO2MAX_ANNOTATION,
944
971
  bodyComposition: GARMIN_BODY_COMPOSITION_ANNOTATION,
945
- bloodPressure: GARMIN_BLOOD_PRESSURE_ANNOTATION
972
+ bloodPressure: GARMIN_BLOOD_PRESSURE_ANNOTATION,
973
+ activity: GARMIN_ACTIVITY_ANNOTATION
946
974
  };
947
975
 
948
976
  // src/devices/annotations/movella.ts
@@ -6280,6 +6308,38 @@ var DonationSDK = class {
6280
6308
  }
6281
6309
  return true;
6282
6310
  }
6311
+ /**
6312
+ * Upload one batch of tracking events (BI events) to the dedicated tracking
6313
+ * endpoint. Tracking donations are stored under the `tracking` type on the
6314
+ * backend and are excluded from restoration.
6315
+ * @param donorIdentity The donor identity
6316
+ * @param program The program the events belong to
6317
+ * @param document The tracking events batch document
6318
+ * @param batchId The UUID identifying this batch (idempotent across retries)
6319
+ * @returns True if the upload succeeded
6320
+ */
6321
+ async donateTrackingEvents(donorIdentity, program, document, batchId) {
6322
+ validateProgramName(program.name, donorIdentity);
6323
+ if (!document.events.length) {
6324
+ return true;
6325
+ }
6326
+ const donations = await this.encryptDonations(
6327
+ [{ id: batchId, document, status: "Active" }],
6328
+ donorIdentity,
6329
+ program.donation.target
6330
+ );
6331
+ const authenticatedDonationAPI = await this.getAuthenticatedDonationAPI(donorIdentity);
6332
+ try {
6333
+ await authenticatedDonationAPI.put({
6334
+ uri: `/tracking/${program.name}`,
6335
+ body: JSON.stringify(donations)
6336
+ });
6337
+ } catch (e) {
6338
+ console.error(e);
6339
+ throw new Error("internal_server_error" /* INTERNAL_SERVER_ERROR */);
6340
+ }
6341
+ return true;
6342
+ }
6283
6343
  /**
6284
6344
  * Encrypt donations to be donated to a specific target
6285
6345
  * @param donatableRecords The donations to encrypt
@@ -6454,6 +6514,9 @@ var DonationSDK = class {
6454
6514
  }
6455
6515
  };
6456
6516
 
6517
+ // src/tracking/types.ts
6518
+ var TRACKING_RESOURCE_TYPE = "TrackingEvents";
6519
+
6457
6520
  // src/helper/datetime.ts
6458
6521
  var stringToDate = (dateString) => {
6459
6522
  const date = new Date(dateString);
@@ -7312,6 +7375,10 @@ export {
7312
7375
  FITBIT_SLEEP_LEVEL_MAP,
7313
7376
  FITBIT_SPO2_ANNOTATION,
7314
7377
  FITBIT_STEPS_ANNOTATION,
7378
+ GARMIN_ACTIVITY_ANNOTATION,
7379
+ GARMIN_ANNOTATION_ITEM_ACTIVITY_ACTIVE_TIME,
7380
+ GARMIN_ANNOTATION_ITEM_ACTIVITY_LEVEL,
7381
+ GARMIN_ANNOTATION_ITEM_ACTIVITY_METS,
7315
7382
  GARMIN_ANNOTATION_ITEM_BLOOD_PRESSURE,
7316
7383
  GARMIN_ANNOTATION_ITEM_BODY_BATTERY,
7317
7384
  GARMIN_ANNOTATION_ITEM_BODY_COMPOSITION,
@@ -7408,6 +7475,7 @@ export {
7408
7475
  TAG_LENGTH,
7409
7476
  TOPIC_ID_PATTERN,
7410
7477
  TOPIC_SCOPE_CODES,
7478
+ TRACKING_RESOURCE_TYPE,
7411
7479
  TimeFuncs,
7412
7480
  TokenNamingSystem,
7413
7481
  TopicInputScopeUrl,