@erxes/api-shared 3.2.21-1 → 3.2.22-1

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.
Files changed (29) hide show
  1. package/core-modules/dist/erxes-api-shared-core-modules.cjs.dev.js +512 -8
  2. package/core-modules/dist/erxes-api-shared-core-modules.cjs.prod.js +512 -8
  3. package/core-modules/dist/erxes-api-shared-core-modules.esm.js +507 -10
  4. package/dist/declarations/src/core-modules/automations/conditionals.d.ts +59 -0
  5. package/dist/declarations/src/core-modules/automations/conditionals.d.ts.map +1 -0
  6. package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts +10 -0
  7. package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts.map +1 -1
  8. package/dist/declarations/src/core-modules/automations/index.d.ts +1 -0
  9. package/dist/declarations/src/core-modules/automations/index.d.ts.map +1 -1
  10. package/dist/declarations/src/core-modules/automations/zodTypes.d.ts +40 -0
  11. package/dist/declarations/src/core-modules/automations/zodTypes.d.ts.map +1 -1
  12. package/dist/declarations/src/core-modules/common/eventHandlers/createEventHandlers.d.ts.map +1 -1
  13. package/dist/declarations/src/core-modules/segments/joinChanges.d.ts +5 -1
  14. package/dist/declarations/src/core-modules/segments/joinChanges.d.ts.map +1 -1
  15. package/dist/{start-plugin-a2f6eca9.esm.js → start-plugin-2b3e89f5.esm.js} +73 -59
  16. package/dist/{start-plugin-b095acca.cjs.prod.js → start-plugin-46baacee.cjs.prod.js} +73 -58
  17. package/dist/{start-plugin-7dc096bc.cjs.dev.js → start-plugin-6687b329.cjs.dev.js} +73 -58
  18. package/package.json +1 -1
  19. package/src/core-modules/automations/conditionals.test.ts +302 -0
  20. package/src/core-modules/automations/conditionals.ts +403 -0
  21. package/src/core-modules/automations/definitions/executions.ts +3 -0
  22. package/src/core-modules/automations/index.ts +1 -0
  23. package/src/core-modules/automations/zodTypes.ts +1 -0
  24. package/src/core-modules/common/eventHandlers/createEventHandlers.ts +20 -2
  25. package/src/core-modules/segments/joinChanges.test.ts +62 -0
  26. package/src/core-modules/segments/joinChanges.ts +26 -11
  27. package/utils/dist/erxes-api-shared-utils.cjs.dev.js +1 -1
  28. package/utils/dist/erxes-api-shared-utils.cjs.prod.js +1 -1
  29. package/utils/dist/erxes-api-shared-utils.esm.js +2 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var startPlugin = require('../../dist/start-plugin-b095acca.cjs.prod.js');
5
+ var startPlugin = require('../../dist/start-plugin-46baacee.cjs.prod.js');
6
6
  var dayjs = require('dayjs');
7
7
  require('node-fetch');
8
8
  var nanoid = require('nanoid');
@@ -543,7 +543,7 @@ var AUTOMATION_RETRY_LIMITS = {
543
543
  MIN_DELAY_SECONDS: 5,
544
544
  MAX_DELAY_SECONDS: 3600
545
545
  };
