@tellescope/sdk 1.80.4 → 1.82.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.
@@ -6270,9 +6270,10 @@ var nextReminderInMS_tests = function () { return __awaiter(void 0, void 0, void
6270
6270
  }
6271
6271
  });
6272
6272
  }); };
6273
- var pollForResults = function (f, evaluate, intervalInMS, iterations) {
6273
+ var pollForResults = function (f, evaluate, intervalInMS, iterations, shouldError) {
6274
6274
  if (intervalInMS === void 0) { intervalInMS = 500; }
6275
6275
  if (iterations === void 0) { iterations = 20; }
6276
+ if (shouldError === void 0) { shouldError = false; }
6276
6277
  return __awaiter(void 0, void 0, void 0, function () {
6277
6278
  var lastResult, i, result;
6278
6279
  return __generator(this, function (_a) {
@@ -6297,6 +6298,8 @@ var pollForResults = function (f, evaluate, intervalInMS, iterations) {
6297
6298
  i++;
6298
6299
  return [3 /*break*/, 1];
6299
6300
  case 5:
6301
+ if (shouldError)
6302
+ return [2 /*return*/, lastResult];
6300
6303
  console.log(lastResult);
6301
6304
  throw new Error("failed pollForResults");
6302
6305
  }
@@ -8007,7 +8010,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8007
8010
  _a.sent();
8008
8011
  return [4 /*yield*/, async_test("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8009
8012
  var results = _a.results;
8010
- return results.length === 0;
8013
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8011
8014
  } })];
8012
8015
  case 8:
8013
8016
  _a.sent();
@@ -8040,7 +8043,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8040
8043
  _a.sent();
8041
8044
  return [4 /*yield*/, async_test("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8042
8045
  var results = _a.results;
8043
- return results.length === 0;
8046
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8044
8047
  } })];
8045
8048
  case 14:
8046
8049
  _a.sent();
@@ -8146,7 +8149,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8146
8149
  _a.sent();
8147
8150
  return [4 /*yield*/, async_test("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8148
8151
  var results = _a.results;
8149
- return results.length === 0;
8152
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8150
8153
  } })
8151
8154
  // bulk create test coverage
8152
8155
  ];
@@ -8183,7 +8186,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8183
8186
  _a.sent();
8184
8187
  return [4 /*yield*/, async_test("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8185
8188
  var results = _a.results;
8186
- return results.length === 0;
8189
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8187
8190
  } })];
8188
8191
  case 41:
8189
8192
  _a.sent();
@@ -8216,7 +8219,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8216
8219
  _a.sent();
8217
8220
  return [4 /*yield*/, async_test("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8218
8221
  var results = _a.results;
8219
- return results.length === 0;
8222
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8220
8223
  } })];
8221
8224
  case 47:
8222
8225
  _a.sent();
@@ -8288,6 +8291,523 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8288
8291
  }
8289
8292
  });
8290
8293
  }); };
