@d4l/collect-lib 1.20.1 → 1.22.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
@@ -44,6 +44,7 @@ function toDeviceConfig(devices) {
44
44
  dataTypes: device.dataTypes
45
45
  };
46
46
  case "AppleHealth":
47
+ case "HealthConnect":
47
48
  return {
48
49
  type: "sdk",
49
50
  device: device.type,
@@ -101,7 +102,8 @@ var DEVICE_KEY_TO_NAME = {
101
102
  fullName: "Internal Beacon Sensing"
102
103
  },
103
104
  // Placeholder, there is no such device
104
- AppleHealth: { shortName: "Apple HealthKit", fullName: "Apple HealthKit" }
105
+ AppleHealth: { shortName: "Apple HealthKit", fullName: "Apple HealthKit" },
106
+ HealthConnect: { shortName: "Health Connect", fullName: "Android Health Connect" }
105
107
  };
106
108
 
107
109
  // src/devices/annotations/base.ts
@@ -801,6 +803,48 @@ var APPLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS = {
801
803
  sleepAnalysis: APPLE_HEALTH_SLEEP_ANALYSIS_ANNOTATION
802
804
  };
803
805
 
806
+ // src/devices/annotations/healthConnect.ts
807
+ var HEALTH_CONNECT_ANNOTATION_ITEM_STEPS = {
808
+ type: "steps",
809
+ size: 4,
810
+ format: "signedInt",
811
+ littleEndian: true
812
+ };
813
+ var HEALTH_CONNECT_STEPS_ANNOTATION = [
814
+ HEALTH_CONNECT_ANNOTATION_ITEM_STEPS
815
+ ];
816
+ var HEALTH_CONNECT_SLEEP_STAGE_MAP = {
817
+ unknown: 0,
818
+ awake: 1,
819
+ sleeping: 2,
820
+ awakeOutOfBed: 3,
821
+ sleepingLight: 4,
822
+ sleepingDeep: 5,
823
+ sleepingRem: 6,
824
+ awakeInBed: 7
825
+ };
826
+ var HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE = {
827
+ type: "sleepStage",
828
+ size: 1,
829
+ format: "unsignedInt",
830
+ littleEndian: true
831
+ };
832
+ var HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION = {
833
+ type: "duration",
834
+ size: 2,
835
+ format: "unsignedInt",
836
+ littleEndian: true,
837
+ unit: "s"
838
+ };
839
+ var HEALTH_CONNECT_SLEEP_ANNOTATION = [
840
+ HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE,
841
+ HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION
842
+ ];
843
+ var HEALTH_CONNECT_SIGNAL_TYPE_ANNOTATIONS = {
844
+ steps: HEALTH_CONNECT_STEPS_ANNOTATION,
845
+ sleep: HEALTH_CONNECT_SLEEP_ANNOTATION
846
+ };
847
+
804
848
  // src/types/recording.ts
805
849
  var RECORDING_MODEL_CURRENT_VERSION = "0.0.6";
806
850
 
