@tellescope/sdk 1.66.2 → 1.66.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/tests/tests.ts"],"names":[],"mappings":"AAqkEA,eAAO,MAAM,kCAAkC,qBA4I9C,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAsK/C,CAAA;AAGD,eAAO,MAAM,oBAAoB,qBAkHhC,CAAA;AAED,eAAO,MAAM,+BAA+B,qBAsF3C,CAAA;AAID,eAAO,MAAM,0BAA0B,qBAqCtC,CAAA;AA+RD,eAAO,MAAM,cAAc,qBAqC1B,CAAA;AAoiBD,eAAO,MAAM,6BAA6B,qBAgCzC,CAAA;AAED,eAAO,MAAM,0BAA0B,qBAmFtC,CAAA;AAqED,eAAO,MAAM,eAAe,qBAgD3B,CAAA;AAED,eAAO,MAAM,oBAAoB,6BAsBhC,CAAA;AAED,eAAO,MAAM,oCAAoC,qBAmKhD,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAkE/C,CAAA"}
1
+ {"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/tests/tests.ts"],"names":[],"mappings":"AAqkEA,eAAO,MAAM,kCAAkC,qBA4I9C,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAsK/C,CAAA;AAGD,eAAO,MAAM,oBAAoB,qBAkHhC,CAAA;AAED,eAAO,MAAM,+BAA+B,qBAsF3C,CAAA;AAID,eAAO,MAAM,0BAA0B,qBAqCtC,CAAA;AAyeD,eAAO,MAAM,cAAc,qBAqC1B,CAAA;AAoiBD,eAAO,MAAM,6BAA6B,qBAgCzC,CAAA;AAED,eAAO,MAAM,0BAA0B,qBAmFtC,CAAA;AAqED,eAAO,MAAM,eAAe,qBAgD3B,CAAA;AAED,eAAO,MAAM,oBAAoB,6BAsBhC,CAAA;AAED,eAAO,MAAM,oCAAoC,qBAmKhD,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAkE/C,CAAA"}
@@ -3453,26 +3453,27 @@ var automation_events_tests = function () { return __awaiter(void 0, void 0, voi
3453
3453
  });
3454
3454
  }); };
3455
3455
  var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, void 0, function () {
3456
- var enduser, journey1, journey2, journey3, form, field, active, dupActive, inactive, accessCode;
3457
- return __generator(this, function (_a) {
3458
- switch (_a.label) {
3456
+ var enduser, journey1, journey2, journey3, form, field, active, dupActive, inactive, noConditions, equals, equalsFalse, existsTrue, existsFalse, doesNotContainTrue, doesNotContainFalse, containFalse, containTrue, accessCode;
3457
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3458
+ return __generator(this, function (_j) {
3459
+ switch (_j.label) {
3459
3460
  case 0:
3460
3461
  log_header("Automation Trigger: Form Response --> Add To Journey");
3461
3462
  return [4 /*yield*/, sdk.api.endusers.createOne({ fname: 'test' })];
3462
3463
  case 1:
3463
- enduser = _a.sent();
3464
+ enduser = _j.sent();
3464
3465
  return [4 /*yield*/, sdk.api.journeys.createOne({ title: 'journey' })];
3465
3466
  case 2:
3466
- journey1 = _a.sent();
3467
+ journey1 = _j.sent();
3467
3468
  return [4 /*yield*/, sdk.api.journeys.createOne({ title: 'journey2' })];
3468
3469
  case 3:
3469
- journey2 = _a.sent();
3470
+ journey2 = _j.sent();
3470
3471
  return [4 /*yield*/, sdk.api.journeys.createOne({ title: 'journey3' })];
3471
3472
  case 4:
3472
- journey3 = _a.sent();
3473
+ journey3 = _j.sent();
3473
3474
  return [4 /*yield*/, sdk.api.forms.createOne({ title: 'form' })];
3474
3475
  case 5:
3475
- form = _a.sent();
3476
+ form = _j.sent();
3476
3477
  return [4 /*yield*/, sdk.api.form_fields.createOne({
3477
3478
  formId: form.id,
3478
3479
  type: 'string',
@@ -3485,7 +3486,7 @@ var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, v
3485
3486
  ],
3486
3487
  })];
3487
3488
  case 6:
3488
- field = _a.sent();
3489
+ field = _j.sent();
3489
3490
  return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3490
3491
  event: { type: 'Form Submitted', info: { formId: form.id } },
3491
3492
  action: { type: 'Add To Journey', info: { journeyId: journey1.id } },
@@ -3493,7 +3494,7 @@ var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, v
3493
3494
  title: "Active"
3494
3495
  })];
3495
3496
  case 7:
3496
- active = _a.sent();
3497
+ active = _j.sent();
3497
3498
  return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3498
3499
  event: { type: 'Form Submitted', info: { formId: form.id } },
3499
3500
  action: { type: 'Add To Journey', info: { journeyId: journey2.id } },
@@ -3501,7 +3502,7 @@ var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, v
3501
3502
  title: "Dup Active"
3502
3503
  })];
