@tellescope/sdk 1.80.4 → 1.81.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.
@@ -6311,9 +6311,10 @@ var nextReminderInMS_tests = function () { return __awaiter(void 0, void 0, void
6311
6311
  }
6312
6312
  });
6313
6313
  }); };
6314
- var pollForResults = function (f, evaluate, intervalInMS, iterations) {
6314
+ var pollForResults = function (f, evaluate, intervalInMS, iterations, shouldError) {
6315
6315
  if (intervalInMS === void 0) { intervalInMS = 500; }
6316
6316
  if (iterations === void 0) { iterations = 20; }
6317
+ if (shouldError === void 0) { shouldError = false; }
6317
6318
  return __awaiter(void 0, void 0, void 0, function () {
6318
6319
  var lastResult, i, result;
6319
6320
  return __generator(this, function (_a) {
@@ -6338,6 +6339,8 @@ var pollForResults = function (f, evaluate, intervalInMS, iterations) {
6338
6339
  i++;
6339
6340
  return [3 /*break*/, 1];
6340
6341
  case 5:
6342
+ if (shouldError)
6343
+ return [2 /*return*/, lastResult];
6341
6344
  console.log(lastResult);
6342
6345
  throw new Error("failed pollForResults");
6343
6346
  }
@@ -8053,7 +8056,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8053
8056
  _a.sent();
8054
8057
  return [4 /*yield*/, (0, testing_1.async_test)("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8055
8058
  var results = _a.results;
8056
- return results.length === 0;
8059
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8057
8060
  } })];
8058
8061
  case 8:
8059
8062
  _a.sent();
@@ -8086,7 +8089,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8086
8089
  _a.sent();
8087
8090
  return [4 /*yield*/, (0, testing_1.async_test)("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8088
8091
  var results = _a.results;
8089
- return results.length === 0;
8092
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8090
8093
  } })];
8091
8094
  case 14:
8092
8095
  _a.sent();
@@ -8192,7 +8195,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8192
8195
  _a.sent();
8193
8196
  return [4 /*yield*/, (0, testing_1.async_test)("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8194
8197
  var results = _a.results;
8195
- return results.length === 0;
8198
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8196
8199
  } })
8197
8200
  // bulk create test coverage
8198
8201
  ];
@@ -8229,7 +8232,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8229
8232
  _a.sent();
8230
8233
  return [4 /*yield*/, (0, testing_1.async_test)("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8231
8234
  var results = _a.results;
8232
- return results.length === 0;
8235
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8233
8236
  } })];
8234
8237
  case 41:
8235
8238
  _a.sent();
@@ -8262,7 +8265,7 @@ var sync_tests = function () { return __awaiter(void 0, void 0, void 0, function
8262
8265
  _a.sent();
8263
8266
  return [4 /*yield*/, (0, testing_1.async_test)("Other organization", function () { return sdkOther.sync({ from: from }); }, { onResult: function (_a) {
8264
8267
  var results = _a.results;
8265
- return results.length === 0;
8268
+ return results.filter(function (e) { return e.modelName === 'endusers' && e.data !== 'deleted'; }).length === 0;
8266
8269
  } })];
8267
8270
  case 47:
8268
8271
  _a.sent();
@@ -8334,6 +8337,523 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8334
8337
  }
8335
8338
  });
8336
8339
  }); };