8294
+ var vital_trigger_tests = function () { return __awaiter(void 0, void 0, void 0, function () {
8295
+ var runTriggerTest, timestamp_for_day_offset;
8296
+ return __generator(this, function (_a) {
8297
+ switch (_a.label) {
8298
+ case 0:
8299
+ log_header("Vital Update Trigger");
8300
+ runTriggerTest = function (_a) {
8301
+ var _configurations = _a.configurations, _triggers = _a.triggers, shouldTrigger = _a.shouldTrigger, vitals = _a.vitals, title = _a.title;
8302
+ return __awaiter(void 0, void 0, void 0, function () {
8303
+ var e, configurations, triggers;
8304
+ return __generator(this, function (_b) {
8305
+ switch (_b.label) {
8306
+ case 0: return [4 /*yield*/, sdk.api.endusers.createOne({})];
8307
+ case 1:
8308
+ e = _b.sent();
8309
+ return [4 /*yield*/, sdk.api.vital_configurations.createSome(_configurations.map(function (c, i) { return (__assign({ title: "configuration ".concat(i) }, c)); }))];
8310
+ case 2:
8311
+ configurations = (_b.sent()).created;
8312
+ return [4 /*yield*/, sdk.api.automation_triggers.createSome(_triggers.map(function (t, i) { return ({
8313
+ title: "trigger ".concat(i),
8314
+ status: 'Active',
8315
+ event: {
8316
+ type: "Vital Update",
8317
+ info: {
8318
+ classifications: t.classifications,
8319
+ configurationIds: configurations.filter(function (_, i) { return t.configurationIndexes.includes(i); }).map(function (c) { return c.id; }),
8320
+ }
8321
+ },
8322
+ action: {
8323
+ type: 'Add Tags',
8324
+ info: { tags: ['Triggered'] },
8325
+ },
8326
+ }); }))];
8327
+ case 3:
8328
+ triggers = (_b.sent()).created;
8329
+ return [4 /*yield*/, sdk.api.enduser_observations.createSome(vitals.map(function (v) { return (__assign(__assign({}, v), { category: 'vital-signs', enduserId: e.id, status: 'registered' })); }))];
8330
+ case 4:
8331
+ _b.sent();
8332
+ return [4 /*yield*/, async_test(title, function () { return pollForResults(function () { return sdk.api.endusers.getOne(e.id); }, function (e) { var _a; return !!((_a = e.tags) === null || _a === void 0 ? void 0 : _a.includes("Triggered")); }, 50, 10, !shouldTrigger); }, passOnAnyResult)];
8333
+ case 5:
8334
+ _b.sent();
8335
+ return [4 /*yield*/, Promise.all(__spreadArray(__spreadArray([
8336
+ sdk.api.endusers.deleteOne(e.id)
8337
+ ], configurations.map(function (c) { return sdk.api.vital_configurations.deleteOne(c.id); }), true), triggers.map(function (t) { return sdk.api.automation_triggers.deleteOne(t.id); }), true))];
8338
+ case 6:
8339
+ _b.sent();
8340
+ return [2 /*return*/];
8341
+ }
8342
+ });
8343
+ });
8344
+ };
8345
+ timestamp_for_day_offset = function (day) { return new Date(Date.now() - 1000 * 60 * 60 * 24 * day); };
8346
+ return [4 /*yield*/, runTriggerTest({
8347
+ title: "Basic Passing Test (Less Than Sucess)",
8348
+ shouldTrigger: true,
8349
+ configurations: [{
8350
+ unit: 'LB',
8351
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 0 },],
8352
+ }],
8353
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8354
+ vitals: [{
8355
+ measurement: { unit: 'LB', value: 1 },
8356
+ timestamp: new Date(),
8357
+ }]
8358
+ })];
8359
+ case 1:
8360
+ _a.sent();
8361
+ return [4 /*yield*/, runTriggerTest({
8362
+ title: "Less Than Fail",
8363
+ shouldTrigger: false,
8364
+ configurations: [{
8365
+ unit: 'LB',
8366
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 0 },],
8367
+ }],
8368
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8369
+ vitals: [{
8370
+ measurement: { unit: 'LB', value: 1 },
8371
+ timestamp: new Date(),
8372
+ }]
8373
+ })];
8374
+ case 2:
8375
+ _a.sent();
8376
+ return [4 /*yield*/, runTriggerTest({
8377
+ title: "Greater Than Success",
8378
+ shouldTrigger: true,
8379
+ configurations: [{
8380
+ unit: 'LB',
8381
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 0 }, trendIntervalInMS: 0 },],
8382
+ }],
8383
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8384
+ vitals: [{
8385
+ measurement: { unit: 'LB', value: 1 },
8386
+ timestamp: new Date(),
8387
+ }]
8388
+ })];
8389
+ case 3:
8390
+ _a.sent();
8391
+ return [4 /*yield*/, runTriggerTest({
8392
+ title: "Greater Than Fail",
8393
+ shouldTrigger: false,
8394
+ configurations: [{
8395
+ unit: 'LB',
8396
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 0 }, trendIntervalInMS: 0 },],
8397
+ }],
8398
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8399
+ vitals: [{
8400
+ measurement: { unit: 'LB', value: 0 },
8401
+ timestamp: new Date(),
8402
+ }]
8403
+ })];
8404
+ case 4:
8405
+ _a.sent();
8406
+ return [4 /*yield*/, runTriggerTest({
8407
+ title: "Between Low Bound",
8408
+ shouldTrigger: true,
8409
+ configurations: [{
8410
+ unit: 'LB',
8411
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8412
+ }],
8413
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8414
+ vitals: [{
8415
+ measurement: { unit: 'LB', value: 0 },
8416
+ timestamp: new Date(),
8417
+ }]
8418
+ })];
8419
+ case 5:
8420
+ _a.sent();
8421
+ return [4 /*yield*/, runTriggerTest({
8422
+ title: "Between Upper Bound",
8423
+ shouldTrigger: true,
8424
+ configurations: [{
8425
+ unit: 'LB',
8426
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8427
+ }],
8428
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8429
+ vitals: [{
8430
+ measurement: { unit: 'LB', value: 1 },
8431
+ timestamp: new Date(),
8432
+ }]
8433
+ })];
8434
+ case 6:
8435
+ _a.sent();
8436
+ return [4 /*yield*/, runTriggerTest({
8437
+ title: "Between Middle",
8438
+ shouldTrigger: true,
8439
+ configurations: [{
8440
+ unit: 'LB',
8441
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 2 } }, trendIntervalInMS: 0 },],
8442
+ }],
8443
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8444
+ vitals: [{
8445
+ measurement: { unit: 'LB', value: 1 },
8446
+ timestamp: new Date(),
8447
+ }]
8448
+ })];
8449
+ case 7:
8450
+ _a.sent();
8451
+ return [4 /*yield*/, runTriggerTest({
8452
+ title: "Between Below Low Bound",
8453
+ shouldTrigger: false,
8454
+ configurations: [{
8455
+ unit: 'LB',
8456
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8457
+ }],
8458
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8459
+ vitals: [{
8460
+ measurement: { unit: 'LB', value: -1 },
8461
+ timestamp: new Date(),
8462
+ }]
8463
+ })];
8464
+ case 8:
8465
+ _a.sent();
8466
+ return [4 /*yield*/, runTriggerTest({
8467
+ title: "Between Above Upper Bound",
8468
+ shouldTrigger: false,
8469
+ configurations: [{
8470
+ unit: 'LB',
8471
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8472
+ }],
8473
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8474
+ vitals: [{
8475
+ measurement: { unit: 'LB', value: 2 },
8476
+ timestamp: new Date(),
8477
+ }]
8478
+ })];
8479
+ case 9:
8480
+ _a.sent();
8481
+ return [4 /*yield*/, runTriggerTest({
8482
+ title: "Mismatch Unit",
8483
+ shouldTrigger: false,
8484
+ configurations: [{
8485
+ unit: 'DIFFERENT',
8486
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8487
+ }],
8488
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8489
+ vitals: [{
8490
+ measurement: { unit: 'LB', value: 1 },
8491
+ timestamp: new Date(),
8492
+ }]
8493
+ })];
8494
+ case 10:
8495
+ _a.sent();
8496
+ return [4 /*yield*/, runTriggerTest({
8497
+ title: "Mismatch Classification",
8498
+ shouldTrigger: false,
8499
+ configurations: [{
8500
+ unit: 'LB',
8501
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8502
+ }],
8503
+ triggers: [{ classifications: ['High'], configurationIndexes: [0] }],
8504
+ vitals: [{
8505
+ measurement: { unit: 'LB', value: 1 },
8506
+ timestamp: new Date(),
8507
+ }]
8508
+ })];
8509
+ case 11:
8510
+ _a.sent();
8511
+ return [4 /*yield*/, runTriggerTest({
8512
+ title: "Multiple Configurations (Classifications)",
8513
+ shouldTrigger: true,
8514
+ configurations: [{
8515
+ unit: 'LB',
8516
+ ranges: [
8517
+ { classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },
8518
+ { classification: 'High', comparison: { type: 'Less Than', value: 100 }, trendIntervalInMS: 0 },
8519
+ ],
8520
+ }],
8521
+ triggers: [{ classifications: ['High'], configurationIndexes: [0, 1] }],
8522
+ vitals: [{
8523
+ measurement: { unit: 'LB', value: 1 },
8524
+ timestamp: new Date(),
8525
+ }]
8526
+ })];
8527
+ case 12:
8528
+ _a.sent();
8529
+ return [4 /*yield*/, runTriggerTest({
8530
+ title: "Multiple Configurations (Comparisons)",
8531
+ shouldTrigger: true,
8532
+ configurations: [{
8533
+ unit: 'LB',
8534
+ ranges: [
8535
+ { classification: 'Target', comparison: { type: 'Less Than', value: 0 }, trendIntervalInMS: 0 },
8536
+ { classification: 'High', comparison: { type: 'Less Than', value: 100 }, trendIntervalInMS: 0 },
8537
+ ],
8538
+ }],
8539
+ triggers: [{ classifications: ['High'], configurationIndexes: [0, 1] }],
8540
+ vitals: [{
8541
+ measurement: { unit: 'LB', value: 1 },
8542
+ timestamp: new Date(),
8543
+ }]
8544
+ })];
8545
+ case 13:
8546
+ _a.sent();
8547
+ return [4 /*yield*/, runTriggerTest({
8548
+ title: "Multiple vitals, 0 passes",
8549
+ shouldTrigger: false,
8550
+ configurations: [{
8551
+ unit: 'LB',
8552
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8553
+ }],
8554
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8555
+ vitals: [
8556
+ { measurement: { unit: 'LB', value: 500 }, timestamp: new Date() },
8557
+ { measurement: { unit: 'LB', value: 1000 }, timestamp: new Date(Date.now() - 100) },
8558
+ { measurement: { unit: 'LB', value: 250 }, timestamp: new Date(Date.now() - 250) },
8559
+ ]
8560
+ })];
8561
+ case 14:
8562
+ _a.sent();
8563
+ return [4 /*yield*/, runTriggerTest({
8564
+ title: "Multiple vitals, 1 passes",
8565
+ shouldTrigger: true,
8566
+ configurations: [{
8567
+ unit: 'LB',
8568
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8569
+ }],
8570
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8571
+ vitals: [
8572
+ { measurement: { unit: 'LB', value: 500 }, timestamp: new Date() },
8573
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(Date.now() - 100) },
8574
+ { measurement: { unit: 'LB', value: 250 }, timestamp: new Date(Date.now() - 250) },
8575
+ ]
8576
+ })];
8577
+ case 15:
8578
+ _a.sent();
8579
+ return [4 /*yield*/, runTriggerTest({
8580
+ title: "Multiple vitals, multiple pass",
8581
+ shouldTrigger: true,
8582
+ configurations: [{
8583
+ unit: 'LB',
8584
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8585
+ }],
8586
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8587
+ vitals: [
8588
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8589
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(Date.now() - 100) },
8590
+ { measurement: { unit: 'LB', value: 3 }, timestamp: new Date(Date.now() - 250) },
8591
+ ]
8592
+ })
8593
+ // trend tests
8594
+ ];
8595
+ case 16:
8596
+ _a.sent();
8597
+ // trend tests
8598
+ return [4 /*yield*/, runTriggerTest({
8599
+ title: "Singleton trend should not work",
8600
+ shouldTrigger: false,
8601
+ configurations: [{
8602
+ unit: 'LB',
8603
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 1000 },],
8604
+ }],
8605
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8606
+ vitals: [{
8607
+ measurement: { unit: 'LB', value: 1 },
8608
+ timestamp: new Date(),
8609
+ }]
8610
+ })];
8611
+ case 17:
8612
+ // trend tests
8613
+ _a.sent();
8614
+ return [4 /*yield*/, runTriggerTest({
8615
+ title: "2-point trend passing",
8616
+ shouldTrigger: true,
8617
+ configurations: [{
8618
+ unit: 'LB',
8619
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 1000 },],
8620
+ }],
8621
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8622
+ vitals: [
8623
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8624
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 999) },
8625
+ ]
8626
+ })];
8627
+ case 18:
8628
+ _a.sent();
8629
+ return [4 /*yield*/, runTriggerTest({
8630
+ title: "2-point trend failing for difference too small",
8631
+ shouldTrigger: true,
8632
+ configurations: [{
8633
+ unit: 'LB',
8634
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 1000 },],
8635
+ }],
8636
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8637
+ vitals: [
8638
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8639
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 999) },
8640
+ ]
8641
+ })];
8642
+ case 19:
8643
+ _a.sent();
8644
+ return [4 /*yield*/, runTriggerTest({
8645
+ title: "2-point trend failing for point out of time range",
8646
+ shouldTrigger: false,
8647
+ configurations: [{
8648
+ unit: 'LB',
8649
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 5 }, trendIntervalInMS: 1000 },],
8650
+ }],
8651
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8652
+ vitals: [
8653
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8654
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 1001) },
8655
+ ]
8656
+ })];
8657
+ case 20:
8658
+ _a.sent();
8659
+ return [4 /*yield*/, runTriggerTest({
8660
+ title: "3-point trend passing (1 point of out range)",
8661
+ shouldTrigger: true,
8662
+ configurations: [{
8663
+ unit: 'LB',
8664
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8665
+ }],
8666
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8667
+ vitals: [
8668
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8669
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 100) },
8670
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 1001) },
8671
+ ]
8672
+ })];
8673
+ case 21:
8674
+ _a.sent();
8675
+ return [4 /*yield*/, runTriggerTest({
8676
+ title: "3-point trend passing (1 point wrong unit)",
8677
+ shouldTrigger: true,
8678
+ configurations: [{
8679
+ unit: 'LB',
8680
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8681
+ }],
8682
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8683
+ vitals: [
8684
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8685
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 100) },
8686
+ { measurement: { unit: 'OTHER', value: 0 }, timestamp: new Date(new Date().getTime() - 200) },
8687
+ ]
8688
+ })];
8689
+ case 22:
8690
+ _a.sent();
8691
+ return [4 /*yield*/, runTriggerTest({
8692
+ title: "3-point trend failing (1 point of out range)",
8693
+ shouldTrigger: false,
8694
+ configurations: [{
8695
+ unit: 'LB',
8696
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8697
+ }],
8698
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8699
+ vitals: [
8700
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8701
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 100) },
8702
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 1001) },
8703
+ ]
8704
+ })];
8705
+ case 23:
8706
+ _a.sent();
8707
+ return [4 /*yield*/, runTriggerTest({
8708
+ title: "3-point trend failing (1 point wrong unit)",
8709
+ shouldTrigger: false,
8710
+ configurations: [{
8711
+ unit: 'LB',
8712
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8713
+ }],
8714
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8715
+ vitals: [
8716
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8717
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 100) },
8718
+ { measurement: { unit: 'OTHER', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
8719
+ ]
8720
+ })];
8721
+ case 24:
8722
+ _a.sent();
8723
+ return [4 /*yield*/, runTriggerTest({
8724
+ title: "multiple trend passing",
8725
+ shouldTrigger: true,
8726
+ configurations: [{
8727
+ unit: 'LB',
8728
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8729
+ }],
8730
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8731
+ vitals: [
8732
+ { measurement: { unit: 'LB', value: 3 }, timestamp: new Date() },
8733
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8734
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
8735
+ ]
8736
+ })];
8737
+ case 25:
8738
+ _a.sent();
8739
+ return [4 /*yield*/, runTriggerTest({
8740
+ title: "multiple trend failing (not enough)",
8741
+ shouldTrigger: false,
8742
+ configurations: [{
8743
+ unit: 'LB',
8744
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8745
+ }],
8746
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8747
+ vitals: [
8748
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8749
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8750
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
8751
+ ]
8752
+ })];
8753
+ case 26:
8754
+ _a.sent();
8755
+ return [4 /*yield*/, runTriggerTest({
8756
+ title: "multiple trend failing (wrong order)",
8757
+ shouldTrigger: false,
8758
+ configurations: [{
8759
+ unit: 'LB',
8760
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8761
+ }],
8762
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8763
+ vitals: [
8764
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8765
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8766
+ { measurement: { unit: 'LB', value: 3 }, timestamp: new Date(new Date().getTime() - 200) },
8767
+ ]
8768
+ })];
8769
+ case 27:
8770
+ _a.sent();
8771
+ return [4 /*yield*/, runTriggerTest({
8772
+ title: "multiple trend failing (not enough, and wrong order)",
8773
+ shouldTrigger: false,
8774
+ configurations: [{
8775
+ unit: 'LB',
8776
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8777
+ }],
8778
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8779
+ vitals: [
8780
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8781
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8782
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 200) },
8783
+ ]
8784
+ })];
8785
+ case 28:
8786
+ _a.sent();
8787
+ return [4 /*yield*/, runTriggerTest({
8788
+ title: "multiple trend failing (lots)",
8789
+ shouldTrigger: false,
8790
+ configurations: [{
8791
+ unit: 'LB',
8792
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8793
+ }],
8794
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8795
+ vitals: [
8796
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8797
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8798
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 200) },
8799
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 300) },
8800
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 400) },
8801
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 500) },
8802
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 600) },
8803
+ ]
8804
+ })];
8805
+ case 29:
8806
+ _a.sent();
8807
+ return [2 /*return*/];
8808
+ }
8809
+ });
8810
+ }); };
8291
8811
  (function () { return __awaiter(void 0, void 0, void 0, function () {
8292
8812
  var err_1, n, _a, _b, _c, _i, returnValidation, t, _d, _f, _g, _h, err_2;
8293
8813
  var _j, _k;
@@ -8300,7 +8820,7 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8300
8820
  _l.sent();
8301
8821
  _l.label = 2;
8302
8822
  case 2:
8303
- _l.trys.push([2, 51, , 52]);
8823
+ _l.trys.push([2, 52, , 53]);
8304
8824
  form_conditional_logic_tests();
8305
8825
  return [4 /*yield*/, test_weighted_round_robin()];
8306
8826
  case 3:
@@ -8345,126 +8865,129 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8345
8865
  return [4 /*yield*/, sync_tests()]; // should come directly after setup to avoid extra sync values
8346
8866
  case 12:
8347
8867
  _l.sent(); // should come directly after setup to avoid extra sync values
8348
- return [4 /*yield*/, ticket_queue_tests()];
8868
+ return [4 /*yield*/, vital_trigger_tests()];
8349
8869
  case 13:
8350
8870
  _l.sent();
8351
- return [4 /*yield*/, close_reasons_no_duplicates_tests()];
8871
+ return [4 /*yield*/, ticket_queue_tests()];
8352
8872
  case 14:
8353
8873
  _l.sent();
8354
- return [4 /*yield*/, register_as_enduser_tests()];
8874
+ return [4 /*yield*/, close_reasons_no_duplicates_tests()];
8355
8875
  case 15:
8356
8876
  _l.sent();
8357
- return [4 /*yield*/, lockout_tests()];
8877
+ return [4 /*yield*/, register_as_enduser_tests()];
8358
8878
  case 16:
8359
8879
  _l.sent();
8360
- return [4 /*yield*/, self_serve_appointment_booking_tests()];
8880
+ return [4 /*yield*/, lockout_tests()];
8361
8881
  case 17:
8882
+ _l.sent();
8883
+ return [4 /*yield*/, self_serve_appointment_booking_tests()];
8884
+ case 18:
8362
8885
  _l.sent();
8363
8886
  return [4 /*yield*/, delete_user_tests()
8364
8887
  // await test_send_with_template()
8365
8888
  ];
8366
- case 18:
8889
+ case 19:
8367
8890
  _l.sent();
8368
8891
  // await test_send_with_template()
8369
8892
  return [4 /*yield*/, bulk_read_tests()];
8370
- case 19:
8893
+ case 20:
8371
8894
  // await test_send_with_template()
8372
8895
  _l.sent();
8373
8896
  return [4 /*yield*/, ticket_reminder_tests()];
8374
- case 20:
8375
- _l.sent();
8376
- return [4 /*yield*/, enduser_access_tags_tests()];
8377
8897
  case 21:
8378
8898
  _l.sent();
8379
- return [4 /*yield*/, marketing_email_unsubscribe_tests()];
8899
+ return [4 /*yield*/, enduser_access_tags_tests()];
8380
8900
  case 22:
8381
8901
  _l.sent();
8382
- return [4 /*yield*/, unique_strings_tests()];
8902
+ return [4 /*yield*/, marketing_email_unsubscribe_tests()];
8383
8903
  case 23:
8384
8904
  _l.sent();
8385
- return [4 /*yield*/, alternate_phones_tests()];
8905
+ return [4 /*yield*/, unique_strings_tests()];
8386
8906
  case 24:
8387
8907
  _l.sent();
8388
- return [4 /*yield*/, no_chained_triggers_tests()];
8908
+ return [4 /*yield*/, alternate_phones_tests()];
8389
8909
  case 25:
8390
8910
  _l.sent();
8391
- return [4 /*yield*/, field_equals_trigger_tests()];
8911
+ return [4 /*yield*/, no_chained_triggers_tests()];
8392
8912
  case 26:
8393
8913
  _l.sent();
8394
- return [4 /*yield*/, test_ticket_automation_assignment_and_optimization()];
8914
+ return [4 /*yield*/, field_equals_trigger_tests()];
8395
8915
  case 27:
8396
8916
  _l.sent();
8397
- return [4 /*yield*/, role_based_access_tests()];
8917
+ return [4 /*yield*/, test_ticket_automation_assignment_and_optimization()];
8398
8918
  case 28:
8399
8919
  _l.sent();
8400
- return [4 /*yield*/, automation_trigger_tests()];
8920
+ return [4 /*yield*/, role_based_access_tests()];
8401
8921
  case 29:
8402
8922
  _l.sent();
8403
- return [4 /*yield*/, enduser_session_tests()];
8923
+ return [4 /*yield*/, automation_trigger_tests()];
8404
8924
  case 30:
8405
8925
  _l.sent();
8406
- return [4 /*yield*/, nextReminderInMS_tests()];
8926
+ return [4 /*yield*/, enduser_session_tests()];
8407
8927
  case 31:
8408
8928
  _l.sent();
8409
- return [4 /*yield*/, search_tests()];
8929
+ return [4 /*yield*/, nextReminderInMS_tests()];
8410
8930
  case 32:
8411
8931
  _l.sent();
8412
- return [4 /*yield*/, wait_for_trigger_tests()];
8932
+ return [4 /*yield*/, search_tests()];
8413
8933
  case 33:
8414
8934
  _l.sent();
8415
- return [4 /*yield*/, pdf_generation()];
8935
+ return [4 /*yield*/, wait_for_trigger_tests()];
8416
8936
  case 34:
8417
8937
  _l.sent();
8418
- return [4 /*yield*/, remove_from_journey_on_incoming_comms_tests()];
8938
+ return [4 /*yield*/, pdf_generation()];
8419
8939
  case 35:
8420
8940
  _l.sent();
8421
- return [4 /*yield*/, rate_limit_tests()];
8941
+ return [4 /*yield*/, remove_from_journey_on_incoming_comms_tests()];
8422
8942
  case 36:
8423
8943
  _l.sent();
8424
- return [4 /*yield*/, merge_enduser_tests()];
8944
+ return [4 /*yield*/, rate_limit_tests()];
8425
8945
  case 37:
8426
8946
  _l.sent();
8427
- return [4 /*yield*/, auto_reply_tests()];
8947
+ return [4 /*yield*/, merge_enduser_tests()];
8428
8948
  case 38:
8429
8949
  _l.sent();
8430
- return [4 /*yield*/, sub_organization_enduser_tests()];
8950
+ return [4 /*yield*/, auto_reply_tests()];
8431
8951
  case 39:
8432
8952
  _l.sent();
8433
- return [4 /*yield*/, sub_organization_tests()];
8953
+ return [4 /*yield*/, sub_organization_enduser_tests()];
8434
8954
  case 40:
8435
8955
  _l.sent();
8436
- return [4 /*yield*/, filter_by_date_tests()];
8956
+ return [4 /*yield*/, sub_organization_tests()];
8437
8957
  case 41:
8438
8958
  _l.sent();
8439
- return [4 /*yield*/, generate_user_auth_tests()];
8959
+ return [4 /*yield*/, filter_by_date_tests()];
8440
8960
  case 42:
8441
8961
  _l.sent();
8442
- return [4 /*yield*/, generateEnduserAuthTests()];
8962
+ return [4 /*yield*/, generate_user_auth_tests()];
8443
8963
  case 43:
8444
8964
  _l.sent();
8445
- return [4 /*yield*/, public_form_tests()];
8965
+ return [4 /*yield*/, generateEnduserAuthTests()];
8446
8966
  case 44:
8447
8967
  _l.sent();
8448
- return [4 /*yield*/, badInputTests()];
8968
+ return [4 /*yield*/, public_form_tests()];
8449
8969
  case 45:
8450
8970
  _l.sent();
8451
- return [4 /*yield*/, filterTests()];
8971
+ return [4 /*yield*/, badInputTests()];
8452
8972
  case 46:
8453
8973
  _l.sent();
8454
- return [4 /*yield*/, updatesTests()];
8974
+ return [4 /*yield*/, filterTests()];
8455
8975
  case 47:
8456
8976
  _l.sent();
8457
- return [4 /*yield*/, threadKeyTests()];
8977
+ return [4 /*yield*/, updatesTests()];
8458
8978
  case 48:
8459
8979
  _l.sent();
8460
- return [4 /*yield*/, enduserAccessTests()];
8980
+ return [4 /*yield*/, threadKeyTests()];
8461
8981
  case 49:
8462
8982
  _l.sent();
8463
- return [4 /*yield*/, enduser_redaction_tests()];
8983
+ return [4 /*yield*/, enduserAccessTests()];
8464
8984
  case 50:
8465
8985
  _l.sent();
8466
- return [3 /*break*/, 52];
8986
+ return [4 /*yield*/, enduser_redaction_tests()];
8467
8987
  case 51:
8988
+ _l.sent();
8989
+ return [3 /*break*/, 53];
8990
+ case 52:
8468
8991
  err_1 = _l.sent();
8469
8992
  console.error("Failed during custom test");
8470
8993
  if (err_1.message && err_1.info) {
@@ -8474,18 +8997,18 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8474
8997
  console.error(err_1);
8475
8998
  }
8476
8999
  process.exit(1);
8477
- return [3 /*break*/, 52];
8478
- case 52:
9000
+ return [3 /*break*/, 53];
9001
+ case 53:
8479
9002
  _a = schema;
8480
9003
  _b = [];
8481
9004
  for (_c in _a)
8482
9005
  _b.push(_c);
8483
9006
  _i = 0;
8484
- _l.label = 53;
8485
- case 53:
8486
- if (!(_i < _b.length)) return [3 /*break*/, 56];
9007
+ _l.label = 54;
9008
+ case 54:
9009
+ if (!(_i < _b.length)) return [3 /*break*/, 57];
8487
9010
  _c = _b[_i];
8488
- if (!(_c in _a)) return [3 /*break*/, 55];
9011
+ if (!(_c in _a)) return [3 /*break*/, 56];
8489
9012
  n = _c;
8490
9013
  returnValidation = (_k = (_j = schema[n].customActions) === null || _j === void 0 ? void 0 : _j.create) === null || _k === void 0 ? void 0 : _k.returns;
8491
9014
  return [4 /*yield*/, run_generated_tests({
@@ -8496,41 +9019,41 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8496
9019
  create: returnValidation // ModelFields<ClientModel>,
8497
9020
  }
8498
9021
  })];
8499
- case 54:
8500
- _l.sent();
8501
- _l.label = 55;
8502
9022
  case 55:
8503
- _i++;
8504
- return [3 /*break*/, 53];
9023
+ _l.sent();
9024
+ _l.label = 56;
8505
9025
  case 56:
9026
+ _i++;
9027
+ return [3 /*break*/, 54];
9028
+ case 57:
8506
9029
  _d = tests;
8507
9030
  _f = [];
8508
9031
  for (_g in _d)
8509
9032
  _f.push(_g);
8510
9033
  _h = 0;
8511
- _l.label = 57;
8512
- case 57:
8513
- if (!(_h < _f.length)) return [3 /*break*/, 62];
8514
- _g = _f[_h];
8515
- if (!(_g in _d)) return [3 /*break*/, 61];
8516
- t = _g;
8517
9034
  _l.label = 58;
8518
9035
  case 58:
8519
- _l.trys.push([58, 60, , 61]);
8520
- return [4 /*yield*/, tests[t]()];
9036
+ if (!(_h < _f.length)) return [3 /*break*/, 63];
9037
+ _g = _f[_h];
9038
+ if (!(_g in _d)) return [3 /*break*/, 62];
9039
+ t = _g;
9040
+ _l.label = 59;
8521
9041
  case 59:
8522
- _l.sent();
8523
- return [3 /*break*/, 61];
9042
+ _l.trys.push([59, 61, , 62]);
9043
+ return [4 /*yield*/, tests[t]()];
8524
9044
  case 60:
9045
+ _l.sent();
9046
+ return [3 /*break*/, 62];
9047
+ case 61:
8525
9048
  err_2 = _l.sent();
8526
9049
  console.error("Error running test:");
8527
9050
  console.error(err_2);
8528
9051
  process.exit(1);
8529
- return [3 /*break*/, 61];
8530
- case 61:
8531
- _h++;
8532
- return [3 /*break*/, 57];
9052
+ return [3 /*break*/, 62];
8533
9053
  case 62:
9054
+ _h++;
9055
+ return [3 /*break*/, 58];
9056
+ case 63:
8534
9057
  process.exit();
8535
9058
  return [2 /*return*/];
8536
9059
  }