3503
3504
  case 8:
3504
- dupActive = _a.sent();
3505
+ dupActive = _j.sent();
3505
3506
  return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3506
3507
  event: { type: 'Form Submitted', info: { formId: form.id } },
3507
3508
  action: { type: 'Add To Journey', info: { journeyId: journey3.id } },
@@ -3509,13 +3510,210 @@ var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, v
3509
3510
  title: "Inactive"
3510
3511
  })];
3511
3512
  case 9:
3512
- inactive = _a.sent();
3513
+ inactive = _j.sent();
3514
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3515
+ event: {
3516
+ type: 'Form Submitted',
3517
+ info: {
3518
+ formId: form.id,
3519
+ },
3520
+ },
3521
+ action: { type: 'Add Tags', info: { tags: ['No Conditions'] } },
3522
+ status: 'Active',
3523
+ title: "No Conditions"
3524
+ })];
3525
+ case 10:
3526
+ noConditions = _j.sent();
3527
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3528
+ event: {
3529
+ type: 'Form Submitted',
3530
+ info: {
3531
+ formId: form.id,
3532
+ },
3533
+ conditions: {
3534
+ "$and": [
3535
+ {
3536
+ "condition": (_a = {},
3537
+ _a[field.id] = "trigger 2",
3538
+ _a)
3539
+ }
3540
+ ]
3541
+ },
3542
+ },
3543
+ action: { type: 'Add Tags', info: { tags: ['Equals'] } },
3544
+ status: 'Active',
3545
+ title: "Equals"
3546
+ })];
3547
+ case 11:
3548
+ equals = _j.sent();
3549
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3550
+ event: {
3551
+ type: 'Form Submitted',
3552
+ info: {
3553
+ formId: form.id,
3554
+ },
3555
+ conditions: {
3556
+ "$and": [
3557
+ {
3558
+ "condition": (_b = {},
3559
+ _b[field.id] = "tri",
3560
+ _b)
3561
+ }
3562
+ ]
3563
+ },
3564
+ },
3565
+ action: { type: 'Add Tags', info: { tags: ['No'] } },
3566
+ status: 'Active',
3567
+ title: "Equals False"
3568
+ })];
3569
+ case 12:
3570
+ equalsFalse = _j.sent();
3571
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3572
+ event: {
3573
+ type: 'Form Submitted',
3574
+ info: {
3575
+ formId: form.id,
3576
+ },
3577
+ conditions: {
3578
+ "$and": [
3579
+ {
3580
+ "condition": (_c = {},
3581
+ _c[field.id] = { $exists: true },
3582
+ _c)
3583
+ }
3584
+ ]
3585
+ },
3586
+ },
3587
+ action: { type: 'Add Tags', info: { tags: ['exists'] } },
3588
+ status: 'Active',
3589
+ title: "Exists true"
3590
+ })];
3591
+ case 13:
3592
+ existsTrue = _j.sent();
3593
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3594
+ event: {
3595
+ type: 'Form Submitted',
3596
+ info: {
3597
+ formId: form.id,
3598
+ },
3599
+ conditions: {
3600
+ "$and": [
3601
+ {
3602
+ "condition": (_d = {},
3603
+ _d[field.id] = { $exists: false },
3604
+ _d)
3605
+ }
3606
+ ]
3607
+ },
3608
+ },
3609
+ action: { type: 'Add Tags', info: { tags: ['No'] } },
3610
+ status: 'Active',
3611
+ title: "Exists False"
3612
+ })];
3613
+ case 14:
3614
+ existsFalse = _j.sent();
3615
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3616
+ event: {
3617
+ type: 'Form Submitted',
3618
+ info: {
3619
+ formId: form.id,
3620
+ },
3621
+ conditions: {
3622
+ "$and": [
3623
+ {
3624
+ "condition": (_e = {},
3625
+ _e[field.id] = {
3626
+ "$doesNotContain": "tri2"
3627
+ },
3628
+ _e)
3629
+ }
3630
+ ]
3631
+ },
3632
+ },
3633
+ action: { type: 'Add Tags', info: { tags: ['doesNotContain'] } },
3634
+ status: 'Active',
3635
+ title: "doesNotContainTrue"
3636
+ })];
3637
+ case 15:
3638
+ doesNotContainTrue = _j.sent();
3639
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3640
+ event: {
3641
+ type: 'Form Submitted',
3642
+ info: {
3643
+ formId: form.id,
3644
+ },
3645
+ conditions: {
3646
+ "$and": [
3647
+ {
3648
+ "condition": (_f = {},
3649
+ _f[field.id] = {
3650
+ "$doesNotContain": "tri"
3651
+ },
3652
+ _f)
3653
+ }
3654
+ ]
3655
+ },
3656
+ },
3657
+ action: { type: 'Add Tags', info: { tags: ['No'] } },
3658
+ status: 'Active',
3659
+ title: "doesNotContainFalse"
3660
+ })];
3661
+ case 16:
3662
+ doesNotContainFalse = _j.sent();
3663
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3664
+ event: {
3665
+ type: 'Form Submitted',
3666
+ info: {
3667
+ formId: form.id,
3668
+ },
3669
+ conditions: {
3670
+ "$and": [
3671
+ {
3672
+ "condition": (_g = {},
3673
+ _g[field.id] = {
3674
+ "$contains": "tri2"
3675
+ },
3676
+ _g)
3677
+ }
3678
+ ]
3679
+ },
3680
+ },
3681
+ action: { type: 'Add Tags', info: { tags: ['No'] } },
3682
+ status: 'Active',
3683
+ title: "containFalse"
3684
+ })];
3685
+ case 17:
3686
+ containFalse = _j.sent();
3687
+ return [4 /*yield*/, sdk.api.automation_triggers.createOne({
3688
+ event: {
3689
+ type: 'Form Submitted',
3690
+ info: {
3691
+ formId: form.id,
3692
+ },
3693
+ conditions: {
3694
+ "$and": [
3695
+ {
3696
+ "condition": (_h = {},
3697
+ _h[field.id] = {
3698
+ "$contains": "tri"
3699
+ },
3700
+ _h)
3701
+ }
3702
+ ]
3703
+ },
3704
+ },
3705
+ action: { type: 'Add Tags', info: { tags: ['contains'] } },
3706
+ status: 'Active',
3707
+ title: "containTrue"
3708
+ })];
3709
+ case 18:
3710
+ containTrue = _j.sent();
3513
3711
  return [4 /*yield*/, sdk.api.form_responses.prepare_form_response({
3514
3712
  enduserId: enduser.id,
3515
3713
  formId: form.id,
3516
3714
  })];