8340
+ var vital_trigger_tests = function () { return __awaiter(void 0, void 0, void 0, function () {
8341
+ var runTriggerTest, timestamp_for_day_offset;
8342
+ return __generator(this, function (_a) {
8343
+ switch (_a.label) {
8344
+ case 0:
8345
+ (0, testing_1.log_header)("Vital Update Trigger");
8346
+ runTriggerTest = function (_a) {
8347
+ var _configurations = _a.configurations, _triggers = _a.triggers, shouldTrigger = _a.shouldTrigger, vitals = _a.vitals, title = _a.title;
8348
+ return __awaiter(void 0, void 0, void 0, function () {
8349
+ var e, configurations, triggers;
8350
+ return __generator(this, function (_b) {
8351
+ switch (_b.label) {
8352
+ case 0: return [4 /*yield*/, sdk.api.endusers.createOne({})];
8353
+ case 1:
8354
+ e = _b.sent();
8355
+ return [4 /*yield*/, sdk.api.vital_configurations.createSome(_configurations.map(function (c, i) { return (__assign({ title: "configuration ".concat(i) }, c)); }))];
8356
+ case 2:
8357
+ configurations = (_b.sent()).created;
8358
+ return [4 /*yield*/, sdk.api.automation_triggers.createSome(_triggers.map(function (t, i) { return ({
8359
+ title: "trigger ".concat(i),
8360
+ status: 'Active',
8361
+ event: {
8362
+ type: "Vital Update",
8363
+ info: {
8364
+ classifications: t.classifications,
8365
+ configurationIds: configurations.filter(function (_, i) { return t.configurationIndexes.includes(i); }).map(function (c) { return c.id; }),
8366
+ }
8367
+ },
8368
+ action: {
8369
+ type: 'Add Tags',
8370
+ info: { tags: ['Triggered'] },
8371
+ },
8372
+ }); }))];
8373
+ case 3:
8374
+ triggers = (_b.sent()).created;
8375
+ return [4 /*yield*/, sdk.api.enduser_observations.createSome(vitals.map(function (v) { return (__assign(__assign({}, v), { category: 'vital-signs', enduserId: e.id, status: 'registered' })); }))];
8376
+ case 4:
8377
+ _b.sent();
8378
+ return [4 /*yield*/, (0, testing_1.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)];
8379
+ case 5:
8380
+ _b.sent();
8381
+ return [4 /*yield*/, Promise.all(__spreadArray(__spreadArray([
8382
+ sdk.api.endusers.deleteOne(e.id)
8383
+ ], 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))];
8384
+ case 6:
8385
+ _b.sent();
8386
+ return [2 /*return*/];
8387
+ }
8388
+ });
8389
+ });
8390
+ };
8391
+ timestamp_for_day_offset = function (day) { return new Date(Date.now() - 1000 * 60 * 60 * 24 * day); };
8392
+ return [4 /*yield*/, runTriggerTest({
8393
+ title: "Basic Passing Test (Less Than Sucess)",
8394
+ shouldTrigger: true,
8395
+ configurations: [{
8396
+ unit: 'LB',
8397
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 0 },],
8398
+ }],
8399
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8400
+ vitals: [{
8401
+ measurement: { unit: 'LB', value: 1 },
8402
+ timestamp: new Date(),
8403
+ }]
8404
+ })];
8405
+ case 1:
8406
+ _a.sent();
8407
+ return [4 /*yield*/, runTriggerTest({
8408
+ title: "Less Than Fail",
8409
+ shouldTrigger: false,
8410
+ configurations: [{
8411
+ unit: 'LB',
8412
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 0 },],
8413
+ }],
8414
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8415
+ vitals: [{
8416
+ measurement: { unit: 'LB', value: 1 },
8417
+ timestamp: new Date(),
8418
+ }]
8419
+ })];
8420
+ case 2:
8421
+ _a.sent();
8422
+ return [4 /*yield*/, runTriggerTest({
8423
+ title: "Greater Than Success",
8424
+ shouldTrigger: true,
8425
+ configurations: [{
8426
+ unit: 'LB',
8427
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 0 }, trendIntervalInMS: 0 },],
8428
+ }],
8429
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8430
+ vitals: [{
8431
+ measurement: { unit: 'LB', value: 1 },
8432
+ timestamp: new Date(),
8433
+ }]
8434
+ })];
8435
+ case 3:
8436
+ _a.sent();
8437
+ return [4 /*yield*/, runTriggerTest({
8438
+ title: "Greater Than Fail",
8439
+ shouldTrigger: false,
8440
+ configurations: [{
8441
+ unit: 'LB',
8442
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 0 }, trendIntervalInMS: 0 },],
8443
+ }],
8444
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8445
+ vitals: [{
8446
+ measurement: { unit: 'LB', value: 0 },
8447
+ timestamp: new Date(),
8448
+ }]
8449
+ })];
8450
+ case 4:
8451
+ _a.sent();
8452
+ return [4 /*yield*/, runTriggerTest({
8453
+ title: "Between Low Bound",
8454
+ shouldTrigger: true,
8455
+ configurations: [{
8456
+ unit: 'LB',
8457
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8458
+ }],
8459
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8460
+ vitals: [{
8461
+ measurement: { unit: 'LB', value: 0 },
8462
+ timestamp: new Date(),
8463
+ }]
8464
+ })];
8465
+ case 5:
8466
+ _a.sent();
8467
+ return [4 /*yield*/, runTriggerTest({
8468
+ title: "Between Upper Bound",
8469
+ shouldTrigger: true,
8470
+ configurations: [{
8471
+ unit: 'LB',
8472
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8473
+ }],
8474
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8475
+ vitals: [{
8476
+ measurement: { unit: 'LB', value: 1 },
8477
+ timestamp: new Date(),
8478
+ }]
8479
+ })];
8480
+ case 6:
8481
+ _a.sent();
8482
+ return [4 /*yield*/, runTriggerTest({
8483
+ title: "Between Middle",
8484
+ shouldTrigger: true,
8485
+ configurations: [{
8486
+ unit: 'LB',
8487
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 2 } }, trendIntervalInMS: 0 },],
8488
+ }],
8489
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8490
+ vitals: [{
8491
+ measurement: { unit: 'LB', value: 1 },
8492
+ timestamp: new Date(),
8493
+ }]
8494
+ })];
8495
+ case 7:
8496
+ _a.sent();
8497
+ return [4 /*yield*/, runTriggerTest({
8498
+ title: "Between Below Low Bound",
8499
+ shouldTrigger: false,
8500
+ configurations: [{
8501
+ unit: 'LB',
8502
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8503
+ }],
8504
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8505
+ vitals: [{
8506
+ measurement: { unit: 'LB', value: -1 },
8507
+ timestamp: new Date(),
8508
+ }]
8509
+ })];
8510
+ case 8:
8511
+ _a.sent();
8512
+ return [4 /*yield*/, runTriggerTest({
8513
+ title: "Between Above Upper Bound",
8514
+ shouldTrigger: false,
8515
+ configurations: [{
8516
+ unit: 'LB',
8517
+ ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 },],
8518
+ }],
8519
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8520
+ vitals: [{
8521
+ measurement: { unit: 'LB', value: 2 },
8522
+ timestamp: new Date(),
8523
+ }]
8524
+ })];
8525
+ case 9:
8526
+ _a.sent();
8527
+ return [4 /*yield*/, runTriggerTest({
8528
+ title: "Mismatch Unit",
8529
+ shouldTrigger: false,
8530
+ configurations: [{
8531
+ unit: 'DIFFERENT',
8532
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8533
+ }],
8534
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8535
+ vitals: [{
8536
+ measurement: { unit: 'LB', value: 1 },
8537
+ timestamp: new Date(),
8538
+ }]
8539
+ })];
8540
+ case 10:
8541
+ _a.sent();
8542
+ return [4 /*yield*/, runTriggerTest({
8543
+ title: "Mismatch Classification",
8544
+ shouldTrigger: false,
8545
+ configurations: [{
8546
+ unit: 'LB',
8547
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8548
+ }],
8549
+ triggers: [{ classifications: ['High'], configurationIndexes: [0] }],
8550
+ vitals: [{
8551
+ measurement: { unit: 'LB', value: 1 },
8552
+ timestamp: new Date(),
8553
+ }]
8554
+ })];
8555
+ case 11:
8556
+ _a.sent();
8557
+ return [4 /*yield*/, runTriggerTest({
8558
+ title: "Multiple Configurations (Classifications)",
8559
+ shouldTrigger: true,
8560
+ configurations: [{
8561
+ unit: 'LB',
8562
+ ranges: [
8563
+ { classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },
8564
+ { classification: 'High', comparison: { type: 'Less Than', value: 100 }, trendIntervalInMS: 0 },
8565
+ ],
8566
+ }],
8567
+ triggers: [{ classifications: ['High'], configurationIndexes: [0, 1] }],
8568
+ vitals: [{
8569
+ measurement: { unit: 'LB', value: 1 },
8570
+ timestamp: new Date(),
8571
+ }]
8572
+ })];
8573
+ case 12:
8574
+ _a.sent();
8575
+ return [4 /*yield*/, runTriggerTest({
8576
+ title: "Multiple Configurations (Comparisons)",
8577
+ shouldTrigger: true,
8578
+ configurations: [{
8579
+ unit: 'LB',
8580
+ ranges: [
8581
+ { classification: 'Target', comparison: { type: 'Less Than', value: 0 }, trendIntervalInMS: 0 },
8582
+ { classification: 'High', comparison: { type: 'Less Than', value: 100 }, trendIntervalInMS: 0 },
8583
+ ],
8584
+ }],
8585
+ triggers: [{ classifications: ['High'], configurationIndexes: [0, 1] }],
8586
+ vitals: [{
8587
+ measurement: { unit: 'LB', value: 1 },
8588
+ timestamp: new Date(),
8589
+ }]
8590
+ })];
8591
+ case 13:
8592
+ _a.sent();
8593
+ return [4 /*yield*/, runTriggerTest({
8594
+ title: "Multiple vitals, 0 passes",
8595
+ shouldTrigger: false,
8596
+ configurations: [{
8597
+ unit: 'LB',
8598
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8599
+ }],
8600
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8601
+ vitals: [
8602
+ { measurement: { unit: 'LB', value: 500 }, timestamp: new Date() },
8603
+ { measurement: { unit: 'LB', value: 1000 }, timestamp: new Date(Date.now() - 100) },
8604
+ { measurement: { unit: 'LB', value: 250 }, timestamp: new Date(Date.now() - 250) },
8605
+ ]
8606
+ })];
8607
+ case 14:
8608
+ _a.sent();
8609
+ return [4 /*yield*/, runTriggerTest({
8610
+ title: "Multiple vitals, 1 passes",
8611
+ shouldTrigger: true,
8612
+ configurations: [{
8613
+ unit: 'LB',
8614
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8615
+ }],
8616
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8617
+ vitals: [
8618
+ { measurement: { unit: 'LB', value: 500 }, timestamp: new Date() },
8619
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(Date.now() - 100) },
8620
+ { measurement: { unit: 'LB', value: 250 }, timestamp: new Date(Date.now() - 250) },
8621
+ ]
8622
+ })];
8623
+ case 15:
8624
+ _a.sent();
8625
+ return [4 /*yield*/, runTriggerTest({
8626
+ title: "Multiple vitals, multiple pass",
8627
+ shouldTrigger: true,
8628
+ configurations: [{
8629
+ unit: 'LB',
8630
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },],
8631
+ }],
8632
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8633
+ vitals: [
8634
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8635
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(Date.now() - 100) },
8636
+ { measurement: { unit: 'LB', value: 3 }, timestamp: new Date(Date.now() - 250) },
8637
+ ]
8638
+ })
8639
+ // trend tests
8640
+ ];
8641
+ case 16:
8642
+ _a.sent();
8643
+ // trend tests
8644
+ return [4 /*yield*/, runTriggerTest({
8645
+ title: "Singleton trend should not work",
8646
+ shouldTrigger: false,
8647
+ configurations: [{
8648
+ unit: 'LB',
8649
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 1000 },],
8650
+ }],
8651
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8652
+ vitals: [{
8653
+ measurement: { unit: 'LB', value: 1 },
8654
+ timestamp: new Date(),
8655
+ }]
8656
+ })];
8657
+ case 17:
8658
+ // trend tests
8659
+ _a.sent();
8660
+ return [4 /*yield*/, runTriggerTest({
8661
+ title: "2-point trend passing",
8662
+ shouldTrigger: true,
8663
+ configurations: [{
8664
+ unit: 'LB',
8665
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 1000 },],
8666
+ }],
8667
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8668
+ vitals: [
8669
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8670
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 999) },
8671
+ ]
8672
+ })];
8673
+ case 18:
8674
+ _a.sent();
8675
+ return [4 /*yield*/, runTriggerTest({
8676
+ title: "2-point trend failing for difference too small",
8677
+ shouldTrigger: true,
8678
+ configurations: [{
8679
+ unit: 'LB',
8680
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 1000 },],
8681
+ }],
8682
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8683
+ vitals: [
8684
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8685
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 999) },
8686
+ ]
8687
+ })];
8688
+ case 19:
8689
+ _a.sent();
8690
+ return [4 /*yield*/, runTriggerTest({
8691
+ title: "2-point trend failing for point out of time range",
8692
+ shouldTrigger: false,
8693
+ configurations: [{
8694
+ unit: 'LB',
8695
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 5 }, trendIntervalInMS: 1000 },],
8696
+ }],
8697
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8698
+ vitals: [
8699
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8700
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 1001) },
8701
+ ]
8702
+ })];
8703
+ case 20:
8704
+ _a.sent();
8705
+ return [4 /*yield*/, runTriggerTest({
8706
+ title: "3-point trend passing (1 point of out range)",
8707
+ shouldTrigger: true,
8708
+ configurations: [{
8709
+ unit: 'LB',
8710
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8711
+ }],
8712
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8713
+ vitals: [
8714
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8715
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 100) },
8716
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 1001) },
8717
+ ]
8718
+ })];
8719
+ case 21:
8720
+ _a.sent();
8721
+ return [4 /*yield*/, runTriggerTest({
8722
+ title: "3-point trend passing (1 point wrong unit)",
8723
+ shouldTrigger: true,
8724
+ configurations: [{
8725
+ unit: 'LB',
8726
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8727
+ }],
8728
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8729
+ vitals: [
8730
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8731
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 100) },
8732
+ { measurement: { unit: 'OTHER', value: 0 }, timestamp: new Date(new Date().getTime() - 200) },
8733
+ ]
8734
+ })];
8735
+ case 22:
8736
+ _a.sent();
8737
+ return [4 /*yield*/, runTriggerTest({
8738
+ title: "3-point trend failing (1 point of out range)",
8739
+ shouldTrigger: false,
8740
+ configurations: [{
8741
+ unit: 'LB',
8742
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8743
+ }],
8744
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8745
+ vitals: [
8746
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8747
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 100) },
8748
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 1001) },
8749
+ ]
8750
+ })];
8751
+ case 23:
8752
+ _a.sent();
8753
+ return [4 /*yield*/, runTriggerTest({
8754
+ title: "3-point trend failing (1 point wrong unit)",
8755
+ shouldTrigger: false,
8756
+ configurations: [{
8757
+ unit: 'LB',
8758
+ ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 },],
8759
+ }],
8760
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8761
+ vitals: [
8762
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8763
+ { measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 100) },
8764
+ { measurement: { unit: 'OTHER', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
8765
+ ]
8766
+ })];
8767
+ case 24:
8768
+ _a.sent();
8769
+ return [4 /*yield*/, runTriggerTest({
8770
+ title: "multiple trend passing",
8771
+ shouldTrigger: true,
8772
+ configurations: [{
8773
+ unit: 'LB',
8774
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8775
+ }],
8776
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8777
+ vitals: [
8778
+ { measurement: { unit: 'LB', value: 3 }, timestamp: new Date() },
8779
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8780
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
8781
+ ]
8782
+ })];
8783
+ case 25:
8784
+ _a.sent();
8785
+ return [4 /*yield*/, runTriggerTest({
8786
+ title: "multiple trend failing (not enough)",
8787
+ shouldTrigger: false,
8788
+ configurations: [{
8789
+ unit: 'LB',
8790
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8791
+ }],
8792
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8793
+ vitals: [
8794
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
8795
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8796
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
8797
+ ]
8798
+ })];
8799
+ case 26:
8800
+ _a.sent();
8801
+ return [4 /*yield*/, runTriggerTest({
8802
+ title: "multiple trend failing (wrong order)",
8803
+ shouldTrigger: false,
8804
+ configurations: [{
8805
+ unit: 'LB',
8806
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8807
+ }],
8808
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8809
+ vitals: [
8810
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8811
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8812
+ { measurement: { unit: 'LB', value: 3 }, timestamp: new Date(new Date().getTime() - 200) },
8813
+ ]
8814
+ })];
8815
+ case 27:
8816
+ _a.sent();
8817
+ return [4 /*yield*/, runTriggerTest({
8818
+ title: "multiple trend failing (not enough, and wrong order)",
8819
+ shouldTrigger: false,
8820
+ configurations: [{
8821
+ unit: 'LB',
8822
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8823
+ }],
8824
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8825
+ vitals: [
8826
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8827
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8828
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 200) },
8829
+ ]
8830
+ })];
8831
+ case 28:
8832
+ _a.sent();
8833
+ return [4 /*yield*/, runTriggerTest({
8834
+ title: "multiple trend failing (lots)",
8835
+ shouldTrigger: false,
8836
+ configurations: [{
8837
+ unit: 'LB',
8838
+ ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 },],
8839
+ }],
8840
+ triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
8841
+ vitals: [
8842
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
8843
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
8844
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 200) },
8845
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 300) },
8846
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 400) },
8847
+ { measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 500) },
8848
+ { measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 600) },
8849
+ ]
8850
+ })];
8851
+ case 29:
8852
+ _a.sent();
8853
+ return [2 /*return*/];
8854
+ }
8855
+ });
8856
+ }); };
8337
8857
  (function () { return __awaiter(void 0, void 0, void 0, function () {
8338
8858
  var err_1, n, _a, _b, _c, _i, returnValidation, t, _d, _f, _g, _h, err_2;
8339
8859
  var _j, _k;
@@ -8346,7 +8866,7 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8346
8866
  _l.sent();
8347
8867
  _l.label = 2;
8348
8868
  case 2:
8349
- _l.trys.push([2, 51, , 52]);
8869
+ _l.trys.push([2, 52, , 53]);
8350
8870
  (0, exports.form_conditional_logic_tests)();
8351
8871
  return [4 /*yield*/, test_weighted_round_robin()];
8352
8872
  case 3:
@@ -8391,126 +8911,129 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8391
8911
  return [4 /*yield*/, sync_tests()]; // should come directly after setup to avoid extra sync values
8392
8912
  case 12:
8393
8913
  _l.sent(); // should come directly after setup to avoid extra sync values
8394
- return [4 /*yield*/, (0, exports.ticket_queue_tests)()];
8914
+ return [4 /*yield*/, vital_trigger_tests()];
8395
8915
  case 13:
8396
8916
  _l.sent();
8397
- return [4 /*yield*/, close_reasons_no_duplicates_tests()];
8917
+ return [4 /*yield*/, (0, exports.ticket_queue_tests)()];
8398
8918
  case 14:
8399
8919
  _l.sent();
8400
- return [4 /*yield*/, register_as_enduser_tests()];
8920
+ return [4 /*yield*/, close_reasons_no_duplicates_tests()];
8401
8921
  case 15:
8402
8922
  _l.sent();
8403
- return [4 /*yield*/, lockout_tests()];
8923
+ return [4 /*yield*/, register_as_enduser_tests()];
8404
8924
  case 16:
8405
8925
  _l.sent();
8406
- return [4 /*yield*/, (0, exports.self_serve_appointment_booking_tests)()];
8926
+ return [4 /*yield*/, lockout_tests()];
8407
8927
  case 17:
8928
+ _l.sent();
8929
+ return [4 /*yield*/, (0, exports.self_serve_appointment_booking_tests)()];
8930
+ case 18:
8408
8931
  _l.sent();
8409
8932
  return [4 /*yield*/, delete_user_tests()
8410
8933
  // await test_send_with_template()
8411
8934
  ];
8412
- case 18:
8935
+ case 19:
8413
8936
  _l.sent();
8414
8937
  // await test_send_with_template()
8415
8938
  return [4 /*yield*/, bulk_read_tests()];
8416
- case 19:
8939
+ case 20:
8417
8940
  // await test_send_with_template()
8418
8941
  _l.sent();
8419
8942
  return [4 /*yield*/, (0, exports.ticket_reminder_tests)()];
8420
- case 20:
8421
- _l.sent();
8422
- return [4 /*yield*/, enduser_access_tags_tests()];
8423
8943
  case 21:
8424
8944
  _l.sent();
8425
- return [4 /*yield*/, marketing_email_unsubscribe_tests()];
8945
+ return [4 /*yield*/, enduser_access_tags_tests()];
8426
8946
  case 22:
8427
8947
  _l.sent();
8428
- return [4 /*yield*/, unique_strings_tests()];
8948
+ return [4 /*yield*/, marketing_email_unsubscribe_tests()];
8429
8949
  case 23:
8430
8950
  _l.sent();
8431
- return [4 /*yield*/, (0, exports.alternate_phones_tests)()];
8951
+ return [4 /*yield*/, unique_strings_tests()];
8432
8952
  case 24:
8433
8953
  _l.sent();
8434
- return [4 /*yield*/, (0, exports.no_chained_triggers_tests)()];
8954
+ return [4 /*yield*/, (0, exports.alternate_phones_tests)()];
8435
8955
  case 25:
8436
8956
  _l.sent();
8437
- return [4 /*yield*/, field_equals_trigger_tests()];
8957
+ return [4 /*yield*/, (0, exports.no_chained_triggers_tests)()];
8438
8958
  case 26:
8439
8959
  _l.sent();
8440
- return [4 /*yield*/, test_ticket_automation_assignment_and_optimization()];
8960
+ return [4 /*yield*/, field_equals_trigger_tests()];
8441
8961
  case 27:
8442
8962
  _l.sent();
8443
- return [4 /*yield*/, role_based_access_tests()];
8963
+ return [4 /*yield*/, test_ticket_automation_assignment_and_optimization()];
8444
8964
  case 28:
8445
8965
  _l.sent();
8446
- return [4 /*yield*/, automation_trigger_tests()];
8966
+ return [4 /*yield*/, role_based_access_tests()];
8447
8967
  case 29:
8448
8968
  _l.sent();
8449
- return [4 /*yield*/, enduser_session_tests()];
8969
+ return [4 /*yield*/, automation_trigger_tests()];
8450
8970
  case 30:
8451
8971
  _l.sent();
8452
- return [4 /*yield*/, nextReminderInMS_tests()];
8972
+ return [4 /*yield*/, enduser_session_tests()];
8453
8973
  case 31:
8454
8974
  _l.sent();
8455
- return [4 /*yield*/, search_tests()];
8975
+ return [4 /*yield*/, nextReminderInMS_tests()];
8456
8976
  case 32:
8457
8977
  _l.sent();
8458
- return [4 /*yield*/, wait_for_trigger_tests()];
8978
+ return [4 /*yield*/, search_tests()];
8459
8979
  case 33:
8460
8980
  _l.sent();
8461
- return [4 /*yield*/, pdf_generation()];
8981
+ return [4 /*yield*/, wait_for_trigger_tests()];
8462
8982
  case 34:
8463
8983
  _l.sent();
8464
- return [4 /*yield*/, remove_from_journey_on_incoming_comms_tests()];
8984
+ return [4 /*yield*/, pdf_generation()];
8465
8985
  case 35:
8466
8986
  _l.sent();
8467
- return [4 /*yield*/, rate_limit_tests()];
8987
+ return [4 /*yield*/, remove_from_journey_on_incoming_comms_tests()];
8468
8988
  case 36:
8469
8989
  _l.sent();
8470
- return [4 /*yield*/, merge_enduser_tests()];
8990
+ return [4 /*yield*/, rate_limit_tests()];
8471
8991
  case 37:
8472
8992
  _l.sent();
8473
- return [4 /*yield*/, auto_reply_tests()];
8993
+ return [4 /*yield*/, merge_enduser_tests()];
8474
8994
  case 38:
8475
8995
  _l.sent();
8476
- return [4 /*yield*/, sub_organization_enduser_tests()];
8996
+ return [4 /*yield*/, auto_reply_tests()];
8477
8997
  case 39:
8478
8998
  _l.sent();
8479
- return [4 /*yield*/, sub_organization_tests()];
8999
+ return [4 /*yield*/, sub_organization_enduser_tests()];
8480
9000
  case 40:
8481
9001
  _l.sent();
8482
- return [4 /*yield*/, (0, exports.filter_by_date_tests)()];
9002
+ return [4 /*yield*/, sub_organization_tests()];
8483
9003
  case 41:
8484
9004
  _l.sent();
8485
- return [4 /*yield*/, generate_user_auth_tests()];
9005
+ return [4 /*yield*/, (0, exports.filter_by_date_tests)()];
8486
9006
  case 42:
8487
9007
  _l.sent();
8488
- return [4 /*yield*/, generateEnduserAuthTests()];
9008
+ return [4 /*yield*/, generate_user_auth_tests()];
8489
9009
  case 43:
8490
9010
  _l.sent();
8491
- return [4 /*yield*/, public_form_tests()];
9011
+ return [4 /*yield*/, generateEnduserAuthTests()];
8492
9012
  case 44:
8493
9013
  _l.sent();
8494
- return [4 /*yield*/, badInputTests()];
9014
+ return [4 /*yield*/, public_form_tests()];
8495
9015
  case 45:
8496
9016
  _l.sent();
8497
- return [4 /*yield*/, filterTests()];
9017
+ return [4 /*yield*/, badInputTests()];
8498
9018
  case 46:
8499
9019
  _l.sent();
8500
- return [4 /*yield*/, updatesTests()];
9020
+ return [4 /*yield*/, filterTests()];
8501
9021
  case 47:
8502
9022
  _l.sent();
8503
- return [4 /*yield*/, threadKeyTests()];
9023
+ return [4 /*yield*/, updatesTests()];
8504
9024
  case 48:
8505
9025
  _l.sent();
8506
- return [4 /*yield*/, enduserAccessTests()];
9026
+ return [4 /*yield*/, threadKeyTests()];
8507
9027
  case 49:
8508
9028
  _l.sent();
8509
- return [4 /*yield*/, enduser_redaction_tests()];
9029
+ return [4 /*yield*/, enduserAccessTests()];
8510
9030
  case 50:
8511
9031
  _l.sent();
8512
- return [3 /*break*/, 52];
9032
+ return [4 /*yield*/, enduser_redaction_tests()];
8513
9033
  case 51:
9034
+ _l.sent();
9035
+ return [3 /*break*/, 53];
9036
+ case 52:
8514
9037
  err_1 = _l.sent();
8515
9038
  console.error("Failed during custom test");
8516
9039
  if (err_1.message && err_1.info) {
@@ -8520,18 +9043,18 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8520
9043
  console.error(err_1);
8521
9044
  }
8522
9045
  process.exit(1);
8523
- return [3 /*break*/, 52];
8524
- case 52:
9046
+ return [3 /*break*/, 53];
9047
+ case 53:
8525
9048
  _a = schema_1.schema;
8526
9049
  _b = [];
8527
9050
  for (_c in _a)
8528
9051
  _b.push(_c);
8529
9052
  _i = 0;
8530
- _l.label = 53;
8531
- case 53:
8532
- if (!(_i < _b.length)) return [3 /*break*/, 56];
9053
+ _l.label = 54;
9054
+ case 54:
9055
+ if (!(_i < _b.length)) return [3 /*break*/, 57];
8533
9056
  _c = _b[_i];
8534
- if (!(_c in _a)) return [3 /*break*/, 55];
9057
+ if (!(_c in _a)) return [3 /*break*/, 56];
8535
9058
  n = _c;
8536
9059
  returnValidation = (_k = (_j = schema_1.schema[n].customActions) === null || _j === void 0 ? void 0 : _j.create) === null || _k === void 0 ? void 0 : _k.returns;
8537
9060
  return [4 /*yield*/, run_generated_tests({
@@ -8542,41 +9065,41 @@ var close_reasons_no_duplicates_tests = function () { return __awaiter(void 0, v
8542
9065
  create: returnValidation // ModelFields<ClientModel>,
8543
9066
  }
8544
9067
  })];
8545
- case 54:
8546
- _l.sent();
8547
- _l.label = 55;
8548
9068
  case 55:
8549
- _i++;
8550
- return [3 /*break*/, 53];
9069
+ _l.sent();
9070
+ _l.label = 56;
8551
9071
  case 56:
9072
+ _i++;
9073
+ return [3 /*break*/, 54];
9074
+ case 57:
8552
9075
  _d = tests;
8553
9076
  _f = [];
8554
9077
  for (_g in _d)
8555
9078
  _f.push(_g);
8556
9079
  _h = 0;
8557
- _l.label = 57;
8558
- case 57:
8559
- if (!(_h < _f.length)) return [3 /*break*/, 62];
8560
- _g = _f[_h];
8561
- if (!(_g in _d)) return [3 /*break*/, 61];
8562
- t = _g;
8563
9080
  _l.label = 58;
8564
9081
  case 58:
8565
- _l.trys.push([58, 60, , 61]);
8566
- return [4 /*yield*/, tests[t]()];
9082
+ if (!(_h < _f.length)) return [3 /*break*/, 63];
9083
+ _g = _f[_h];
9084
+ if (!(_g in _d)) return [3 /*break*/, 62];
9085
+ t = _g;
9086
+ _l.label = 59;
8567
9087
  case 59:
8568
- _l.sent();
8569
- return [3 /*break*/, 61];
9088
+ _l.trys.push([59, 61, , 62]);
9089
+ return [4 /*yield*/, tests[t]()];
8570
9090
  case 60:
9091
+ _l.sent();
9092
+ return [3 /*break*/, 62];
9093
+ case 61:
8571
9094
  err_2 = _l.sent();
8572
9095
  console.error("Error running test:");
8573
9096
  console.error(err_2);
8574
9097
  process.exit(1);
8575
- return [3 /*break*/, 61];
8576
- case 61:
8577
- _h++;
8578
- return [3 /*break*/, 57];
9098
+ return [3 /*break*/, 62];
8579
9099
  case 62:
9100
+ _h++;
9101
+ return [3 /*break*/, 58];
9102
+ case 63:
8580
9103
  process.exit();
8581
9104
  return [2 /*return*/];
8582
9105
  }