@@ -4869,7 +4913,7 @@ var DonationSDK = class {
4869
4913
  let hasMore = true;
4870
4914
  while (hasMore) {
4871
4915
  const [response, _] = await authenticatedDonationAPI.get({
4872
- uri: `/responses/${programName}?limit=${limit}&offset=${offset}&updatedAfter=${updatedAfter}`
4916
+ uri: `/responses/${programName}?limit=${limit}&offset=${offset}&updatedAfter=${encodeURIComponent(updatedAfter)}`
4873
4917
  });
4874
4918
  limit = response.limit;
4875
4919
  responses = [...responses, ...response.responses];
@@ -4981,7 +5025,67 @@ var evaluateOperator = (value, operator, operand) => {
4981
5025
  return false;
4982
5026
  }
4983
5027
  };
4984
- var DateCondition = class {
5028
+ var AnswerCodeGuard = class {
5029
+ constructor(questionID, operator, operand, surveyName, offset) {
5030
+ this.offset = Duration.fromObject({});
5031
+ this.surveyName = surveyName;
5032
+ this.questionID = questionID;
5033
+ this.operand = operand;
5034
+ this.operator = operator;
5035
+ if (offset) {
5036
+ const parsedOffset = Duration.fromISO(offset);
5037
+ if (parsedOffset.isValid) {
5038
+ this.offset = parsedOffset;
5039
+ }
5040
+ }
5041
+ }
5042
+ evaluate(answers) {
5043
+ const { operand, questionID, operator } = this;
5044
+ if (!operand) {
5045
+ return false;
5046
+ }
5047
+ const answer = answers[questionID];
5048
+ if (!answer) {
5049
+ return false;
5050
+ }
5051
+ if (Array.isArray(answer)) {
5052
+ switch (operator) {
5053
+ case "exists":
5054
+ return !!answer.length;
5055
+ case "=":
5056
+ return answer.includes(operand);
5057
+ case "!=":
5058
+ return !answer.includes(operand);
5059
+ default:
5060
+ return false;
5061
+ }
5062
+ } else {
5063
+ switch (operator) {
5064
+ case "exists":
5065
+ return !!answer;
5066
+ case "=":
5067
+ return answer === operand;
5068
+ case "!=":
5069
+ return answer !== operand;
5070
+ default:
5071
+ return false;
5072
+ }
5073
+ }
5074
+ }
5075
+ getFulfillmentDate(params) {
5076
+ const { multiAnswers } = params;
5077
+ if (!this.surveyName || multiAnswers === void 0) {
5078
+ return null;
5079
+ }
5080
+ let fulfilled = this.evaluate(multiAnswers[this.surveyName].answers);
5081
+ if (!fulfilled) {
5082
+ return null;
5083
+ }
5084
+ const answerDate = DateTime4.fromJSDate(multiAnswers[this.surveyName].date).plus(this.offset);
5085
+ return answerDate.toJSDate();
5086
+ }
5087
+ };
5088
+ var AnswerDateGuard = class {
4985
5089
  constructor(questionID, operand, operator, surveyName, offset) {
4986
5090
  this.offset = Duration.fromObject({});
4987
5091
  this.surveyName = surveyName;
@@ -5010,8 +5114,9 @@ var DateCondition = class {
5010
5114
  }
5011
5115
  return evaluateOperator(has.getTime(), operator, operand.getTime());
5012
5116
  }
5013
- getFulfillmentDate(multiAnswers) {
5014
- if (this.surveyName) {
5117
+ getFulfillmentDate(params) {
5118
+ const { multiAnswers } = params;
5119
+ if (this.surveyName && multiAnswers !== void 0) {
5015
5120
  const answer = multiAnswers[this.surveyName].answers[this.questionID];
5016
5121
  if (answer && !Array.isArray(answer)) {
5017
5122
  const jsDate = new Date(answer);
@@ -5024,8 +5129,8 @@ var DateCondition = class {
5024
5129
  return null;
5025
5130
  }
5026
5131
  };
5027
- var newStepDateCondtion = (questionID, surveyName, offset) => new DateCondition(questionID, "irrelevant", "exists", surveyName, offset);
5028
- var YearCondition = class {
5132
+ var newStepDateGuard = (questionID, surveyName, offset) => new AnswerDateGuard(questionID, "irrelevant", "exists", surveyName, offset);
5133
+ var YearGuard = class {
5029
5134
  constructor(questionID, operand, operator) {
5030
5135
  this.questionID = questionID;
5031
5136
  this.operand = stringToYear(operand);
@@ -5046,70 +5151,11 @@ var YearCondition = class {
5046
5151
  }
5047
5152
  return evaluateOperator(has, operator, operand);
5048
5153
  }
5049
- getFulfillmentDate(_multiAnswers) {
5154
+ getFulfillmentDate(_params) {
5050
5155
  return null;
5051
5156
  }
5052
5157
  };
5053
- var AnswerCodeCondition = class {
5054
- constructor(questionID, operand, operator, surveyName, offset) {
5055
- this.offset = Duration.fromObject({});
5056
- this.surveyName = surveyName;
5057
- this.questionID = questionID;
5058
- this.operand = operand;
5059
- this.operator = operator;
5060
- if (offset) {
5061
- const parsedOffset = Duration.fromISO(offset);
5062
- if (parsedOffset.isValid) {
5063
- this.offset = parsedOffset;
5064
- }
5065
- }
5066
- }
5067
- evaluate(answers) {
5068
- const { operand, questionID, operator } = this;
5069
- if (!operand) {
5070
- return false;
5071
- }
5072
- const answer = answers[questionID];
5073
- if (!answer) {
5074
- return false;
5075
- }
5076
- if (Array.isArray(answer)) {
5077
- switch (operator) {
5078
- case "exists":
5079
- return !!answer.length;
5080
- case "=":
5081
- return answer.includes(operand);
5082
- case "!=":
5083
- return !answer.includes(operand);
5084
- default:
5085
- return false;
5086
- }
5087
- } else {
5088
- switch (operator) {
5089
- case "exists":
5090
- return !!answer;
5091
- case "=":
5092
- return answer === operand;
5093
- case "!=":
5094
- return answer !== operand;
5095
- default:
5096
- return false;
5097
- }
5098
- }
5099
- }
5100
- getFulfillmentDate(multiAnswers) {
5101
- if (!this.surveyName) {
5102
- return null;
5103
- }
5104
- let fulfilled = this.evaluate(multiAnswers[this.surveyName].answers);
5105
- if (!fulfilled) {
5106
- return null;
5107
- }
5108
- const answerDate = DateTime4.fromJSDate(multiAnswers[this.surveyName].date).plus(this.offset);
5109
- return answerDate.toJSDate();
5110
- }
5111
- };
5112
- var DecimalCondition = class {
5158
+ var DecimalGuard = class {
5113
5159
  constructor(questionID, operand, operator) {
5114
5160
  this.questionID = questionID;
5115
5161
  this.operand = operand;
@@ -5130,11 +5176,11 @@ var DecimalCondition = class {
5130
5176
  }
5131
5177
  return evaluateOperator(has, operator, operand);
5132
5178
  }
5133
- getFulfillmentDate(_multiAnswers) {
5179
+ getFulfillmentDate(_params) {
5134
5180
  return null;
5135
5181
  }
5136
5182
  };
5137
- var ExistsCondition = class {
5183
+ var ExistsGuard = class {
5138
5184
  constructor(questionID) {
5139
5185
  this.questionID = questionID;
5140
5186
  }
@@ -5142,18 +5188,18 @@ var ExistsCondition = class {
5142
5188
  const { questionID } = this;
5143
5189
  return !!answers[questionID];
5144
5190
  }
5145
- getFulfillmentDate(_multiAnswers) {
5191
+ getFulfillmentDate(_params) {
5146
5192
  return null;
5147
5193
  }
5148
5194
  };
5149
- var BoolCondition = class {
5195
+ var BoolGuard = class {
5150
5196
  constructor(condition) {
5151
5197
  this.condition = condition;
5152
5198
  }
5153
5199
  evaluate(_answers) {
5154
5200
  return this.condition;
5155
5201
  }
5156
- getFulfillmentDate(_multiAnswers) {
5202
+ getFulfillmentDate(_params) {
5157
5203
  return this.condition ? /* @__PURE__ */ new Date() : null;
5158
5204
  }
5159
5205
  };
@@ -5178,10 +5224,10 @@ var Conjunction = class {
5178
5224
  }
5179
5225
  return true;
5180
5226
  }
5181
- getFulfillmentDate(multiAnswers, consentTimes) {
5227
+ getFulfillmentDate(params) {
5182
5228
  let fulfillmentDates = [];
5183
5229
  for (const condition of this.conditions) {
5184
- const fulfillmentDate = condition.getFulfillmentDate(multiAnswers, consentTimes);
5230
+ const fulfillmentDate = condition.getFulfillmentDate(params);
5185
5231
  if (!fulfillmentDate) {
5186
5232
  return null;
5187
5233
  }
@@ -5207,10 +5253,10 @@ var Disjunction = class {
5207
5253
  }
5208
5254
  return false;
5209
5255
  }
5210
- getFulfillmentDate(multiAnswers, consentTimes) {
5256
+ getFulfillmentDate(params) {
5211
5257
  let fulfillmentDates = [];
5212
5258
  for (const condition of this.conditions) {
5213
- const fulfillmentDate = condition.getFulfillmentDate(multiAnswers, consentTimes);
5259
+ const fulfillmentDate = condition.getFulfillmentDate(params);
5214
5260
  if (fulfillmentDate) {
5215
5261
  fulfillmentDates.push(fulfillmentDate);
5216
5262
  }
@@ -5236,8 +5282,8 @@ var Offset = class {
5236
5282
  evaluate(answers) {
5237
5283
  return this.condition.evaluate(answers);
5238
5284
  }
5239
- getFulfillmentDate(multiAnswers, consentTimes) {
5240
- const fulfillmentDate = this.condition.getFulfillmentDate(multiAnswers, consentTimes);
5285
+ getFulfillmentDate(params) {
5286
+ const fulfillmentDate = this.condition.getFulfillmentDate(params);
5241
5287
  if (fulfillmentDate && !isNaN(fulfillmentDate == null ? void 0 : fulfillmentDate.getTime())) {
5242
5288
  const answerDate = DateTime4.fromJSDate(fulfillmentDate).plus(this.offset);
5243
5289
  return answerDate.toJSDate();
@@ -5245,7 +5291,7 @@ var Offset = class {
5245
5291
  return null;
5246
5292
  }
5247
5293
  };
5248
- var ConsentCondition = class {
5294
+ var ConsentGuard = class {
5249
5295
  constructor(consentKey, offset) {
5250
5296
  this.offset = Duration.fromObject({});
5251
5297
  this.consentKey = consentKey;
@@ -5257,14 +5303,15 @@ var ConsentCondition = class {
5257
5303
  evaluate(_answers) {
5258
5304
  return true;
5259
5305
  }
5260
- getFulfillmentDate(_multiAnswers, consentTimes) {
5306
+ getFulfillmentDate(params) {
5307
+ const { consentTimes } = params;
5261
5308
  if (!(consentTimes == null ? void 0 : consentTimes[this.consentKey])) {
5262
5309
  return null;
5263
5310
  }
5264
5311
  return DateTime4.fromJSDate(consentTimes[this.consentKey]).plus(this.offset).toJSDate();
5265
5312
  }
5266
5313
  };
5267
- var SurveyCondition = class {
5314
+ var SurveyGuard = class {
5268
5315
  constructor(surveyName, offset) {
5269
5316
  this.offset = Duration.fromObject({});
5270
5317
  this.surveyName = surveyName;
@@ -5278,7 +5325,11 @@ var SurveyCondition = class {
5278
5325
  evaluate(_answers) {
5279
5326
  return true;
5280
5327
  }
5281
- getFulfillmentDate(multiAnswers) {
5328
+ getFulfillmentDate(params) {
5329
+ const { multiAnswers } = params;
5330
+ if (!(multiAnswers == null ? void 0 : multiAnswers[this.surveyName])) {
5331
+ return null;
5332
+ }
5282
5333
  const date = multiAnswers[this.surveyName].date;
5283
5334
  if (!date) {
5284
5335
  return null;
@@ -5290,7 +5341,7 @@ var SurveyCondition = class {
5290
5341
  return answerDate.toJSDate();
5291
5342
  }
5292
5343
  };
5293
- var RoutineCondition = class {
5344
+ var RoutineGuard = class {
5294
5345
  constructor(routineName, offset) {
5295
5346
  this.offset = Duration.fromObject({});
5296
5347
  this.routineName = routineName;
@@ -5302,13 +5353,50 @@ var RoutineCondition = class {
5302
5353
  evaluate(_answers) {
5303
5354
  return true;
5304
5355
  }
5305
- getFulfillmentDate(_multiAnswers, _consentTimes, routineTimes) {
5356
+ getFulfillmentDate(params) {
5357
+ const { routineTimes } = params;
5306
5358
  if (!(routineTimes == null ? void 0 : routineTimes[this.routineName])) {
5307
5359
  return null;
5308
5360
  }
5309
5361
  return DateTime4.fromJSDate(routineTimes[this.routineName]).plus(this.offset).toJSDate();
5310
5362
  }
5311
5363
  };
5364
+ var ResponseGuard = class {
5365
+ constructor(responseName, offset) {
5366
+ this.offset = Duration.fromObject({});
5367
+ this.responseName = responseName;
5368
+ if (offset) {
5369
+ const parsedOffset = Duration.fromISO(offset);
5370
+ parsedOffset.isValid && (this.offset = parsedOffset);
5371
+ }
5372
+ }
5373
+ evaluate(_answers) {
5374
+ return true;
5375
+ }
5376
+ getFulfillmentDate(params) {
5377
+ const { responseTimes } = params;
5378
+ if (!(responseTimes == null ? void 0 : responseTimes[this.responseName])) {
5379
+ return null;
5380
+ }
5381
+ return DateTime4.fromJSDate(responseTimes[this.responseName]).plus(this.offset).toJSDate();
5382
+ }
5383
+ };
5384
+ var DateGuard = class {
5385
+ constructor(date, offset) {
5386
+ this.offset = Duration.fromObject({});
5387
+ this.date = new Date(date);
5388
+ if (offset) {
5389
+ const parsedOffset = Duration.fromISO(offset);
5390
+ parsedOffset.isValid && (this.offset = parsedOffset);
5391
+ }
5392
+ }
5393
+ evaluate(_answers) {
5394
+ return true;
5395
+ }
5396
+ getFulfillmentDate(_params) {
5397
+ return DateTime4.fromJSDate(this.date).plus(this.offset).toJSDate();
5398
+ }
5399
+ };
5312
5400
  var generateQuestionGuard = (enableWhen, enableBehavior) => {
5313
5401
  if (!enableWhen || !enableWhen.length || !enableBehavior) {
5314
5402
  return void 0;
@@ -5316,139 +5404,111 @@ var generateQuestionGuard = (enableWhen, enableBehavior) => {
5316
5404
  const guards = [];
5317
5405
  for (const condition of enableWhen) {
5318
5406
  if (condition.operator === "exists") {
5319
- guards.push(new ExistsCondition(condition.question));
5407
+ guards.push(new ExistsGuard(condition.question));
5320
5408
  } else if (condition.answerDate && condition.answerDate.length === 4) {
5321
- guards.push(new YearCondition(condition.question, condition.answerDate, condition.operator));
5409
+ guards.push(new YearGuard(condition.question, condition.answerDate, condition.operator));
5322
5410
  } else if (condition.answerDate) {
5323
- guards.push(new DateCondition(condition.question, condition.answerDate, condition.operator));
5411
+ guards.push(
5412
+ new AnswerDateGuard(condition.question, condition.answerDate, condition.operator)
5413
+ );
5324
5414
  } else if (condition.answerCoding) {
5325
5415
  guards.push(
5326
- new AnswerCodeCondition(
5327
- condition.question,
5328
- condition.answerCoding.code,
5329
- condition.operator
5330
- )
5416
+ new AnswerCodeGuard(condition.question, condition.operator, condition.answerCoding.code)
5331
5417
  );
5332
5418
  } else if (condition.answerDecimal) {
5333
5419
  guards.push(
5334
- new DecimalCondition(condition.question, condition.answerDecimal, condition.operator)
5420
+ new DecimalGuard(condition.question, condition.answerDecimal, condition.operator)
5335
5421
  );
5336
5422
  }
5337
5423
  }
5338
5424
  return enableBehavior === "all" ? new Conjunction(guards) : new Disjunction(guards);
5339
5425
  };
5340
5426
  var generateStepGuard = (cond) => {
5341
- const guards = [];
5342
- let surveyNames = [];
5343
- let routineNames = [];
5344
- let consentKeys = [];
5345
- if (cond.items) {
5346
- for (const condition of cond.items) {
5347
- const {
5348
- guard,
5349
- surveyNames: nestedIds,
5350
- routineNames: nestedRoutineNames,
5351
- consentKeys: nestedKeys
5352
- } = generateStepGuard(condition);
5353
- guards.push(guard);
5354
- surveyNames.push(...nestedIds);
5355
- routineNames.push(...nestedRoutineNames);
5356
- consentKeys.push(...nestedKeys);
5357
- }
5358
- surveyNames = [...new Set(surveyNames)];
5359
- routineNames = [...new Set(routineNames)];
5360
- consentKeys = [...new Set(consentKeys)];
5427
+ if (cond.type === "and" || cond.type === "or") {
5428
+ const guard = cond.type === "and" ? new Conjunction([], cond.sorting) : new Disjunction([], cond.sorting);
5429
+ return cond.items.reduce(
5430
+ (result, condition) => {
5431
+ const item = generateStepGuard(condition);
5432
+ guard.conditions.push(item.guard);
5433
+ return mergeContexts(result, item);
5434
+ },
5435
+ { guard }
5436
+ );
5361
5437
  }
5362
5438
  switch (cond.type) {
5363
5439
  case "question":
5364
5440
  switch (cond.questionType) {
5365
5441
  case "coding":
5366
5442
  return {
5367
- guard: new AnswerCodeCondition(
5443
+ guard: new AnswerCodeGuard(
5368
5444
  cond.linkID,
5369
- cond.operand,
5370
5445
  cond.operator,
5446
+ cond.operand,
5371
5447
  cond.surveyName,
5372
5448
  cond.offset
5373
5449
  ),
5374
- surveyNames: [cond.surveyName],
5375
- routineNames: [],
5376
- consentKeys: []
5450
+ surveyNames: [cond.surveyName]
5377
5451
  };
5378
5452
  case "date":
5379
5453
  return {
5380
- guard: newStepDateCondtion(cond.linkID, cond.surveyName, cond.offset),
5381
- surveyNames: [cond.surveyName],
5382
- routineNames: [],
5383
- consentKeys: []
5454
+ guard: newStepDateGuard(cond.linkID, cond.surveyName, cond.offset),
5455
+ surveyNames: [cond.surveyName]
5384
5456
  };
5385
5457
  default:
5386
- console.warn(`[Step Guard Generation] Unknown question type: "${cond.questionType}"`);
5458
+ console.warn(`[Step Guard Generation] Unknown question condition: "${cond}"`);
5387
5459
  return {
5388
- guard: new BoolCondition(false),
5389
- surveyNames: [cond.surveyName],
5390
- routineNames: [],
5391
- consentKeys: []
5460
+ guard: new BoolGuard(false)
5392
5461
  };
5393
5462
  }
5394
- case "and":
5395
- return {
5396
- guard: new Conjunction(guards, cond.sorting),
5397
- surveyNames,
5398
- routineNames,
5399
- consentKeys
5400
- };
5401
- case "or":
5463
+ case "offset":
5464
+ const { guard, surveyNames, routineNames, consentKeys, responseNames } = generateStepGuard(
5465
+ cond.item
5466
+ );
5402
5467
  return {
5403
- guard: new Disjunction(guards, cond.sorting),
5468
+ guard: new Offset(guard, cond.offset),
5404
5469
  surveyNames,
5405
5470
  routineNames,
5406
- consentKeys
5407
- };
5408
- case "offset":
5409
- const {
5410
- guard: offsetGuard,
5411
- surveyNames: offsetSurveyNames,
5412
- routineNames: offsetRoutineNames,
5413
- consentKeys: offsetConsentKeys
5414
- } = generateStepGuard(cond.item);
5415
- return {
5416
- guard: new Offset(offsetGuard, cond.offset),
5417
- surveyNames: [...offsetSurveyNames],
5418
- routineNames: [...offsetRoutineNames],
5419
- consentKeys: [...offsetConsentKeys]
5471
+ consentKeys,
5472
+ responseNames
5420
5473
  };
5421
5474
  case "consent":
5422
5475
  return {
5423
- guard: new ConsentCondition(cond.consentKey, cond.offset),
5424
- surveyNames: [],
5425
- routineNames: [],
5476
+ guard: new ConsentGuard(cond.consentKey, cond.offset),
5426
5477
  consentKeys: [cond.consentKey]
5427
5478
  };
5428
5479
  case "survey":
5429
5480
  return {
5430
- guard: new SurveyCondition(cond.surveyName, cond.offset),
5431
- surveyNames: [cond.surveyName],
5432
- routineNames: [],
5433
- consentKeys: []
5481
+ guard: new SurveyGuard(cond.surveyName, cond.offset),
5482
+ surveyNames: [cond.surveyName]
5434
5483
  };
5435
5484
  case "routine":
5436
5485
  return {
5437
- guard: new RoutineCondition(cond.routineName, cond.offset),
5438
- surveyNames: [],
5439
- routineNames: [cond.routineName],
5440
- consentKeys: []
5486
+ guard: new RoutineGuard(cond.routineName, cond.offset),
5487
+ routineNames: [cond.routineName]
5441
5488
  };
5489
+ case "response":
5490
+ return {
5491
+ guard: new ResponseGuard(cond.responseName, cond.offset),
5492
+ responseNames: [cond.responseName]
5493
+ };
5494
+ case "date":
5495
+ return { guard: new DateGuard(cond.date) };
5442
5496
  default:
5443
- console.warn(`[Step Guard Generation] Unknown condition type: "${cond.type}"`);
5497
+ console.warn(`[Step Guard Generation] Unknown condition: "${cond}"`);
5444
5498
  return {
5445
- guard: new BoolCondition(false),
5446
- surveyNames: [],
5447
- routineNames: [],
5448
- consentKeys: []
5499
+ guard: new BoolGuard(false)
5449
5500
  };
5450
5501
  }
5451
5502
  };
5503
+ function mergeContexts(a, b) {
5504
+ return {
5505
+ guard: a.guard,
5506
+ surveyNames: [.../* @__PURE__ */ new Set([...a.surveyNames || [], ...b.surveyNames || []])],
5507
+ routineNames: [.../* @__PURE__ */ new Set([...a.routineNames || [], ...b.routineNames || []])],
5508
+ consentKeys: [.../* @__PURE__ */ new Set([...a.consentKeys || [], ...b.consentKeys || []])],
5509
+ responseNames: [.../* @__PURE__ */ new Set([...a.responseNames || [], ...b.responseNames || []])]
5510
+ };
5511
+ }
5452
5512
 
5453
5513
  // src/helper/ulid/index.ts
5454
5514
  import { Buffer as Buffer11 } from "buffer/";
@@ -5571,7 +5631,8 @@ export {
5571
5631
  APPLE_HEALTH_WALKING_RUNNING_DISTANCE_ANNOTATION,
5572
5632
  ASMSECGMeasurementAnnotation,
5573
5633
  ASMSSpO2MeasurementAnnotation,
5574
- AnswerCodeCondition,
5634
+ AnswerCodeGuard,
5635
+ AnswerDateGuard,
5575
5636
  AppIDNamingSystem,
5576
5637
  BLE_ASMS_ANNOTATION_ITEM_ECG,
5577
5638
  BLE_ASMS_ANNOTATION_ITEM_SPO2,
@@ -5614,12 +5675,12 @@ export {
5614
5675
  BLE_PSMS_ANNOTATION_ITEM_PPG_IR,
5615
5676
  BLE_PSMS_ANNOTATION_ITEM_PPG_RED,
5616
5677
  BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE,
5617
- BoolCondition,
5678
+ BoolGuard,
5618
5679
  CPMSHealthServicesActivityDetectionAnnotation,
5619
5680
  CPMSHealthServicesPassiveDataAnnotation,
5620
5681
  CommunicationTypeSystem,
5621
5682
  Conjunction,
5622
- ConsentCondition,
5683
+ ConsentGuard,
5623
5684
  ConsentNameSystem,
5624
5685
  ConsentVersionSystem,
5625
5686
  CustomExtensionDate,
@@ -5646,12 +5707,12 @@ export {
5646
5707
  DEVICE_LABEL_CODING,
5647
5708
  DEVICE_OUTPUT_RATE_CODING,
5648
5709
  DEVICE_SENSOR_DELAY_CODING,
5649
- DateCondition,
5650
- DecimalCondition,
5710
+ DateGuard,
5711
+ DecimalGuard,
5651
5712
  Disjunction,
5652
5713
  DonationSDK,
5653
5714
  ERROR_CODES,
5654
- ExistsCondition,
5715
+ ExistsGuard,
5655
5716
  FITBIT_ANNOTATION_ITEM_BREATHING_RATE,
5656
5717
  FITBIT_ANNOTATION_ITEM_CALORIES,
5657
5718
  FITBIT_ANNOTATION_ITEM_HEART_RATE,
@@ -5671,6 +5732,13 @@ export {
5671
5732
  FITBIT_SLEEP_LEVEL_MAP,
5672
5733
  FITBIT_SPO2_ANNOTATION,
5673
5734
  FITBIT_STEPS_ANNOTATION,
5735
+ HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION,
5736
+ HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE,
5737
+ HEALTH_CONNECT_ANNOTATION_ITEM_STEPS,
5738
+ HEALTH_CONNECT_SIGNAL_TYPE_ANNOTATIONS,
5739
+ HEALTH_CONNECT_SLEEP_ANNOTATION,
5740
+ HEALTH_CONNECT_SLEEP_STAGE_MAP,
5741
+ HEALTH_CONNECT_STEPS_ANNOTATION,
5674
5742
  IMUAnnotation,
5675
5743
  InternalSensorAnnotationTypes,
5676
5744
  KeyHandler,
@@ -5694,7 +5762,8 @@ export {
5694
5762
  RECORDING_SIGNAL_MODEL_CURRENT_VERSION,
5695
5763
  RelativeMaxValueExtension,
5696
5764
  RelativeMinValueExtension,
5697
- RoutineCondition,
5765
+ ResponseGuard,
5766
+ RoutineGuard,
5698
5767
  RoutineIsPassiveExtension,
5699
5768
  SIGNAL_DURATION_CODING,
5700
5769
  SensorIdentifierSystem,
@@ -5705,7 +5774,7 @@ export {
5705
5774
  SliderMinLabelExtension,
5706
5775
  SliderStepSizeExtension,
5707
5776
  StudyNameSystem,
5708
- SurveyCondition,
5777
+ SurveyGuard,
5709
5778
  TimeFuncs,
5710
5779
  TokenNamingSystem,
5711
5780
  ULID_REGEX,
@@ -5715,7 +5784,7 @@ export {
5715
5784
  WORDLIST_LANGUAGES,
5716
5785
  WearOS3AnnotationMap,
5717
5786
  WebConverter,
5718
- YearCondition,
5787
+ YearGuard,
5719
5788
  binaryStringToUint8Array,
5720
5789
  calculateQuestionnaireScoreRange,
5721
5790
  calculateScoreRangeForItem,
@@ -5744,7 +5813,7 @@ export {
5744
5813
  isNotBeforeStartDate,
5745
5814
  isScoreEligible,
5746
5815
  isYearString,
5747
- newStepDateCondtion,
5816
+ newStepDateGuard,
5748
5817
  overwriteTime,
5749
5818
  stringToDate,
5750
5819
  stringToYear,