546
- var isRecord$1 = function isRecord(value) {
546
+ var isRecord$2 = function isRecord(value) {
547
547
  return startPlugin._typeof(value) === 'object' && value !== null;
548
548
  };
549
549
  var asActionId = function asActionId(value) {
@@ -566,8 +566,8 @@ var isBackoff = function isBackoff(value) {
566
566
  * never park an execution for longer than the ceiling allows.
567
567
  */
568
568
  var resolveActionErrorPolicy = function resolveActionErrorPolicy(config) {
569
- var policy = isRecord$1(config) && isRecord$1(config.errorPolicy) ? config.errorPolicy : {};
570
- var retry = isRecord$1(policy.retry) ? policy.retry : {};
569
+ var policy = isRecord$2(config) && isRecord$2(config.errorPolicy) ? config.errorPolicy : {};
570
+ var retry = isRecord$2(policy.retry) ? policy.retry : {};
571
571
  var MAX_ATTEMPTS = AUTOMATION_RETRY_LIMITS.MAX_ATTEMPTS,
572
572
  DEFAULT_DELAY_SECONDS = AUTOMATION_RETRY_LIMITS.DEFAULT_DELAY_SECONDS,
573
573
  MIN_DELAY_SECONDS = AUTOMATION_RETRY_LIMITS.MIN_DELAY_SECONDS,
@@ -585,7 +585,7 @@ var resolveActionErrorPolicy = function resolveActionErrorPolicy(config) {
585
585
  * the plain `nextActionId` is only read while the policy is off.
586
586
  */
587
587
  var resolveActionBranchTarget = function resolveActionBranchTarget(action, outcome) {
588
- var config = isRecord$1(action === null || action === void 0 ? void 0 : action.config) ? action.config : {};
588
+ var config = isRecord$2(action === null || action === void 0 ? void 0 : action.config) ? action.config : {};
589
589
  var branching = resolveActionErrorPolicy(config).onError === AUTOMATION_ERROR_BEHAVIOURS.BRANCH;
590
590
  if (!branching) {
591
591
  return outcome === 'success' ? action === null || action === void 0 ? void 0 : action.nextActionId : undefined;
@@ -637,7 +637,7 @@ var buildFailedAction = function buildFailedAction(message, code, result) {
637
637
  result: result
638
638
  };
639
639
  };
640
- var isRecord = function isRecord(value) {
640
+ var isRecord$1 = function isRecord(value) {
641
641
  return startPlugin._typeof(value) === 'object' && value !== null;
642
642
  };
643
643
  var isDeclaredStatus = function isDeclaredStatus(value) {
@@ -646,7 +646,7 @@ var isDeclaredStatus = function isDeclaredStatus(value) {
646
646
 
647
647
  /** For callers that forward an action's answer without reading it. */
648
648
  var isActionOutcomeEnvelope = function isActionOutcomeEnvelope(value) {
649
- return isRecord(value) && isRecord(value.outcome) && isDeclaredStatus(value.outcome.status);
649
+ return isRecord$1(value) && isRecord$1(value.outcome) && isDeclaredStatus(value.outcome.status);
650
650
  };
651
651
  var asString = function asString(value) {
652
652
  return typeof value === 'string' && value.trim() ? value.trim() : undefined;
@@ -661,7 +661,7 @@ var resolveActionOutcome = function resolveActionOutcome(actionResponse) {
661
661
  status: AUTOMATION_ACTION_OUTCOMES.SUCCESS,
662
662
  result: actionResponse
663
663
  };
664
- if (!isRecord(actionResponse) || !isRecord(actionResponse.outcome)) {
664
+ if (!isRecord$1(actionResponse) || !isRecord$1(actionResponse.outcome)) {
665
665
  return asSuccess;
666
666
  }
667
667
  var outcome = actionResponse.outcome,
@@ -783,6 +783,503 @@ var reEnrollmentRelationPaths = function reEnrollmentRelationPaths() {
783
783
  });
784
784
  };
785
785
 
786
+ /**
787
+ * A field whose value depends on the run holds a token instead of a value;
788
+ * the rules behind it live in the action config under this key. The engine
789
+ * swaps tokens for the first matching row before the action ever sees its
790
+ * config, so no action has to know conditionals exist.
791
+ */
792
+ var AUTOMATION_CONDITIONALS_KEY = '_conditionals';
793
+ var CONDITIONAL_TOKEN_REGEX = /^<<\s*cond:([A-Za-z0-9_-]+)\s*>>$/;
794
+ var formatConditionalToken = function formatConditionalToken(id) {
795
+ return "<< cond:".concat(id, " >>");
796
+ };
797
+
798
+ // The whole value must be the token, so text that merely mentions one is left alone
799
+ var parseConditionalToken = function parseConditionalToken(value) {
800
+ if (typeof value !== 'string') {
801
+ return null;
802
+ }
803
+ var match = value.match(CONDITIONAL_TOKEN_REGEX);
804
+ return match ? match[1] : null;
805
+ };
806
+ // Operators that test presence or truth and take no right-hand value
807
+ var AUTOMATION_UNARY_OPERATORS = ['is', 'ins', 'dateis', 'dateins', 'it', 'if'];
808
+ var isEmptyValue = function isEmptyValue(value) {
809
+ return value === undefined || value === null || value === '' || Array.isArray(value) && !value.length;
810
+ };
811
+ var normalizeDate = function normalizeDate(value) {
812
+ var date = value instanceof Date ? value : new Date(value);
813
+ return Number.isNaN(date.getTime()) ? null : date.getTime();
814
+ };
815
+ var compareDates = function compareDates(actual, expected, compare) {
816
+ var actualDate = normalizeDate(actual);
817
+ var expectedDate = normalizeDate(expected);
818
+ return actualDate !== null && expectedDate !== null ? compare(actualDate, expectedDate) : false;
819
+ };
820
+
821
+ /** Split and conditional values share one meaning per operator. */
822
+ var isAutomationConditionMatched = function isAutomationConditionMatched(actualValue, operator, expectedValue) {
823
+ switch (operator) {
824
+ case 'e':
825
+ return actualValue === expectedValue;
826
+ case 'numbere':
827
+ return Number(actualValue) === Number(expectedValue);
828
+ case 'dne':
829
+ return actualValue !== expectedValue;
830
+ case 'numberdne':
831
+ return Number(actualValue) !== Number(expectedValue);
832
+ case 'c':
833
+ return String(actualValue || '').toLowerCase().includes(String(expectedValue || '').toLowerCase());
834
+ case 'dnc':
835
+ return !String(actualValue || '').toLowerCase().includes(String(expectedValue || '').toLowerCase());
836
+ case 'it':
837
+ return actualValue === true;
838
+ case 'if':
839
+ return actualValue === false;
840
+ case 'is':
841
+ case 'dateis':
842
+ return !isEmptyValue(actualValue);
843
+ case 'ins':
844
+ case 'dateins':
845
+ return isEmptyValue(actualValue);
846
+ case 'numberigt':
847
+ return Number(actualValue) >= Number(expectedValue);
848
+ case 'numberilt':
849
+ return Number(actualValue) <= Number(expectedValue);
850
+ case 'dateigt':
851
+ return compareDates(actualValue, expectedValue, function (a, b) {
852
+ return a >= b;
853
+ });
854
+ case 'dateilt':
855
+ return compareDates(actualValue, expectedValue, function (a, b) {
856
+ return a <= b;
857
+ });
858
+ default:
859
+ return false;
860
+ }
861
+ };
862
+
863
+ /** Problems that keep a conditional from running; empty when it can. */
864
+ var validateAutomationConditional = function validateAutomationConditional(conditional) {
865
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
866
+ _ref$requiredKeys = _ref.requiredKeys,
867
+ requiredKeys = _ref$requiredKeys === void 0 ? [] : _ref$requiredKeys;
868
+ var errors = [];
869
+ if (!conditional.rows.length) {
870
+ errors.push('Add at least one condition row');
871
+ }
872
+ conditional.rows.forEach(function (row, rowIndex) {
873
+ var at = "Row ".concat(rowIndex + 1);
874
+ if (!row.conditions.length) {
875
+ errors.push("".concat(at, ": add at least one condition"));
876
+ }
877
+ row.conditions.forEach(function (condition, conditionIndex) {
878
+ var _condition$left;
879
+ var where = "".concat(at, ", condition ").concat(conditionIndex + 1);
880
+ if (condition.kind === 'segment') {
881
+ if (!condition.segmentId) {
882
+ errors.push("".concat(where, ": pick a segment"));
883
+ }
884
+ return;
885
+ }
886
+ if (!((_condition$left = condition.left) !== null && _condition$left !== void 0 && _condition$left.trim())) {
887
+ errors.push("".concat(where, ": pick a value to check"));
888
+ }
889
+ if (!condition.operator) {
890
+ errors.push("".concat(where, ": pick an operator"));
891
+ } else if (!AUTOMATION_UNARY_OPERATORS.includes(condition.operator) && isEmptyValue(condition.right)) {
892
+ errors.push("".concat(where, ": enter a value to compare with"));
893
+ }
894
+ });
895
+ var _iterator = startPlugin._createForOfIteratorHelper(conditional.keys),
896
+ _step;
897
+ try {
898
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
899
+ var _row$values;
900
+ var key = _step.value;
901
+ if (isEmptyValue((_row$values = row.values) === null || _row$values === void 0 ? void 0 : _row$values[key])) {
902
+ errors.push("".concat(at, ": set a value"));
903
+ break;
904
+ }
905
+ }
906
+ } catch (err) {
907
+ _iterator.e(err);
908
+ } finally {
909
+ _iterator.f();
910
+ }
911
+ });
912
+ var _iterator2 = startPlugin._createForOfIteratorHelper(requiredKeys),
913
+ _step2;
914
+ try {
915
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
916
+ var _conditional$otherwis;
917
+ var key = _step2.value;
918
+ if (isEmptyValue((_conditional$otherwis = conditional.otherwise) === null || _conditional$otherwis === void 0 ? void 0 : _conditional$otherwis[key])) {
919
+ errors.push('Otherwise: set a value');
920
+ break;
921
+ }
922
+ }
923
+ } catch (err) {
924
+ _iterator2.e(err);
925
+ } finally {
926
+ _iterator2.f();
927
+ }
928
+ return errors;
929
+ };
930
+ var conditionCacheKey = function conditionCacheKey(condition) {
931
+ var _condition$right;
932
+ return condition.kind === 'segment' ? "segment|".concat(condition.segmentId) : "value|".concat(condition.left, "|").concat(condition.operator, "|").concat((_condition$right = condition.right) !== null && _condition$right !== void 0 ? _condition$right : '');
933
+ };
934
+ // One answer per distinct condition for the whole action, however many
935
+ // fields repeat it
936
+ var createConditionEvaluator = function createConditionEvaluator(_ref2) {
937
+ var subdomain = _ref2.subdomain,
938
+ execution = _ref2.execution,
939
+ isInSegment = _ref2.isInSegment;
940
+ var answers = new Map();
941
+ var evaluate = /*#__PURE__*/function () {
942
+ var _ref3 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(condition) {
943
+ var _condition$right2;
944
+ var resolved;
945
+ return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
946
+ while (1) switch (_context.prev = _context.next) {
947
+ case 0:
948
+ if (!(condition.kind === 'segment')) {
949
+ _context.next = 2;
950
+ break;
951
+ }
952
+ return _context.abrupt("return", isInSegment(condition.segmentId));
953
+ case 2:
954
+ _context.next = 4;
955
+ return startPlugin.replaceOutputPlaceholders({
956
+ subdomain: subdomain,
957
+ execution: execution,
958
+ values: {
959
+ left: condition.left,
960
+ right: (_condition$right2 = condition.right) !== null && _condition$right2 !== void 0 ? _condition$right2 : ''
961
+ },
962
+ defaultValue: '',
963
+ keepUnresolvedPlaceholders: false
964
+ });
965
+ case 4:
966
+ resolved = _context.sent;
967
+ return _context.abrupt("return", isAutomationConditionMatched(resolved.left, condition.operator, resolved.right));
968
+ case 6:
969
+ case "end":
970
+ return _context.stop();
971
+ }
972
+ }, _callee);
973
+ }));
974
+ return function evaluate(_x) {
975
+ return _ref3.apply(this, arguments);
976
+ };
977
+ }();
978
+ return function (condition) {
979
+ var key = conditionCacheKey(condition);
980
+ if (!answers.has(key)) {
981
+ answers.set(key, evaluate(condition));
982
+ }
983
+ return answers.get(key);
984
+ };
985
+ };
986
+ var isRowMatched = /*#__PURE__*/function () {
987
+ var _ref4 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(row, evaluate) {
988
+ var _iterator3, _step3, _condition, _iterator4, _step4, _condition2;
989
+ return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
990
+ while (1) switch (_context2.prev = _context2.next) {
991
+ case 0:
992
+ if (row.conditions.length) {
993
+ _context2.next = 2;
994
+ break;
995
+ }
996
+ return _context2.abrupt("return", false);
997
+ case 2:
998
+ if (!(row.conjunction === 'or')) {
999
+ _context2.next = 23;
1000
+ break;
1001
+ }
1002
+ _iterator3 = startPlugin._createForOfIteratorHelper(row.conditions);
1003
+ _context2.prev = 4;
1004
+ _iterator3.s();
1005
+ case 6:
1006
+ if ((_step3 = _iterator3.n()).done) {
1007
+ _context2.next = 14;
1008
+ break;
1009
+ }
1010
+ _condition = _step3.value;
1011
+ _context2.next = 10;
1012
+ return evaluate(_condition);
1013
+ case 10:
1014
+ if (!_context2.sent) {
1015
+ _context2.next = 12;
1016
+ break;
1017
+ }
1018
+ return _context2.abrupt("return", true);
1019
+ case 12:
1020
+ _context2.next = 6;
1021
+ break;
1022
+ case 14:
1023
+ _context2.next = 19;
1024
+ break;
1025
+ case 16:
1026
+ _context2.prev = 16;
1027
+ _context2.t0 = _context2["catch"](4);
1028
+ _iterator3.e(_context2.t0);
1029
+ case 19:
1030
+ _context2.prev = 19;
1031
+ _iterator3.f();
1032
+ return _context2.finish(19);
1033
+ case 22:
1034
+ return _context2.abrupt("return", false);
1035
+ case 23:
1036
+ _iterator4 = startPlugin._createForOfIteratorHelper(row.conditions);
1037
+ _context2.prev = 24;
1038
+ _iterator4.s();
1039
+ case 26:
1040
+ if ((_step4 = _iterator4.n()).done) {
1041
+ _context2.next = 34;
1042
+ break;
1043
+ }
1044
+ _condition2 = _step4.value;
1045
+ _context2.next = 30;
1046
+ return evaluate(_condition2);
1047
+ case 30:
1048
+ if (_context2.sent) {
1049
+ _context2.next = 32;
1050
+ break;
1051
+ }
1052
+ return _context2.abrupt("return", false);
1053
+ case 32:
1054
+ _context2.next = 26;
1055
+ break;
1056
+ case 34:
1057
+ _context2.next = 39;
1058
+ break;
1059
+ case 36:
1060
+ _context2.prev = 36;
1061
+ _context2.t1 = _context2["catch"](24);
1062
+ _iterator4.e(_context2.t1);
1063
+ case 39:
1064
+ _context2.prev = 39;
1065
+ _iterator4.f();
1066
+ return _context2.finish(39);
1067
+ case 42:
1068
+ return _context2.abrupt("return", true);
1069
+ case 43:
1070
+ case "end":
1071
+ return _context2.stop();
1072
+ }
1073
+ }, _callee2, null, [[4, 16, 19, 22], [24, 36, 39, 42]]);
1074
+ }));
1075
+ return function isRowMatched(_x2, _x3) {
1076
+ return _ref4.apply(this, arguments);
1077
+ };
1078
+ }();
1079
+ var isRecord = function isRecord(value) {
1080
+ return startPlugin._typeof(value) === 'object' && value !== null && !Array.isArray(value);
1081
+ };
1082
+
1083
+ /**
1084
+ * Returns the config the action should run with: every token replaced by its
1085
+ * first matching row (or otherwise), the conditionals key removed, and which
1086
+ * row each conditional used. Tokens without a conditional are reported, never
1087
+ * passed through as text.
1088
+ */
1089
+ var applyAutomationConditionals = /*#__PURE__*/function () {
1090
+ var _ref6 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee5(_ref5) {
1091
+ var subdomain, execution, config, isInSegment, _ref7, rawConditionals, rest, conditionals, evaluate, matches, missing, chosenById, choose, _walk;
1092
+ return startPlugin._regeneratorRuntime().wrap(function _callee5$(_context6) {
1093
+ while (1) switch (_context6.prev = _context6.next) {
1094
+ case 0:
1095
+ subdomain = _ref5.subdomain, execution = _ref5.execution, config = _ref5.config, isInSegment = _ref5.isInSegment;
1096
+ _ref7 = config || {}, rawConditionals = _ref7[AUTOMATION_CONDITIONALS_KEY], rest = startPlugin._objectWithoutProperties(_ref7, [AUTOMATION_CONDITIONALS_KEY].map(startPlugin._toPropertyKey));
1097
+ conditionals = isRecord(rawConditionals) ? rawConditionals : {};
1098
+ evaluate = createConditionEvaluator({
1099
+ subdomain: subdomain,
1100
+ execution: execution,
1101
+ isInSegment: isInSegment
1102
+ });
1103
+ matches = {};
1104
+ missing = [];
1105
+ chosenById = new Map();
1106
+ choose = /*#__PURE__*/function () {
1107
+ var _ref8 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3(id, conditional) {
1108
+ var chosen, _iterator5, _step5, row;
1109
+ return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
1110
+ while (1) switch (_context3.prev = _context3.next) {
1111
+ case 0:
1112
+ if (chosenById.has(id)) {
1113
+ _context3.next = 24;
1114
+ break;
1115
+ }
1116
+ chosen = {
1117
+ rowId: 'otherwise',
1118
+ values: conditional.otherwise || {}
1119
+ };
1120
+ _iterator5 = startPlugin._createForOfIteratorHelper(conditional.rows || []);
1121
+ _context3.prev = 3;
1122
+ _iterator5.s();
1123
+ case 5:
1124
+ if ((_step5 = _iterator5.n()).done) {
1125
+ _context3.next = 14;
1126
+ break;
1127
+ }
1128
+ row = _step5.value;
1129
+ _context3.next = 9;
1130
+ return isRowMatched(row, evaluate);
1131
+ case 9:
1132
+ if (!_context3.sent) {
1133
+ _context3.next = 12;
1134
+ break;
1135
+ }
1136
+ chosen = {
1137
+ rowId: row.id,
1138
+ values: row.values || {}
1139
+ };
1140
+ return _context3.abrupt("break", 14);
1141
+ case 12:
1142
+ _context3.next = 5;
1143
+ break;
1144
+ case 14:
1145
+ _context3.next = 19;
1146
+ break;
1147
+ case 16:
1148
+ _context3.prev = 16;
1149
+ _context3.t0 = _context3["catch"](3);
1150
+ _iterator5.e(_context3.t0);
1151
+ case 19:
1152
+ _context3.prev = 19;
1153
+ _iterator5.f();
1154
+ return _context3.finish(19);
1155
+ case 22:
1156
+ matches[id] = chosen.rowId;
1157
+ chosenById.set(id, startPlugin._objectSpread2(startPlugin._objectSpread2({}, conditional.otherwise || {}), chosen.values));
1158
+ case 24:
1159
+ return _context3.abrupt("return", chosenById.get(id));
1160
+ case 25:
1161
+ case "end":
1162
+ return _context3.stop();
1163
+ }
1164
+ }, _callee3, null, [[3, 16, 19, 22]]);
1165
+ }));
1166
+ return function choose(_x5, _x6) {
1167
+ return _ref8.apply(this, arguments);
1168
+ };
1169
+ }();
1170
+ _walk = /*#__PURE__*/function () {
1171
+ var _ref9 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee4(node) {
1172
+ var next, patches, _loop, _ret, _i, _Object$entries;
1173
+ return startPlugin._regeneratorRuntime().wrap(function _callee4$(_context5) {
1174
+ while (1) switch (_context5.prev = _context5.next) {
1175
+ case 0:
1176
+ if (!Array.isArray(node)) {
1177
+ _context5.next = 2;
1178
+ break;
1179
+ }
1180
+ return _context5.abrupt("return", Promise.all(node.map(_walk)));
1181
+ case 2:
1182
+ if (isRecord(node)) {
1183
+ _context5.next = 4;
1184
+ break;
1185
+ }
1186
+ return _context5.abrupt("return", node);
1187
+ case 4:
1188
+ next = {};
1189
+ patches = [];
1190
+ _loop = /*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _loop() {
1191
+ var _conditional$keys;
1192
+ var _Object$entries$_i, key, value, id, conditional, chosen, keys;
1193
+ return startPlugin._regeneratorRuntime().wrap(function _loop$(_context4) {
1194
+ while (1) switch (_context4.prev = _context4.next) {
1195
+ case 0:
1196
+ _Object$entries$_i = startPlugin._slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
1197
+ id = parseConditionalToken(value);
1198
+ if (id) {
1199
+ _context4.next = 7;
1200
+ break;
1201
+ }
1202
+ _context4.next = 5;
1203
+ return _walk(value);
1204
+ case 5:
1205
+ next[key] = _context4.sent;
1206
+ return _context4.abrupt("return", 0);
1207
+ case 7:
1208
+ conditional = conditionals[id];
1209
+ if (conditional) {
1210
+ _context4.next = 12;
1211
+ break;
1212
+ }
1213
+ missing.push(id);
1214
+ next[key] = '';
1215
+ return _context4.abrupt("return", 0);
1216
+ case 12:
1217
+ _context4.next = 14;
1218
+ return choose(id, conditional);
1219
+ case 14:
1220
+ chosen = _context4.sent;
1221
+ keys = (_conditional$keys = conditional.keys) !== null && _conditional$keys !== void 0 && _conditional$keys.length ? conditional.keys : [key];
1222
+ patches.push(Object.fromEntries(keys.map(function (patchKey) {
1223
+ return [patchKey, chosen[patchKey]];
1224
+ })));
1225
+ case 17:
1226
+ case "end":
1227
+ return _context4.stop();
1228
+ }
1229
+ }, _loop);
1230
+ });
1231
+ _i = 0, _Object$entries = Object.entries(node);
1232
+ case 8:
1233
+ if (!(_i < _Object$entries.length)) {
1234
+ _context5.next = 16;
1235
+ break;
1236
+ }
1237
+ return _context5.delegateYield(_loop(), "t0", 10);
1238
+ case 10:
1239
+ _ret = _context5.t0;
1240
+ if (!(_ret === 0)) {
1241
+ _context5.next = 13;
1242
+ break;
1243
+ }
1244
+ return _context5.abrupt("continue", 13);
1245
+ case 13:
1246
+ _i++;
1247
+ _context5.next = 8;
1248
+ break;
1249
+ case 16:
1250
+ return _context5.abrupt("return", Object.assign.apply(Object, [next].concat(patches)));
1251
+ case 17:
1252
+ case "end":
1253
+ return _context5.stop();
1254
+ }
1255
+ }, _callee4);
1256
+ }));
1257
+ return function walk(_x7) {
1258
+ return _ref9.apply(this, arguments);
1259
+ };
1260
+ }();
1261
+ _context6.next = 11;
1262
+ return _walk(rest);
1263
+ case 11:
1264
+ _context6.t0 = _context6.sent;
1265
+ _context6.t1 = matches;
1266
+ _context6.t2 = missing;
1267
+ return _context6.abrupt("return", {
1268
+ config: _context6.t0,
1269
+ matches: _context6.t1,
1270
+ missing: _context6.t2
1271
+ });
1272
+ case 15:
1273
+ case "end":
1274
+ return _context6.stop();
1275
+ }
1276
+ }, _callee5);
1277
+ }));
1278
+ return function applyAutomationConditionals(_x4) {
1279
+ return _ref6.apply(this, arguments);
1280
+ };
1281
+ }();
1282
+
786
1283
  var userActionsMap = /*#__PURE__*/function () {
787
1284
  var _ref = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(userPermissions, groupPermissions, user) {
788
1285
  var totalPermissions, allowedActions, check, _iterator, _step, _step$value, requiredActions, allowed, action, _iterator2, _step2, actionName;
@@ -6582,6 +7079,7 @@ exports.zonedDayStart = startPlugin.zonedDayStart;
6582
7079
  exports.zonedPeriodRange = startPlugin.zonedPeriodRange;
6583
7080
  exports.AUTOMATION_ACTION_OUTCOMES = AUTOMATION_ACTION_OUTCOMES;
6584
7081
  exports.AUTOMATION_BRANCH_KEYS = AUTOMATION_BRANCH_KEYS;
7082
+ exports.AUTOMATION_CONDITIONALS_KEY = AUTOMATION_CONDITIONALS_KEY;
6585
7083
  exports.AUTOMATION_ERROR_BEHAVIOURS = AUTOMATION_ERROR_BEHAVIOURS;
6586
7084
  exports.AUTOMATION_RETRY_BACKOFFS = AUTOMATION_RETRY_BACKOFFS;
6587
7085
  exports.AUTOMATION_RETRY_LIMITS = AUTOMATION_RETRY_LIMITS;
@@ -6589,6 +7087,7 @@ exports.AUTOMATION_RE_ENROLL_EVERY_TIME = AUTOMATION_RE_ENROLL_EVERY_TIME;
6589
7087
  exports.AUTOMATION_RE_ENROLL_RELATION_PREFIX = AUTOMATION_RE_ENROLL_RELATION_PREFIX;
6590
7088
  exports.AUTOMATION_SEGMENT_MEMBERSHIP_EVENT = AUTOMATION_SEGMENT_MEMBERSHIP_EVENT;
6591
7089
  exports.AUTOMATION_SEGMENT_MEMBERSHIP_FOLKS = AUTOMATION_SEGMENT_MEMBERSHIP_FOLKS;
7090
+ exports.AUTOMATION_UNARY_OPERATORS = AUTOMATION_UNARY_OPERATORS;
6592
7091
  exports.COLORS_DEFAULT = COLORS_DEFAULT;
6593
7092
  exports.DEFAULT_SEGMENT_PAGE_SIZE = DEFAULT_SEGMENT_PAGE_SIZE;
6594
7093
  exports.EMAIL_CONTENT_FORMATS = EMAIL_CONTENT_FORMATS;
@@ -6601,6 +7100,7 @@ exports.TemplateManager = TemplateManager;
6601
7100
  exports.actionRetryDelayMs = actionRetryDelayMs;
6602
7101
  exports.activityBuilder = activityBuilder;
6603
7102
  exports.appendUnsubscribeFooter = appendUnsubscribeFooter;
7103
+ exports.applyAutomationConditionals = applyAutomationConditionals;
6604
7104
  exports.applySegmentMembership = applySegmentMembership;
6605
7105
  exports.assignmentRule = assignmentRule;
6606
7106
  exports.blocksToHtml = blocksToHtml;
@@ -6635,12 +7135,14 @@ exports.expandRepeatRows = expandRepeatRows;
6635
7135
  exports.featuredFieldCode = featuredFieldCode;
6636
7136
  exports.fieldChangeRule = fieldChangeRule;
6637
7137
  exports.findUnresolvedPlaceholders = findUnresolvedPlaceholders;
7138
+ exports.formatConditionalToken = formatConditionalToken;
6638
7139
  exports.gatherAssociatedTypes = gatherAssociatedTypes;
6639
7140
  exports.gatherDependentServicesType = gatherDependentServicesType;
6640
7141
  exports.generateFieldsFromSchema = generateFieldsFromSchema;
6641
7142
  exports.getRecordReferenceFields = getRecordReferenceFields;
6642
7143
  exports.getUserActionsMap = getUserActionsMap;
6643
7144
  exports.isActionOutcomeEnvelope = isActionOutcomeEnvelope;
7145
+ exports.isAutomationConditionMatched = isAutomationConditionMatched;
6644
7146
  exports.isPropertyFilterOperator = isPropertyFilterOperator;
6645
7147
  exports.isSegmentMembershipTrigger = isSegmentMembershipTrigger;
6646
7148
  exports.measureSegmentRelations = measureSegmentRelations;
@@ -6649,6 +7151,7 @@ exports.mergePropertyData = mergePropertyData;
6649
7151
  exports.namespacePaths = namespacePaths;
6650
7152
  exports.normalizeDiffs = normalizeDiffs;
6651
7153
  exports.normalizeExportLimit = normalizeExportLimit;
7154
+ exports.parseConditionalToken = parseConditionalToken;
6652
7155
  exports.parsePropertyFilterConditions = parsePropertyFilterConditions;
6653
7156
  exports.planValueRefs = planValueRefs;
6654
7157
  exports.projectionForRequests = projectionForRequests;
@@ -6682,4 +7185,5 @@ exports.sendSegmentMaterialized = sendSegmentMaterialized;
6682
7185
  exports.sendSegmentMembershipToAutomations = sendSegmentMembershipToAutomations;
6683
7186
  exports.splitSegmentFieldRequests = splitSegmentFieldRequests;
6684
7187
  exports.userActionsMap = userActionsMap;
7188
+ exports.validateAutomationConditional = validateAutomationConditional;
6685
7189
  exports.validateWorkflowBindings = validateWorkflowBindings;