@bigbinary/neeto-rules-frontend 2.7.21 → 2.7.22
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.
|
@@ -463,6 +463,18 @@ var actionParts = function actionParts(_ref11) {
|
|
|
463
463
|
recipientSubtitle: channelMeta.recipientSubtitle || (option === null || option === void 0 ? void 0 : option.recipientSubtitle)
|
|
464
464
|
};
|
|
465
465
|
};
|
|
466
|
+
|
|
467
|
+
// Which condition fields a host offers can depend on the rule — a trigger may
|
|
468
|
+
// only support a subset. Lookups deliberately keep using the full list so a
|
|
469
|
+
// field already on the rule still resolves after the offer narrows.
|
|
470
|
+
var offeredConditionFields = function offeredConditionFields(_ref12) {
|
|
471
|
+
var _ref13, _schema$conditions$fi, _schema$conditions3, _schema$conditions3$f, _schema$conditions4;
|
|
472
|
+
var schema = _ref12.schema,
|
|
473
|
+
rule = _ref12.rule;
|
|
474
|
+
return (_ref13 = (_schema$conditions$fi = schema === null || schema === void 0 || (_schema$conditions3 = schema.conditions) === null || _schema$conditions3 === void 0 || (_schema$conditions3$f = _schema$conditions3.fieldsFor) === null || _schema$conditions3$f === void 0 ? void 0 : _schema$conditions3$f.call(_schema$conditions3, {
|
|
475
|
+
rule: rule
|
|
476
|
+
})) !== null && _schema$conditions$fi !== void 0 ? _schema$conditions$fi : schema === null || schema === void 0 || (_schema$conditions4 = schema.conditions) === null || _schema$conditions4 === void 0 ? void 0 : _schema$conditions4.fields) !== null && _ref13 !== void 0 ? _ref13 : [];
|
|
477
|
+
};
|
|
466
478
|
var hasTrigger = function hasTrigger(rule) {
|
|
467
479
|
return !isEmpty((rule === null || rule === void 0 ? void 0 : rule.triggers) || []);
|
|
468
480
|
};
|
|
@@ -474,28 +486,28 @@ var hasAction = function hasAction(rule) {
|
|
|
474
486
|
var isRuleComplete = function isRuleComplete(rule) {
|
|
475
487
|
return hasTrigger(rule) && hasAction(rule);
|
|
476
488
|
};
|
|
477
|
-
var scopeOptionFor = function scopeOptionFor(
|
|
489
|
+
var scopeOptionFor = function scopeOptionFor(_ref14) {
|
|
478
490
|
var _item$value, _schema$scope;
|
|
479
|
-
var schema =
|
|
480
|
-
item =
|
|
491
|
+
var schema = _ref14.schema,
|
|
492
|
+
item = _ref14.item;
|
|
481
493
|
var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
|
|
482
494
|
return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
|
|
483
495
|
var _candidate$value2;
|
|
484
496
|
return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
|
|
485
497
|
});
|
|
486
498
|
};
|
|
487
|
-
var scopePhoneFields = function scopePhoneFields(
|
|
488
|
-
var
|
|
489
|
-
var schema =
|
|
490
|
-
item =
|
|
491
|
-
return (
|
|
499
|
+
var scopePhoneFields = function scopePhoneFields(_ref15) {
|
|
500
|
+
var _ref16, _item$phoneFields, _scopeOptionFor;
|
|
501
|
+
var schema = _ref15.schema,
|
|
502
|
+
item = _ref15.item;
|
|
503
|
+
return (_ref16 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
|
|
492
504
|
schema: schema,
|
|
493
505
|
item: item
|
|
494
|
-
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null &&
|
|
506
|
+
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref16 !== void 0 ? _ref16 : null;
|
|
495
507
|
};
|
|
496
|
-
var effectiveScopePhoneField = function effectiveScopePhoneField(
|
|
497
|
-
var schema =
|
|
498
|
-
item =
|
|
508
|
+
var effectiveScopePhoneField = function effectiveScopePhoneField(_ref17) {
|
|
509
|
+
var schema = _ref17.schema,
|
|
510
|
+
item = _ref17.item;
|
|
499
511
|
if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
|
|
500
512
|
var phoneFields = scopePhoneFields({
|
|
501
513
|
schema: schema,
|
|
@@ -503,14 +515,14 @@ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
|
|
|
503
515
|
});
|
|
504
516
|
return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
|
|
505
517
|
};
|
|
506
|
-
var invalidScopeIndexes = function invalidScopeIndexes(
|
|
518
|
+
var invalidScopeIndexes = function invalidScopeIndexes(_ref18) {
|
|
507
519
|
var _scope$requiresPhone;
|
|
508
|
-
var rule =
|
|
509
|
-
schema =
|
|
520
|
+
var rule = _ref18.rule,
|
|
521
|
+
schema = _ref18.schema;
|
|
510
522
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
511
523
|
if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone = scope.requiresPhone) !== null && _scope$requiresPhone !== void 0 && _scope$requiresPhone.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
|
|
512
524
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
513
|
-
var
|
|
525
|
+
var _ref19, _item$hasPhoneField;
|
|
514
526
|
var option = scopeOptionFor({
|
|
515
527
|
schema: schema,
|
|
516
528
|
item: item
|
|
@@ -519,15 +531,15 @@ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
|
|
|
519
531
|
schema: schema,
|
|
520
532
|
item: item
|
|
521
533
|
});
|
|
522
|
-
var hasPhoneField = (
|
|
534
|
+
var hasPhoneField = (_ref19 = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField) !== null && _ref19 !== void 0 ? _ref19 : phoneFields ? phoneFields.length > 0 : undefined;
|
|
523
535
|
if (hasPhoneField === false) indexes.push(index);
|
|
524
536
|
return indexes;
|
|
525
537
|
}, []);
|
|
526
538
|
};
|
|
527
|
-
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(
|
|
539
|
+
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref20) {
|
|
528
540
|
var _scope$requiresPhone2;
|
|
529
|
-
var rule =
|
|
530
|
-
schema =
|
|
541
|
+
var rule = _ref20.rule,
|
|
542
|
+
schema = _ref20.schema;
|
|
531
543
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
532
544
|
if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone2 = scope.requiresPhone) !== null && _scope$requiresPhone2 !== void 0 && _scope$requiresPhone2.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
|
|
533
545
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
@@ -564,9 +576,9 @@ var minutesToParts = function minutesToParts(minutes) {
|
|
|
564
576
|
unit: "minutes"
|
|
565
577
|
};
|
|
566
578
|
};
|
|
567
|
-
var partsToMinutes = function partsToMinutes(
|
|
568
|
-
var value =
|
|
569
|
-
unit =
|
|
579
|
+
var partsToMinutes = function partsToMinutes(_ref21) {
|
|
580
|
+
var value = _ref21.value,
|
|
581
|
+
unit = _ref21.unit;
|
|
570
582
|
return (
|
|
571
583
|
// eslint-disable-next-line security/detect-object-injection
|
|
572
584
|
(Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
|
|
@@ -621,22 +633,22 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
|
|
|
621
633
|
};
|
|
622
634
|
|
|
623
635
|
// eslint-disable-next-line security/detect-object-injection
|
|
624
|
-
var valueAt = function valueAt(
|
|
636
|
+
var valueAt = function valueAt(_ref22) {
|
|
625
637
|
var _values$key;
|
|
626
|
-
var values =
|
|
627
|
-
key =
|
|
638
|
+
var values = _ref22.values,
|
|
639
|
+
key = _ref22.key;
|
|
628
640
|
return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
|
|
629
641
|
};
|
|
630
642
|
var asArray = function asArray(maybeArray) {
|
|
631
643
|
return Array.isArray(maybeArray) ? maybeArray : [];
|
|
632
644
|
};
|
|
633
645
|
var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
634
|
-
var _schema$triggers3, _schema$actor2, _schema$
|
|
646
|
+
var _schema$triggers3, _schema$actor2, _schema$conditions5, _schema$actions3, _schema$delay, _schema$triggers4, _schema$scope2;
|
|
635
647
|
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
636
648
|
return {
|
|
637
649
|
triggers: ((_schema$triggers3 = schema.triggers) === null || _schema$triggers3 === void 0 ? void 0 : _schema$triggers3.fieldKey) || "events",
|
|
638
650
|
performer: ((_schema$actor2 = schema.actor) === null || _schema$actor2 === void 0 ? void 0 : _schema$actor2.fieldKey) || "performer",
|
|
639
|
-
conditions: ((_schema$
|
|
651
|
+
conditions: ((_schema$conditions5 = schema.conditions) === null || _schema$conditions5 === void 0 ? void 0 : _schema$conditions5.fieldKey) || "conditions",
|
|
640
652
|
actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
|
|
641
653
|
delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
|
|
642
654
|
leadTime: (_schema$triggers4 = schema.triggers) === null || _schema$triggers4 === void 0 || (_schema$triggers4 = _schema$triggers4.leadTime) === null || _schema$triggers4 === void 0 ? void 0 : _schema$triggers4.fieldKey,
|
|
@@ -647,11 +659,11 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
|
647
659
|
};
|
|
648
660
|
var valuesToRuleModel = function valuesToRuleModel() {
|
|
649
661
|
var _valueAt, _conditions$;
|
|
650
|
-
var
|
|
651
|
-
|
|
652
|
-
values =
|
|
653
|
-
|
|
654
|
-
schema =
|
|
662
|
+
var _ref23 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
663
|
+
_ref23$values = _ref23.values,
|
|
664
|
+
values = _ref23$values === void 0 ? {} : _ref23$values,
|
|
665
|
+
_ref23$schema = _ref23.schema,
|
|
666
|
+
schema = _ref23$schema === void 0 ? {} : _ref23$schema;
|
|
655
667
|
var keys = fieldKeysFromSchema(schema);
|
|
656
668
|
var conditions = asArray(valueAt({
|
|
657
669
|
values: values,
|
|
@@ -695,42 +707,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
|
|
|
695
707
|
}))
|
|
696
708
|
};
|
|
697
709
|
};
|
|
698
|
-
var setTriggers = function setTriggers(
|
|
699
|
-
var schema =
|
|
700
|
-
triggers =
|
|
710
|
+
var setTriggers = function setTriggers(_ref24) {
|
|
711
|
+
var schema = _ref24.schema,
|
|
712
|
+
triggers = _ref24.triggers;
|
|
701
713
|
return {
|
|
702
714
|
path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
|
|
703
715
|
value: triggers
|
|
704
716
|
};
|
|
705
717
|
};
|
|
706
|
-
var setPerformer = function setPerformer(
|
|
707
|
-
var schema =
|
|
708
|
-
performer =
|
|
718
|
+
var setPerformer = function setPerformer(_ref25) {
|
|
719
|
+
var schema = _ref25.schema,
|
|
720
|
+
performer = _ref25.performer;
|
|
709
721
|
return {
|
|
710
722
|
path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
|
|
711
723
|
value: performer
|
|
712
724
|
};
|
|
713
725
|
};
|
|
714
|
-
var setActions = function setActions(
|
|
715
|
-
var schema =
|
|
716
|
-
actions =
|
|
726
|
+
var setActions = function setActions(_ref26) {
|
|
727
|
+
var schema = _ref26.schema,
|
|
728
|
+
actions = _ref26.actions;
|
|
717
729
|
return {
|
|
718
730
|
path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
|
|
719
731
|
value: actions
|
|
720
732
|
};
|
|
721
733
|
};
|
|
722
|
-
var setConditions = function setConditions(
|
|
723
|
-
var schema =
|
|
724
|
-
conditions =
|
|
734
|
+
var setConditions = function setConditions(_ref27) {
|
|
735
|
+
var schema = _ref27.schema,
|
|
736
|
+
conditions = _ref27.conditions;
|
|
725
737
|
return {
|
|
726
738
|
path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
|
|
727
739
|
value: conditions
|
|
728
740
|
};
|
|
729
741
|
};
|
|
730
|
-
var setConditionMode = function setConditionMode(
|
|
731
|
-
var schema =
|
|
732
|
-
conditions =
|
|
733
|
-
joinType =
|
|
742
|
+
var setConditionMode = function setConditionMode(_ref28) {
|
|
743
|
+
var schema = _ref28.schema,
|
|
744
|
+
conditions = _ref28.conditions,
|
|
745
|
+
joinType = _ref28.joinType;
|
|
734
746
|
return setConditions({
|
|
735
747
|
schema: schema,
|
|
736
748
|
conditions: conditions.map(function (condition) {
|
|
@@ -738,34 +750,34 @@ var setConditionMode = function setConditionMode(_ref26) {
|
|
|
738
750
|
})
|
|
739
751
|
});
|
|
740
752
|
};
|
|
741
|
-
var setDelay = function setDelay(
|
|
742
|
-
var schema =
|
|
743
|
-
delay =
|
|
753
|
+
var setDelay = function setDelay(_ref29) {
|
|
754
|
+
var schema = _ref29.schema,
|
|
755
|
+
delay = _ref29.delay;
|
|
744
756
|
return {
|
|
745
757
|
path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
|
|
746
758
|
value: delay !== null && delay !== void 0 ? delay : {}
|
|
747
759
|
};
|
|
748
760
|
};
|
|
749
|
-
var setActive = function setActive(
|
|
750
|
-
var schema =
|
|
751
|
-
active =
|
|
761
|
+
var setActive = function setActive(_ref30) {
|
|
762
|
+
var schema = _ref30.schema,
|
|
763
|
+
active = _ref30.active;
|
|
752
764
|
return {
|
|
753
765
|
path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
|
|
754
766
|
value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
|
|
755
767
|
};
|
|
756
768
|
};
|
|
757
|
-
var setScope = function setScope(
|
|
758
|
-
var schema =
|
|
759
|
-
scope =
|
|
769
|
+
var setScope = function setScope(_ref31) {
|
|
770
|
+
var schema = _ref31.schema,
|
|
771
|
+
scope = _ref31.scope;
|
|
760
772
|
return {
|
|
761
773
|
path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
|
|
762
774
|
value: scope
|
|
763
775
|
};
|
|
764
776
|
};
|
|
765
|
-
var removeArrayItem = function removeArrayItem(
|
|
766
|
-
var values =
|
|
767
|
-
fieldKey =
|
|
768
|
-
index =
|
|
777
|
+
var removeArrayItem = function removeArrayItem(_ref32) {
|
|
778
|
+
var values = _ref32.values,
|
|
779
|
+
fieldKey = _ref32.fieldKey,
|
|
780
|
+
index = _ref32.index;
|
|
769
781
|
var list = asArray(valueAt({
|
|
770
782
|
values: values,
|
|
771
783
|
key: fieldKey
|
|
@@ -792,9 +804,9 @@ var removeArrayItem = function removeArrayItem(_ref30) {
|
|
|
792
804
|
}
|
|
793
805
|
return result;
|
|
794
806
|
};
|
|
795
|
-
var clearArrayItems = function clearArrayItems(
|
|
796
|
-
var values =
|
|
797
|
-
fieldKey =
|
|
807
|
+
var clearArrayItems = function clearArrayItems(_ref33) {
|
|
808
|
+
var values = _ref33.values,
|
|
809
|
+
fieldKey = _ref33.fieldKey;
|
|
798
810
|
var list = asArray(valueAt({
|
|
799
811
|
values: values,
|
|
800
812
|
key: fieldKey
|
|
@@ -2216,7 +2228,7 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
|
|
|
2216
2228
|
});
|
|
2217
2229
|
};
|
|
2218
2230
|
var descriptorFor = function descriptorFor(_ref15) {
|
|
2219
|
-
var _schema$actor2
|
|
2231
|
+
var _schema$actor2;
|
|
2220
2232
|
var anchor = _ref15.anchor,
|
|
2221
2233
|
schema = _ref15.schema,
|
|
2222
2234
|
rule = _ref15.rule,
|
|
@@ -2262,7 +2274,10 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2262
2274
|
title: t("neetoRules.builder.panes.addCondition"),
|
|
2263
2275
|
subtitle: t("neetoRules.builder.panes.condFieldSubtitle"),
|
|
2264
2276
|
cascade: true,
|
|
2265
|
-
options: (
|
|
2277
|
+
options: offeredConditionFields({
|
|
2278
|
+
schema: schema,
|
|
2279
|
+
rule: rule
|
|
2280
|
+
}).map(function (field) {
|
|
2266
2281
|
return {
|
|
2267
2282
|
label: field.paneLabel || field.label,
|
|
2268
2283
|
value: optionValue(field),
|
|
@@ -2276,7 +2291,7 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2276
2291
|
};
|
|
2277
2292
|
case BUILDER_ANCHORS.COND_OP_TOGGLE:
|
|
2278
2293
|
{
|
|
2279
|
-
var _schema$
|
|
2294
|
+
var _schema$conditions2;
|
|
2280
2295
|
var field = findField({
|
|
2281
2296
|
schema: schema,
|
|
2282
2297
|
value: conditionAt({
|
|
@@ -2284,7 +2299,7 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2284
2299
|
index: index
|
|
2285
2300
|
}).field
|
|
2286
2301
|
});
|
|
2287
|
-
var labels = ((_schema$
|
|
2302
|
+
var labels = ((_schema$conditions2 = schema.conditions) === null || _schema$conditions2 === void 0 ? void 0 : _schema$conditions2.operatorLabels) || {};
|
|
2288
2303
|
var verbs = (field === null || field === void 0 ? void 0 : field.allowMatching) || [];
|
|
2289
2304
|
var fieldLabel = (field === null || field === void 0 ? void 0 : field.paneLabel) || (field === null || field === void 0 ? void 0 : field.label) || "";
|
|
2290
2305
|
var isContains = isNotEmpty(verbs) && verbs.every(isContainsVerb);
|
|
@@ -2767,7 +2782,7 @@ var applyPreview = function applyPreview(_ref19) {
|
|
|
2767
2782
|
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2768
2783
|
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2769
2784
|
var Canvas = function Canvas(_ref) {
|
|
2770
|
-
var _schema$scope, _schema$
|
|
2785
|
+
var _schema$scope, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2771
2786
|
var schema = _ref.schema;
|
|
2772
2787
|
var _useTranslation = useTranslation(),
|
|
2773
2788
|
t = _useTranslation.t;
|
|
@@ -3000,7 +3015,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
3000
3015
|
return i !== index;
|
|
3001
3016
|
}));
|
|
3002
3017
|
};
|
|
3003
|
-
var conditionFields = (
|
|
3018
|
+
var conditionFields = offeredConditionFields({
|
|
3019
|
+
schema: schema,
|
|
3020
|
+
rule: rule
|
|
3021
|
+
});
|
|
3004
3022
|
var canAddCondition = isNotEmpty(conditionFields);
|
|
3005
3023
|
var leadTimeAppliesTo = (schema === null || schema === void 0 || (_schema$triggers = schema.triggers) === null || _schema$triggers === void 0 || (_schema$triggers = _schema$triggers.leadTime) === null || _schema$triggers === void 0 ? void 0 : _schema$triggers.appliesTo) || [];
|
|
3006
3024
|
var hasLeadTimeTrigger = rule.triggers.some(function (trigger) {
|