3517
- case 10:
3518
- accessCode = (_a.sent()).accessCode;
3715
+ case 19:
3716
+ accessCode = (_j.sent()).accessCode;
3519
3717
  return [4 /*yield*/, sdk.api.form_responses.submit_form_response({
3520
3718
  accessCode: accessCode,
3521
3719
  responses: [
@@ -3531,21 +3729,32 @@ var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, v
3531
3729
  })
3532
3730
  // allow triggers to happen
3533
3731
  ];
3534
- case 11:
3535
- _a.sent();
3732
+ case 20:
3733
+ _j.sent();
3536
3734
  // allow triggers to happen
3537
3735
  return [4 /*yield*/, wait(undefined, 1000)];
3538
- case 12:
3736
+ case 21:
3539
3737
  // allow triggers to happen
3540
- _a.sent();
3738
+ _j.sent();
3739
+ return [4 /*yield*/, async_test("Triggers with conditional works", function () { return sdk.api.endusers.getOne(enduser.id); }, { onResult: function (e) {
3740
+ var _a, _b, _c, _d, _e, _f;
3741
+ return !!(((_a = e.tags) === null || _a === void 0 ? void 0 : _a.includes('Equals'))
3742
+ && ((_b = e.tags) === null || _b === void 0 ? void 0 : _b.includes('contains'))
3743
+ && ((_c = e.tags) === null || _c === void 0 ? void 0 : _c.includes('exists'))
3744
+ && ((_d = e.tags) === null || _d === void 0 ? void 0 : _d.includes('No Conditions'))
3745
+ && ((_e = e.tags) === null || _e === void 0 ? void 0 : _e.includes('doesNotContain'))
3746
+ && !((_f = e.tags) === null || _f === void 0 ? void 0 : _f.includes('No')));
3747
+ } })];
3748
+ case 22:
3749
+ _j.sent();
3541
3750
  return [4 /*yield*/, async_test("Automated triggers work", function () { return sdk.api.endusers.getOne(enduser.id); }, { onResult: function (e) {
3542
3751
  var _a, _b, _c;
3543
3752
  return !!(((_a = e.journeys) === null || _a === void 0 ? void 0 : _a[journey1.id]) === ''
3544
3753
  && ((_b = e.journeys) === null || _b === void 0 ? void 0 : _b[journey2.id]) === ''
3545
3754
  && ((_c = e.journeys) === null || _c === void 0 ? void 0 : _c[journey3.id]) === undefined);
3546
3755
  } })];
3547
- case 13:
3548
- _a.sent();
3756
+ case 23:
3757
+ _j.sent();
3549
3758
  return [4 /*yield*/, Promise.all([
3550
3759
  sdk.api.journeys.deleteOne(journey1.id),
3551
3760
  sdk.api.journeys.deleteOne(journey2.id),
@@ -3555,9 +3764,18 @@ var formSubmittedTriggerTests = function () { return __awaiter(void 0, void 0, v
3555
3764
  sdk.api.automation_triggers.deleteOne(active.id),
3556
3765
  sdk.api.automation_triggers.deleteOne(dupActive.id),
3557
3766
  sdk.api.automation_triggers.deleteOne(inactive.id),
3767
+ sdk.api.automation_triggers.deleteOne(equals.id),
3768
+ sdk.api.automation_triggers.deleteOne(doesNotContainTrue.id),
3769
+ sdk.api.automation_triggers.deleteOne(containTrue.id),
3770
+ sdk.api.automation_triggers.deleteOne(noConditions.id),
3771
+ sdk.api.automation_triggers.deleteOne(existsTrue.id),
3772
+ sdk.api.automation_triggers.deleteOne(existsFalse.id),
3773
+ sdk.api.automation_triggers.deleteOne(containFalse.id),
3774
+ sdk.api.automation_triggers.deleteOne(equalsFalse.id),
3775
+ sdk.api.automation_triggers.deleteOne(doesNotContainFalse.id),
3558
3776
  ])];
3559
- case 14:
3560
- _a.sent();
3777
+ case 24:
3778
+ _j.sent();
3561
3779
  return [2 /*return*/];
3562
3780
  }
3563
3781
  });
