@media-quest/builder 0.0.2 → 0.0.4
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.
- package/dist/public-api.d.mts +35 -11
- package/dist/public-api.d.ts +35 -11
- package/dist/public-api.js +455 -47
- package/dist/public-api.mjs +427 -37
- package/package.json +3 -4
- package/src/Builder-option.ts +51 -52
- package/src/Builder-schema.ts +1 -0
- package/src/public-api.ts +3 -0
- package/src/rulebuilder/Builder-rule.spec.ts +266 -182
- package/src/rulebuilder/Builder-rule.ts +106 -67
- package/src/rulebuilder/Rule2.ts +87 -0
- package/src/rulebuilder/RuleBuilder-test-utils.ts +250 -239
- package/src/rulebuilder/RuleVariable.ts +13 -9
- package/src/rulebuilder/SingleSelectItem.ts +118 -118
- package/src/rulebuilder/{Builder-condition-group.ts → condition/Builder-condition-group.ts} +42 -33
- package/src/rulebuilder/condition/Builder-condition.spec.ts +185 -0
- package/src/rulebuilder/condition/Builder-condition.ts +208 -0
- package/src/rulebuilder/index.ts +11 -11
- package/src/rulebuilder/jump-to-action-manager.ts +26 -26
- package/src/rulebuilder/page-action-manager.ts +23 -13
- package/src/rulebuilder/tag-action-manager.ts +23 -13
- package/src/theme/default-theme-compiler.ts +26 -1
- package/src/rulebuilder/Builder-condition.spec.ts +0 -169
- package/src/rulebuilder/Builder-condition.ts +0 -186
- /package/src/rulebuilder/{Builder-condition-group.spec.ts → condition/Builder-condition-group.spec.ts} +0 -0
- /package/src/rulebuilder/{Builder-operator.spec.ts → condition/Builder-operator.spec.ts} +0 -0
- /package/src/rulebuilder/{Builder-operator.ts → condition/Builder-operator.ts} +0 -0
package/dist/public-api.js
CHANGED
|
@@ -20,13 +20,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/public-api.ts
|
|
21
21
|
var public_api_exports = {};
|
|
22
22
|
__export(public_api_exports, {
|
|
23
|
+
BuilderCondition: () => BuilderCondition,
|
|
24
|
+
BuilderConditionGroup: () => BuilderConditionGroup,
|
|
23
25
|
BuilderMainText: () => BuilderMainText,
|
|
26
|
+
BuilderOperator: () => BuilderOperator,
|
|
24
27
|
BuilderOption: () => BuilderOption,
|
|
25
28
|
BuilderPage: () => BuilderPage,
|
|
26
29
|
BuilderQuestion: () => BuilderQuestion,
|
|
30
|
+
BuilderRule: () => BuilderRule,
|
|
27
31
|
BuilderSchema: () => BuilderSchema,
|
|
28
32
|
BuilderTag: () => BuilderTag,
|
|
29
33
|
BuilderText: () => BuilderText,
|
|
34
|
+
BuilderVariableOption: () => BuilderVariableOption,
|
|
35
|
+
CustomVariable: () => CustomVariable,
|
|
36
|
+
ExcludeByPageIdSelectItem: () => ExcludeByPageIdSelectItem,
|
|
37
|
+
ExcludeByTagSelectItem: () => ExcludeByTagSelectItem,
|
|
38
|
+
JumpToActionManager: () => JumpToActionManager,
|
|
39
|
+
JumpToPageSelectItem: () => JumpToPageSelectItem,
|
|
40
|
+
MultiSelectItem: () => MultiSelectItem,
|
|
41
|
+
OperatorSelectItem: () => OperatorSelectItem,
|
|
42
|
+
PageActionManager: () => PageActionManager,
|
|
43
|
+
QuestionVariable: () => QuestionVariable,
|
|
44
|
+
RuleInput: () => RuleInput,
|
|
45
|
+
RuleOptionSelectItem: () => RuleOptionSelectItem,
|
|
46
|
+
RuleVariableSelectItem: () => RuleVariableSelectItem,
|
|
47
|
+
SingleSelectItem: () => SingleSelectItem,
|
|
48
|
+
TagActionManager: () => TagActionManager,
|
|
30
49
|
TagCollection: () => TagCollection
|
|
31
50
|
});
|
|
32
51
|
module.exports = __toCommonJS(public_api_exports);
|
|
@@ -412,6 +431,15 @@ var QuestionVariable = class {
|
|
|
412
431
|
kind = "question-variable";
|
|
413
432
|
dataType = "numericWithOptions";
|
|
414
433
|
};
|
|
434
|
+
var CustomVariable = class {
|
|
435
|
+
constructor(varId, label, options) {
|
|
436
|
+
this.varId = varId;
|
|
437
|
+
this.label = label;
|
|
438
|
+
this.options = options;
|
|
439
|
+
}
|
|
440
|
+
kind = "configuration-variable";
|
|
441
|
+
dataType = "numericWithOptions";
|
|
442
|
+
};
|
|
415
443
|
|
|
416
444
|
// src/Builder-page.ts
|
|
417
445
|
var import_engine2 = require("@media-quest/engine");
|
|
@@ -840,7 +868,7 @@ var TagCollection = class _TagCollection {
|
|
|
840
868
|
}
|
|
841
869
|
};
|
|
842
870
|
|
|
843
|
-
// src/rulebuilder/Builder-operator.ts
|
|
871
|
+
// src/rulebuilder/condition/Builder-operator.ts
|
|
844
872
|
var BuilderOperatorSymbols = {
|
|
845
873
|
equal: true,
|
|
846
874
|
notEqual: true,
|
|
@@ -871,7 +899,7 @@ var BuilderOperator;
|
|
|
871
899
|
};
|
|
872
900
|
})(BuilderOperator || (BuilderOperator = {}));
|
|
873
901
|
|
|
874
|
-
// src/rulebuilder/Builder-condition.ts
|
|
902
|
+
// src/rulebuilder/condition/Builder-condition.ts
|
|
875
903
|
var BuilderCondition = class _BuilderCondition extends BuilderObject {
|
|
876
904
|
objectType = "builder-condition";
|
|
877
905
|
static NUMBER_OPERATORS = [
|
|
@@ -953,6 +981,29 @@ var BuilderCondition = class _BuilderCondition extends BuilderObject {
|
|
|
953
981
|
}
|
|
954
982
|
return { isValid: true };
|
|
955
983
|
}
|
|
984
|
+
toEngineCondition() {
|
|
985
|
+
const val = this.value;
|
|
986
|
+
const op = this._operator;
|
|
987
|
+
const v = this._variable;
|
|
988
|
+
if (!val)
|
|
989
|
+
return false;
|
|
990
|
+
if (!op)
|
|
991
|
+
return false;
|
|
992
|
+
if (!v)
|
|
993
|
+
return false;
|
|
994
|
+
if (op === "equal") {
|
|
995
|
+
const engineCondition = {
|
|
996
|
+
kind: "numeric-condition",
|
|
997
|
+
value: val.value,
|
|
998
|
+
valueLabel: val.label,
|
|
999
|
+
referenceId: v.varId,
|
|
1000
|
+
referenceLabel: v.label,
|
|
1001
|
+
operator: "eq"
|
|
1002
|
+
};
|
|
1003
|
+
return engineCondition;
|
|
1004
|
+
}
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
956
1007
|
findVariableInUniverse(variableId) {
|
|
957
1008
|
const v = this._variableList.find((v2) => v2.varId === variableId);
|
|
958
1009
|
return v ?? false;
|
|
@@ -1026,7 +1077,7 @@ var BuilderCondition = class _BuilderCondition extends BuilderObject {
|
|
|
1026
1077
|
}
|
|
1027
1078
|
};
|
|
1028
1079
|
|
|
1029
|
-
// src/rulebuilder/Builder-condition-group.ts
|
|
1080
|
+
// src/rulebuilder/condition/Builder-condition-group.ts
|
|
1030
1081
|
var ConditionGroupType = {
|
|
1031
1082
|
all: true,
|
|
1032
1083
|
any: true,
|
|
@@ -1054,9 +1105,7 @@ var BuilderConditionGroup = class _BuilderConditionGroup extends BuilderObject {
|
|
|
1054
1105
|
this.name = dto.name;
|
|
1055
1106
|
this._type = dto.type;
|
|
1056
1107
|
const conditionList = Array.isArray(dto.conditions) ? dto.conditions : [];
|
|
1057
|
-
this._conditions = conditionList.map(
|
|
1058
|
-
(dto2) => BuilderCondition.fromDto(dto2, variableList)
|
|
1059
|
-
);
|
|
1108
|
+
this._conditions = conditionList.map((dto2) => BuilderCondition.fromDto(dto2, variableList));
|
|
1060
1109
|
this._variableList = variableList;
|
|
1061
1110
|
}
|
|
1062
1111
|
get conditions() {
|
|
@@ -1082,9 +1131,7 @@ var BuilderConditionGroup = class _BuilderConditionGroup extends BuilderObject {
|
|
|
1082
1131
|
return this.toJson();
|
|
1083
1132
|
}
|
|
1084
1133
|
toJson() {
|
|
1085
|
-
const conditions = [
|
|
1086
|
-
...this._conditions.map((c) => c.toJson())
|
|
1087
|
-
];
|
|
1134
|
+
const conditions = [...this._conditions.map((c) => c.toJson())];
|
|
1088
1135
|
return {
|
|
1089
1136
|
name: this.name,
|
|
1090
1137
|
conditions,
|
|
@@ -1092,6 +1139,29 @@ var BuilderConditionGroup = class _BuilderConditionGroup extends BuilderObject {
|
|
|
1092
1139
|
kind: "condition-group"
|
|
1093
1140
|
};
|
|
1094
1141
|
}
|
|
1142
|
+
toEngineConditionComplex() {
|
|
1143
|
+
const comp = {
|
|
1144
|
+
kind: "complex-condition",
|
|
1145
|
+
all: [],
|
|
1146
|
+
some: [],
|
|
1147
|
+
name: ""
|
|
1148
|
+
};
|
|
1149
|
+
const conditions = [];
|
|
1150
|
+
this.conditions.forEach((c) => {
|
|
1151
|
+
const maybeSimple = c.toEngineCondition();
|
|
1152
|
+
if (maybeSimple) {
|
|
1153
|
+
conditions.push(maybeSimple);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
if (this._type === "all") {
|
|
1157
|
+
return { ...comp, all: conditions };
|
|
1158
|
+
}
|
|
1159
|
+
if (this._type === "any") {
|
|
1160
|
+
return { ...comp, some: conditions };
|
|
1161
|
+
}
|
|
1162
|
+
console.log("INVALID COMPLEX CONDITION. TODO IMPLEMENT range, and count.");
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1095
1165
|
get type() {
|
|
1096
1166
|
return this._type;
|
|
1097
1167
|
}
|
|
@@ -1179,6 +1249,11 @@ var TagActionManager = class {
|
|
|
1179
1249
|
const selected = this.selectItems.filter((item) => item.isSelected).map((itm) => itm.data.tag);
|
|
1180
1250
|
return selected;
|
|
1181
1251
|
}
|
|
1252
|
+
getEngineActions() {
|
|
1253
|
+
const selected = this.selectItems.filter((item) => item.isSelected);
|
|
1254
|
+
const tagActions = selected.map((s) => s.data);
|
|
1255
|
+
return [...tagActions];
|
|
1256
|
+
}
|
|
1182
1257
|
};
|
|
1183
1258
|
|
|
1184
1259
|
// src/rulebuilder/page-action-manager.ts
|
|
@@ -1198,6 +1273,11 @@ var PageActionManager = class {
|
|
|
1198
1273
|
const selected = this.selectItems.filter((item) => item.isSelected).map((itm) => itm.data.pageId);
|
|
1199
1274
|
return selected;
|
|
1200
1275
|
}
|
|
1276
|
+
getEngineAction() {
|
|
1277
|
+
const selectItems = this.selectItems.filter((item) => item.isSelected);
|
|
1278
|
+
const actions = selectItems.map((item) => item.data);
|
|
1279
|
+
return [...actions];
|
|
1280
|
+
}
|
|
1201
1281
|
};
|
|
1202
1282
|
|
|
1203
1283
|
// src/rulebuilder/jump-to-action-manager.ts
|
|
@@ -1232,6 +1312,248 @@ var JumpToActionManager = class {
|
|
|
1232
1312
|
}
|
|
1233
1313
|
};
|
|
1234
1314
|
|
|
1315
|
+
// src/rulebuilder/Builder-rule.ts
|
|
1316
|
+
var import_engine3 = require("@media-quest/engine");
|
|
1317
|
+
|
|
1318
|
+
// src/rulebuilder/RuleBuilder-test-utils.ts
|
|
1319
|
+
var RuleBuilderTestUtils;
|
|
1320
|
+
((RuleBuilderTestUtils2) => {
|
|
1321
|
+
RuleBuilderTestUtils2.createOptions = () => [
|
|
1322
|
+
BuilderOption.create(0, "Nei"),
|
|
1323
|
+
BuilderOption.create(1, "Ja"),
|
|
1324
|
+
BuilderOption.create(9, "Vet ikke")
|
|
1325
|
+
];
|
|
1326
|
+
RuleBuilderTestUtils2.excludeByTagAction = (tag) => {
|
|
1327
|
+
const pageCount = Math.floor(Math.random() * 10);
|
|
1328
|
+
const action = {
|
|
1329
|
+
kind: "exclude-by-tag",
|
|
1330
|
+
tag,
|
|
1331
|
+
description: "Description for tag: " + tag,
|
|
1332
|
+
pageCount
|
|
1333
|
+
};
|
|
1334
|
+
return action;
|
|
1335
|
+
};
|
|
1336
|
+
RuleBuilderTestUtils2.excludeByPageIdAction = (pageId, pageNumber) => {
|
|
1337
|
+
const action = {
|
|
1338
|
+
kind: "exclude-by-pageId",
|
|
1339
|
+
mainText: "",
|
|
1340
|
+
pageId,
|
|
1341
|
+
pageNumber
|
|
1342
|
+
};
|
|
1343
|
+
return action;
|
|
1344
|
+
};
|
|
1345
|
+
RuleBuilderTestUtils2.jumpToPageAction = (pageId, pageNumber) => {
|
|
1346
|
+
const action = {
|
|
1347
|
+
kind: "jump-to-page",
|
|
1348
|
+
mainText: "TEXT: " + pageId,
|
|
1349
|
+
pageId,
|
|
1350
|
+
pageNumber
|
|
1351
|
+
};
|
|
1352
|
+
return action;
|
|
1353
|
+
};
|
|
1354
|
+
RuleBuilderTestUtils2.excludeByTagActionList = () => {
|
|
1355
|
+
const list = [
|
|
1356
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag1"),
|
|
1357
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag2"),
|
|
1358
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag3"),
|
|
1359
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag4"),
|
|
1360
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag5"),
|
|
1361
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag6"),
|
|
1362
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag7"),
|
|
1363
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag8"),
|
|
1364
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag9"),
|
|
1365
|
+
(0, RuleBuilderTestUtils2.excludeByTagAction)("tag10")
|
|
1366
|
+
];
|
|
1367
|
+
return list;
|
|
1368
|
+
};
|
|
1369
|
+
RuleBuilderTestUtils2.createRuleVariable = (id, pageNumber) => new QuestionVariable(id, "Har du " + id + "?", (0, RuleBuilderTestUtils2.createOptions)(), pageNumber);
|
|
1370
|
+
RuleBuilderTestUtils2.createBuilderVariables_A_H = () => [
|
|
1371
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("a", 3),
|
|
1372
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("b", 4),
|
|
1373
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("c", 5),
|
|
1374
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("d", 6),
|
|
1375
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("e", 7),
|
|
1376
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("f", 8),
|
|
1377
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("g", 9),
|
|
1378
|
+
(0, RuleBuilderTestUtils2.createRuleVariable)("h", 10)
|
|
1379
|
+
];
|
|
1380
|
+
RuleBuilderTestUtils2.createConditionDto = (variable) => {
|
|
1381
|
+
const operator = Math.random() > 0 ? "equal" : "notEqual";
|
|
1382
|
+
const opt = variable.options[0];
|
|
1383
|
+
return {
|
|
1384
|
+
kind: "condition",
|
|
1385
|
+
name: "condition 1",
|
|
1386
|
+
variableId: variable.varId,
|
|
1387
|
+
operator,
|
|
1388
|
+
value: opt.value
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
RuleBuilderTestUtils2.createConditionGroupDto = (conditions) => {
|
|
1392
|
+
return {
|
|
1393
|
+
kind: "condition-group",
|
|
1394
|
+
conditions,
|
|
1395
|
+
type: "all",
|
|
1396
|
+
name: "random-group-name"
|
|
1397
|
+
};
|
|
1398
|
+
};
|
|
1399
|
+
RuleBuilderTestUtils2.createBuilderRuleDto = () => {
|
|
1400
|
+
const variables = (0, RuleBuilderTestUtils2.createBuilderVariables_A_H)();
|
|
1401
|
+
const condition0 = (0, RuleBuilderTestUtils2.createConditionDto)(variables[0]);
|
|
1402
|
+
const condition1 = (0, RuleBuilderTestUtils2.createConditionDto)(variables[1]);
|
|
1403
|
+
const condition3 = (0, RuleBuilderTestUtils2.createConditionDto)(variables[3]);
|
|
1404
|
+
const condition5 = (0, RuleBuilderTestUtils2.createConditionDto)(variables[5]);
|
|
1405
|
+
const group = (0, RuleBuilderTestUtils2.createConditionGroupDto)([condition0, condition3]);
|
|
1406
|
+
const rule = {
|
|
1407
|
+
name: "rule-name",
|
|
1408
|
+
conditions: [condition1, group, condition5],
|
|
1409
|
+
excludeTags: [],
|
|
1410
|
+
excludePages: [],
|
|
1411
|
+
jumpToPage: false,
|
|
1412
|
+
type: "all"
|
|
1413
|
+
};
|
|
1414
|
+
return [];
|
|
1415
|
+
};
|
|
1416
|
+
RuleBuilderTestUtils2.createExcludeByPageIdList = () => [
|
|
1417
|
+
ExcludeByPageIdSelectItem.create(
|
|
1418
|
+
{
|
|
1419
|
+
kind: "exclude-by-pageId",
|
|
1420
|
+
pageId: "page_a",
|
|
1421
|
+
pageNumber: 5,
|
|
1422
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1423
|
+
},
|
|
1424
|
+
false
|
|
1425
|
+
),
|
|
1426
|
+
ExcludeByPageIdSelectItem.create(
|
|
1427
|
+
{
|
|
1428
|
+
kind: "exclude-by-pageId",
|
|
1429
|
+
pageId: "page_b",
|
|
1430
|
+
pageNumber: 5,
|
|
1431
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1432
|
+
},
|
|
1433
|
+
true
|
|
1434
|
+
),
|
|
1435
|
+
ExcludeByPageIdSelectItem.create(
|
|
1436
|
+
{
|
|
1437
|
+
kind: "exclude-by-pageId",
|
|
1438
|
+
pageId: "page_c",
|
|
1439
|
+
pageNumber: 5,
|
|
1440
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1441
|
+
},
|
|
1442
|
+
false
|
|
1443
|
+
),
|
|
1444
|
+
ExcludeByPageIdSelectItem.create(
|
|
1445
|
+
{
|
|
1446
|
+
kind: "exclude-by-pageId",
|
|
1447
|
+
pageId: "page_d",
|
|
1448
|
+
pageNumber: 5,
|
|
1449
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1450
|
+
},
|
|
1451
|
+
false
|
|
1452
|
+
),
|
|
1453
|
+
ExcludeByPageIdSelectItem.create(
|
|
1454
|
+
{
|
|
1455
|
+
kind: "exclude-by-pageId",
|
|
1456
|
+
pageId: "page_e",
|
|
1457
|
+
pageNumber: 5,
|
|
1458
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1459
|
+
},
|
|
1460
|
+
true
|
|
1461
|
+
),
|
|
1462
|
+
ExcludeByPageIdSelectItem.create(
|
|
1463
|
+
{
|
|
1464
|
+
kind: "exclude-by-pageId",
|
|
1465
|
+
pageId: "page_f",
|
|
1466
|
+
pageNumber: 5,
|
|
1467
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1468
|
+
},
|
|
1469
|
+
false
|
|
1470
|
+
),
|
|
1471
|
+
ExcludeByPageIdSelectItem.create(
|
|
1472
|
+
{
|
|
1473
|
+
kind: "exclude-by-pageId",
|
|
1474
|
+
pageId: "page_g",
|
|
1475
|
+
pageNumber: 5,
|
|
1476
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1477
|
+
},
|
|
1478
|
+
true
|
|
1479
|
+
),
|
|
1480
|
+
ExcludeByPageIdSelectItem.create(
|
|
1481
|
+
{
|
|
1482
|
+
kind: "exclude-by-pageId",
|
|
1483
|
+
pageId: "page_h",
|
|
1484
|
+
pageNumber: 5,
|
|
1485
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1486
|
+
},
|
|
1487
|
+
false
|
|
1488
|
+
),
|
|
1489
|
+
ExcludeByPageIdSelectItem.create(
|
|
1490
|
+
{
|
|
1491
|
+
kind: "exclude-by-pageId",
|
|
1492
|
+
pageId: "page_i",
|
|
1493
|
+
pageNumber: 5,
|
|
1494
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1495
|
+
},
|
|
1496
|
+
false
|
|
1497
|
+
),
|
|
1498
|
+
ExcludeByPageIdSelectItem.create(
|
|
1499
|
+
{
|
|
1500
|
+
kind: "exclude-by-pageId",
|
|
1501
|
+
pageId: "page_j",
|
|
1502
|
+
pageNumber: 5,
|
|
1503
|
+
mainText: "Har du noen gang v\xE6rt deprimeri?? "
|
|
1504
|
+
},
|
|
1505
|
+
true
|
|
1506
|
+
)
|
|
1507
|
+
];
|
|
1508
|
+
RuleBuilderTestUtils2.createExcludeByTagList = () => [
|
|
1509
|
+
ExcludeByTagSelectItem.create(
|
|
1510
|
+
{
|
|
1511
|
+
kind: "exclude-by-tag",
|
|
1512
|
+
tag: "Can_read",
|
|
1513
|
+
pageCount: 5,
|
|
1514
|
+
description: ""
|
|
1515
|
+
},
|
|
1516
|
+
false
|
|
1517
|
+
),
|
|
1518
|
+
ExcludeByTagSelectItem.create(
|
|
1519
|
+
{
|
|
1520
|
+
kind: "exclude-by-tag",
|
|
1521
|
+
tag: "Is grownup",
|
|
1522
|
+
pageCount: 1,
|
|
1523
|
+
description: ""
|
|
1524
|
+
},
|
|
1525
|
+
true
|
|
1526
|
+
),
|
|
1527
|
+
ExcludeByTagSelectItem.create(
|
|
1528
|
+
{
|
|
1529
|
+
kind: "exclude-by-tag",
|
|
1530
|
+
tag: "speaks english",
|
|
1531
|
+
pageCount: 3,
|
|
1532
|
+
description: ""
|
|
1533
|
+
},
|
|
1534
|
+
false
|
|
1535
|
+
),
|
|
1536
|
+
ExcludeByTagSelectItem.create(
|
|
1537
|
+
{
|
|
1538
|
+
kind: "exclude-by-tag",
|
|
1539
|
+
tag: "has work",
|
|
1540
|
+
pageCount: 7,
|
|
1541
|
+
description: ""
|
|
1542
|
+
},
|
|
1543
|
+
false
|
|
1544
|
+
),
|
|
1545
|
+
ExcludeByTagSelectItem.create(
|
|
1546
|
+
{
|
|
1547
|
+
kind: "exclude-by-tag",
|
|
1548
|
+
tag: "is-depressed",
|
|
1549
|
+
pageCount: 2,
|
|
1550
|
+
description: ""
|
|
1551
|
+
},
|
|
1552
|
+
false
|
|
1553
|
+
)
|
|
1554
|
+
];
|
|
1555
|
+
})(RuleBuilderTestUtils || (RuleBuilderTestUtils = {}));
|
|
1556
|
+
|
|
1235
1557
|
// src/rulebuilder/Builder-rule.ts
|
|
1236
1558
|
var BuilderRule = class _BuilderRule extends BuilderObject {
|
|
1237
1559
|
constructor(dto, _ruleInput) {
|
|
@@ -1247,26 +1569,14 @@ var BuilderRule = class _BuilderRule extends BuilderObject {
|
|
|
1247
1569
|
acc.push(condition);
|
|
1248
1570
|
}
|
|
1249
1571
|
if (curr.kind === "condition-group") {
|
|
1250
|
-
const conditionGroup = BuilderConditionGroup.fromDto(
|
|
1251
|
-
curr,
|
|
1252
|
-
conditionInput
|
|
1253
|
-
);
|
|
1572
|
+
const conditionGroup = BuilderConditionGroup.fromDto(curr, conditionInput);
|
|
1254
1573
|
acc.push(conditionGroup);
|
|
1255
1574
|
}
|
|
1256
1575
|
return acc;
|
|
1257
1576
|
}, []);
|
|
1258
|
-
this._pageActionManager = new PageActionManager(
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
);
|
|
1262
|
-
this._tagActionManager = new TagActionManager(
|
|
1263
|
-
_ruleInput.excludeByTagActions,
|
|
1264
|
-
dto.excludeTags
|
|
1265
|
-
);
|
|
1266
|
-
this.jumpToActionManager = new JumpToActionManager(
|
|
1267
|
-
_ruleInput.jumpToPageActions,
|
|
1268
|
-
dto.jumpToPage
|
|
1269
|
-
);
|
|
1577
|
+
this._pageActionManager = new PageActionManager(_ruleInput.excludeByPageIdActions, dto.excludePages);
|
|
1578
|
+
this._tagActionManager = new TagActionManager(_ruleInput.excludeByTagActions, dto.excludeTags);
|
|
1579
|
+
this.jumpToActionManager = new JumpToActionManager(_ruleInput.jumpToPageActions, dto.jumpToPage);
|
|
1270
1580
|
}
|
|
1271
1581
|
objectType = "builder-rule";
|
|
1272
1582
|
_type = "all";
|
|
@@ -1308,9 +1618,7 @@ var BuilderRule = class _BuilderRule extends BuilderObject {
|
|
|
1308
1618
|
return true;
|
|
1309
1619
|
}
|
|
1310
1620
|
addCondition() {
|
|
1311
|
-
const condition = BuilderCondition.create(
|
|
1312
|
-
this._ruleInput.getConditionInput()
|
|
1313
|
-
);
|
|
1621
|
+
const condition = BuilderCondition.create(this._ruleInput.getConditionInput());
|
|
1314
1622
|
this._conditions.push(condition);
|
|
1315
1623
|
return condition;
|
|
1316
1624
|
}
|
|
@@ -1321,10 +1629,7 @@ var BuilderRule = class _BuilderRule extends BuilderObject {
|
|
|
1321
1629
|
type: "all",
|
|
1322
1630
|
conditions: []
|
|
1323
1631
|
};
|
|
1324
|
-
const newGroup = BuilderConditionGroup.fromDto(
|
|
1325
|
-
dto,
|
|
1326
|
-
this._ruleInput.questionVars
|
|
1327
|
-
);
|
|
1632
|
+
const newGroup = BuilderConditionGroup.fromDto(dto, this._ruleInput.questionVars);
|
|
1328
1633
|
this._conditions.push(newGroup);
|
|
1329
1634
|
return newGroup;
|
|
1330
1635
|
}
|
|
@@ -1346,6 +1651,70 @@ var BuilderRule = class _BuilderRule extends BuilderObject {
|
|
|
1346
1651
|
};
|
|
1347
1652
|
return dto;
|
|
1348
1653
|
}
|
|
1654
|
+
toEngineRule() {
|
|
1655
|
+
const conditions = [];
|
|
1656
|
+
this._conditions.forEach((c) => {
|
|
1657
|
+
if (c) {
|
|
1658
|
+
if (c instanceof BuilderCondition) {
|
|
1659
|
+
const simpleCondition = c.toEngineCondition();
|
|
1660
|
+
if (simpleCondition) {
|
|
1661
|
+
conditions.push(simpleCondition);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
if (c instanceof BuilderConditionGroup) {
|
|
1665
|
+
const complexCondition = c.toEngineConditionComplex();
|
|
1666
|
+
if (complexCondition)
|
|
1667
|
+
conditions.push(complexCondition);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
let all = [];
|
|
1672
|
+
let some = [];
|
|
1673
|
+
if (this.type === "all") {
|
|
1674
|
+
all = [...conditions];
|
|
1675
|
+
}
|
|
1676
|
+
const pageQueCommands = [];
|
|
1677
|
+
const maybeJumpToPage = this.jumpToActionManager.selected;
|
|
1678
|
+
if (maybeJumpToPage) {
|
|
1679
|
+
const jumpCommand = {
|
|
1680
|
+
kind: "PAGE_QUE_JUMP_TO_PAGE_COMMAND",
|
|
1681
|
+
target: "PAGE_QUE",
|
|
1682
|
+
targetId: "PAGE_QUE",
|
|
1683
|
+
payload: { pageId: maybeJumpToPage.data.pageId }
|
|
1684
|
+
};
|
|
1685
|
+
pageQueCommands.push(jumpCommand);
|
|
1686
|
+
}
|
|
1687
|
+
const excludePageByIdList = this._pageActionManager.getEngineAction().map((a) => a.pageId);
|
|
1688
|
+
if (excludePageByIdList.length) {
|
|
1689
|
+
const command = {
|
|
1690
|
+
kind: "PAGE_QUE_EXCLUDE_BY_PAGE_ID_COMMAND",
|
|
1691
|
+
target: "PAGE_QUE",
|
|
1692
|
+
targetId: "PAGE_QUE",
|
|
1693
|
+
payload: { pageIds: [...excludePageByIdList] }
|
|
1694
|
+
};
|
|
1695
|
+
pageQueCommands.push(command);
|
|
1696
|
+
}
|
|
1697
|
+
const excludeTags = this._tagActionManager.getEngineActions().map((tagA) => tagA.tag);
|
|
1698
|
+
if (excludeTags.length) {
|
|
1699
|
+
const excludeTagsCommand = {
|
|
1700
|
+
kind: "PAGE_QUE_EXCLUDE_BY_TAG_COMMAND",
|
|
1701
|
+
target: "PAGE_QUE",
|
|
1702
|
+
targetId: "PAGE_QUE",
|
|
1703
|
+
payload: { tagIds: [...excludeTags] }
|
|
1704
|
+
};
|
|
1705
|
+
pageQueCommands.push(excludeTagsCommand);
|
|
1706
|
+
}
|
|
1707
|
+
const id = import_engine3.DUtil.randomObjectId();
|
|
1708
|
+
const rule = {
|
|
1709
|
+
id: "",
|
|
1710
|
+
description: this.name,
|
|
1711
|
+
all,
|
|
1712
|
+
some,
|
|
1713
|
+
onFailure: [],
|
|
1714
|
+
onSuccess: pageQueCommands
|
|
1715
|
+
};
|
|
1716
|
+
return rule;
|
|
1717
|
+
}
|
|
1349
1718
|
};
|
|
1350
1719
|
|
|
1351
1720
|
// src/theme/AbstractThemeCompiler.ts
|
|
@@ -1356,34 +1725,34 @@ var AbstractThemeCompiler = class {
|
|
|
1356
1725
|
};
|
|
1357
1726
|
|
|
1358
1727
|
// src/theme/standard-props.ts
|
|
1359
|
-
var
|
|
1728
|
+
var import_engine4 = require("@media-quest/engine");
|
|
1360
1729
|
var DStateProps;
|
|
1361
1730
|
((DStateProps2) => {
|
|
1362
|
-
DStateProps2.mediaBlockedBySequence = new
|
|
1731
|
+
DStateProps2.mediaBlockedBySequence = new import_engine4.BooleanStateProperty(
|
|
1363
1732
|
"media-blocked-by-autoplay-sequence",
|
|
1364
1733
|
false,
|
|
1365
1734
|
"Should be true if the page is in a autoplay-sequence. The autoplay-sequence will always block other media."
|
|
1366
1735
|
);
|
|
1367
|
-
DStateProps2.inputBlockingBySequence = new
|
|
1368
|
-
DStateProps2.mediaBlockedByAudio = new
|
|
1369
|
-
DStateProps2.inputBlockedByAudio = new
|
|
1370
|
-
DStateProps2.mediaBlockedByVideo = new
|
|
1371
|
-
DStateProps2.inputBlockedByVideo = new
|
|
1736
|
+
DStateProps2.inputBlockingBySequence = new import_engine4.BooleanStateProperty("input-blocked-by-autoplay-sequence", false, "");
|
|
1737
|
+
DStateProps2.mediaBlockedByAudio = new import_engine4.BooleanStateProperty("media-blocked-by-audio", false, "");
|
|
1738
|
+
DStateProps2.inputBlockedByAudio = new import_engine4.BooleanStateProperty("input-blocked-by-audio", false, "");
|
|
1739
|
+
DStateProps2.mediaBlockedByVideo = new import_engine4.BooleanStateProperty("media-blocked-by-video", false, "");
|
|
1740
|
+
DStateProps2.inputBlockedByVideo = new import_engine4.BooleanStateProperty(
|
|
1372
1741
|
"input-blocked-by-video",
|
|
1373
1742
|
false,
|
|
1374
1743
|
"Should be true if a video is playing, and this video is suppose to block user-input."
|
|
1375
1744
|
);
|
|
1376
|
-
DStateProps2.userPausedVideo = new
|
|
1745
|
+
DStateProps2.userPausedVideo = new import_engine4.BooleanStateProperty(
|
|
1377
1746
|
"user-paused-video",
|
|
1378
1747
|
false,
|
|
1379
1748
|
"Should be true if user paused the video by pressing the pause-button."
|
|
1380
1749
|
);
|
|
1381
|
-
DStateProps2.videoIsPlaying = new
|
|
1750
|
+
DStateProps2.videoIsPlaying = new import_engine4.BooleanStateProperty(
|
|
1382
1751
|
"video-is-playing",
|
|
1383
1752
|
false,
|
|
1384
1753
|
"Should be true if any video is playing on the page."
|
|
1385
1754
|
);
|
|
1386
|
-
DStateProps2.audioIsPlaying = new
|
|
1755
|
+
DStateProps2.audioIsPlaying = new import_engine4.BooleanStateProperty(
|
|
1387
1756
|
"audio-is-playing",
|
|
1388
1757
|
false,
|
|
1389
1758
|
"Should be tru if any audio is playing on page"
|
|
@@ -1566,16 +1935,35 @@ var ThemeUtils;
|
|
|
1566
1935
|
})(ThemeUtils || (ThemeUtils = {}));
|
|
1567
1936
|
|
|
1568
1937
|
// src/theme/default-theme-compiler.ts
|
|
1569
|
-
var
|
|
1570
|
-
var U3 =
|
|
1938
|
+
var import_engine5 = require("@media-quest/engine");
|
|
1939
|
+
var U3 = import_engine5.DUtil;
|
|
1571
1940
|
var generateElementId = () => U3.randomString(32);
|
|
1572
1941
|
var DefaultThemeCompiler = class extends AbstractThemeCompiler {
|
|
1573
1942
|
name = "Ispe default theme.";
|
|
1943
|
+
TAG = "[ DEFAULT_THEME_COMPILER ]: ";
|
|
1574
1944
|
constructor() {
|
|
1575
1945
|
super(DefaultTheme);
|
|
1576
1946
|
}
|
|
1947
|
+
compileRules(source) {
|
|
1948
|
+
const builderSchema = BuilderSchema.fromJson(source);
|
|
1949
|
+
const ruleInput = builderSchema.getRuleInput();
|
|
1950
|
+
const pageQueRules = [];
|
|
1951
|
+
source.rules.forEach((rule) => {
|
|
1952
|
+
const engineRule = BuilderRule.fromDto(rule, ruleInput).toEngineRule();
|
|
1953
|
+
if (!import_engine5.Rule.isEmpty(engineRule)) {
|
|
1954
|
+
pageQueRules.push(engineRule);
|
|
1955
|
+
} else {
|
|
1956
|
+
console.groupCollapsed(this.TAG, "Throws away empty rule.");
|
|
1957
|
+
console.log(rule);
|
|
1958
|
+
console.log(ruleInput);
|
|
1959
|
+
console.groupEnd();
|
|
1960
|
+
}
|
|
1961
|
+
});
|
|
1962
|
+
return pageQueRules;
|
|
1963
|
+
}
|
|
1577
1964
|
compile(source) {
|
|
1578
1965
|
const pages = source.pages.map((p) => this.compilePage(p, source.id));
|
|
1966
|
+
const rules = this.compileRules(source);
|
|
1579
1967
|
const dto = {
|
|
1580
1968
|
backgroundColor: source.backgroundColor,
|
|
1581
1969
|
baseHeight: source.baseHeight,
|
|
@@ -1585,7 +1973,7 @@ var DefaultThemeCompiler = class extends AbstractThemeCompiler {
|
|
|
1585
1973
|
pages,
|
|
1586
1974
|
predefinedFacts: [],
|
|
1587
1975
|
prefix: source.prefix,
|
|
1588
|
-
rules
|
|
1976
|
+
rules,
|
|
1589
1977
|
stateFromEvent: [
|
|
1590
1978
|
{
|
|
1591
1979
|
onEvent: "VIDEO_ENDED_EVENT",
|
|
@@ -1906,8 +2294,8 @@ var DefaultThemeCompiler = class extends AbstractThemeCompiler {
|
|
|
1906
2294
|
};
|
|
1907
2295
|
|
|
1908
2296
|
// src/Builder-schema.ts
|
|
1909
|
-
var
|
|
1910
|
-
var U4 =
|
|
2297
|
+
var import_engine6 = require("@media-quest/engine");
|
|
2298
|
+
var U4 = import_engine6.DUtil;
|
|
1911
2299
|
var BuilderSchema = class _BuilderSchema {
|
|
1912
2300
|
constructor(id, name, prefix) {
|
|
1913
2301
|
this.id = id;
|
|
@@ -2003,6 +2391,7 @@ var BuilderSchema = class _BuilderSchema {
|
|
|
2003
2391
|
input
|
|
2004
2392
|
);
|
|
2005
2393
|
this._rules.push(rule);
|
|
2394
|
+
return rule;
|
|
2006
2395
|
}
|
|
2007
2396
|
deleteRule(rule) {
|
|
2008
2397
|
this._rules = this._rules.filter((r) => r !== rule);
|
|
@@ -2150,12 +2539,31 @@ var BuilderText = class _BuilderText extends BuilderObject {
|
|
|
2150
2539
|
};
|
|
2151
2540
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2152
2541
|
0 && (module.exports = {
|
|
2542
|
+
BuilderCondition,
|
|
2543
|
+
BuilderConditionGroup,
|
|
2153
2544
|
BuilderMainText,
|
|
2545
|
+
BuilderOperator,
|
|
2154
2546
|
BuilderOption,
|
|
2155
2547
|
BuilderPage,
|
|
2156
2548
|
BuilderQuestion,
|
|
2549
|
+
BuilderRule,
|
|
2157
2550
|
BuilderSchema,
|
|
2158
2551
|
BuilderTag,
|
|
2159
2552
|
BuilderText,
|
|
2553
|
+
BuilderVariableOption,
|
|
2554
|
+
CustomVariable,
|
|
2555
|
+
ExcludeByPageIdSelectItem,
|
|
2556
|
+
ExcludeByTagSelectItem,
|
|
2557
|
+
JumpToActionManager,
|
|
2558
|
+
JumpToPageSelectItem,
|
|
2559
|
+
MultiSelectItem,
|
|
2560
|
+
OperatorSelectItem,
|
|
2561
|
+
PageActionManager,
|
|
2562
|
+
QuestionVariable,
|
|
2563
|
+
RuleInput,
|
|
2564
|
+
RuleOptionSelectItem,
|
|
2565
|
+
RuleVariableSelectItem,
|
|
2566
|
+
SingleSelectItem,
|
|
2567
|
+
TagActionManager,
|
|
2160
2568
|
TagCollection
|
|
2161
2569
|
});
|