@@ -5857,43 +6075,43 @@ var TRACK_OPEN_IMAGE = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwC
5857
6075
  return [4 /*yield*/, setup_tests()];
5858
6076
  case 7:
5859
6077
  _k.sent();
5860
- return [4 /*yield*/, enduser_session_tests()];
6078
+ return [4 /*yield*/, automation_trigger_tests()];
5861
6079
  case 8:
5862
6080
  _k.sent();
5863
- return [4 /*yield*/, nextReminderInMS_tests()];
6081
+ return [4 /*yield*/, enduser_session_tests()];
5864
6082
  case 9:
5865
6083
  _k.sent();
5866
- return [4 /*yield*/, search_tests()];
6084
+ return [4 /*yield*/, nextReminderInMS_tests()];
5867
6085
  case 10:
5868
6086
  _k.sent();
5869
- return [4 /*yield*/, wait_for_trigger_tests()];
6087
+ return [4 /*yield*/, search_tests()];
5870
6088
  case 11:
5871
6089
  _k.sent();
5872
- return [4 /*yield*/, role_based_access_tests()];
6090
+ return [4 /*yield*/, wait_for_trigger_tests()];
5873
6091
  case 12:
5874
6092
  _k.sent();
5875
- return [4 /*yield*/, multi_tenant_tests()]; // should come right after setup tests
6093
+ return [4 /*yield*/, role_based_access_tests()];
5876
6094
  case 13:
6095
+ _k.sent();
6096
+ return [4 /*yield*/, multi_tenant_tests()]; // should come right after setup tests
6097
+ case 14:
5877
6098
  _k.sent(); // should come right after setup tests
5878
6099
  return [4 /*yield*/, pdf_generation()];
5879
- case 14:
5880
- _k.sent();
5881
- return [4 /*yield*/, remove_from_journey_on_incoming_comms_tests()];
5882
6100
  case 15:
5883
6101
  _k.sent();
5884
- return [4 /*yield*/, rate_limit_tests()];
6102
+ return [4 /*yield*/, remove_from_journey_on_incoming_comms_tests()];
5885
6103
  case 16:
5886
6104
  _k.sent();
5887
- return [4 /*yield*/, merge_enduser_tests()];
6105
+ return [4 /*yield*/, rate_limit_tests()];
5888
6106
  case 17:
5889
6107
  _k.sent();
5890
- return [4 /*yield*/, self_serve_appointment_booking_tests()];
6108
+ return [4 /*yield*/, merge_enduser_tests()];
5891
6109
  case 18:
5892
6110
  _k.sent();
5893
- return [4 /*yield*/, auto_reply_tests()];
6111
+ return [4 /*yield*/, self_serve_appointment_booking_tests()];
5894
6112
  case 19:
5895
6113
  _k.sent();
5896
- return [4 /*yield*/, automation_trigger_tests()];
6114
+ return [4 /*yield*/, auto_reply_tests()];
5897
6115
  case 20:
5898
6116
  _k.sent();
5899
6117
  return [4 /*yield*/, sub_organization_enduser_tests()];