@media-quest/builder 0.0.25 → 0.0.26
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/package.json +15 -15
- package/src/Builder-option.ts +64 -64
- package/src/Builder-page.spec.ts +2 -160
- package/src/Builder-page.ts +6 -83
- package/src/Builder-question.spec.ts +68 -68
- package/src/Builder-question.ts +102 -102
- package/src/Builder-schema.spec.ts +86 -114
- package/src/Builder-schema.ts +13 -9
- package/src/Builder-text.spec.ts +24 -24
- package/src/Builder-text.ts +57 -57
- package/src/BuilderObject.ts +30 -29
- package/src/BuilderTag.ts +96 -96
- package/src/builder-compiler.ts +1 -1
- package/src/code-book/codebook-variable.ts +29 -0
- package/src/{codebook.ts → code-book/codebook.ts} +72 -72
- package/src/primitives/ID.spec.ts +39 -39
- package/src/primitives/ID.ts +138 -119
- package/src/primitives/page-prefix.ts +59 -59
- package/src/primitives/varID.ts +12 -12
- package/src/public-api.ts +28 -26
- package/src/rulebuilder/Builder-rule.spec.ts +323 -323
- package/src/rulebuilder/Builder-rule.ts +191 -191
- package/src/rulebuilder/RuleBuilder-test-utils.ts +320 -320
- package/src/rulebuilder/RuleInput.ts +30 -30
- package/src/rulebuilder/RuleVariable.ts +34 -48
- package/src/rulebuilder/SingleSelectItem.ts +9 -8
- package/src/rulebuilder/condition/Builder-condition-group.ts +14 -6
- package/src/rulebuilder/condition/Builder-condition.spec.ts +12 -12
- package/src/rulebuilder/condition/Builder-condition.ts +17 -13
- package/src/rulebuilder/index.ts +16 -3
- package/src/rulebuilder/page-action-manager.ts +33 -33
- package/src/rulebuilder/rule2/Rule2.ts +211 -215
- package/src/schema-config.ts +25 -25
- package/src/sum-score/sum-score-answer.ts +6 -0
- package/src/sum-score/sum-score-manager.spec.ts +189 -0
- package/src/sum-score/sum-score-manager.ts +154 -0
- package/src/sum-score/sum-score-membership.ts +45 -0
- package/src/sum-score/sum-score-variable.spec.ts +151 -0
- package/src/sum-score/sum-score-variable.ts +36 -0
- package/src/{variable → sum-score}/sum-score.ts +122 -130
- package/tsconfig.tsbuildinfo +1 -1
- package/src/variable/b-variable.ts +0 -68
- package/src/variable/mq-variable.spec.ts +0 -147
- package/src/variable/sum-score-variable.ts +0 -50
|
@@ -1,320 +1,320 @@
|
|
|
1
|
-
import { BuilderOption } from "../Builder-option";
|
|
2
|
-
import { type
|
|
3
|
-
import type { BuilderRuleDto } from "./Builder-rule";
|
|
4
|
-
import type { BuilderConditionGroupDto } from "./condition/Builder-condition-group";
|
|
5
|
-
import type { BuilderConditionDto } from "./condition/Builder-condition";
|
|
6
|
-
import type { BuilderOperator } from "./condition/Builder-operator";
|
|
7
|
-
import type { ExcludeByPageAction, ExcludeByTagAction, JumpToPageAction } from "./RuleAction";
|
|
8
|
-
import { ExcludeByPageIdSelectItem, ExcludeByTagSelectItem } from "./multi-select-item";
|
|
9
|
-
import { PagePrefix } from "../primitives/page-prefix";
|
|
10
|
-
import { VarID } from "../primitives/varID";
|
|
11
|
-
import { SchemaPrefix } from "../primitives/schema-prefix";
|
|
12
|
-
import { PageID } from "../primitives/ID";
|
|
13
|
-
|
|
14
|
-
const idPxx = () => {
|
|
15
|
-
const id = PageID.create();
|
|
16
|
-
const prefix = PagePrefix.fromStringOrThrow("pxx");
|
|
17
|
-
return { id, prefix: prefix };
|
|
18
|
-
};
|
|
19
|
-
export namespace RuleBuilderTestUtils {
|
|
20
|
-
export const createOptions = () => [
|
|
21
|
-
BuilderOption.create(0, "Nei"),
|
|
22
|
-
BuilderOption.create(1, "Ja"),
|
|
23
|
-
BuilderOption.create(9, "Vet ikke"),
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export const excludeByTagAction = (tag: string) => {
|
|
27
|
-
const pageCount = Math.floor(Math.random() * 10);
|
|
28
|
-
const action: ExcludeByTagAction = {
|
|
29
|
-
kind: "exclude-by-tag",
|
|
30
|
-
tag,
|
|
31
|
-
description: "Description for tag: " + tag,
|
|
32
|
-
pageCount,
|
|
33
|
-
};
|
|
34
|
-
return action;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const excludeByPageIdAction = (pageId: PageID, pageNumber: number) => {
|
|
38
|
-
const pagePrefix = PagePrefix.castOrCreateRandom("").value;
|
|
39
|
-
const action: ExcludeByPageAction = {
|
|
40
|
-
kind: "exclude-by-pageId",
|
|
41
|
-
mainText: "",
|
|
42
|
-
pageId,
|
|
43
|
-
pagePrefix,
|
|
44
|
-
pageNumber,
|
|
45
|
-
};
|
|
46
|
-
return action;
|
|
47
|
-
};
|
|
48
|
-
export const jumpToPageAction = (pageId: PageID, pageNumber: number) => {
|
|
49
|
-
const pagePrefix = PagePrefix.castOrCreateRandom("").value;
|
|
50
|
-
const action: JumpToPageAction = {
|
|
51
|
-
kind: "jump-to-page",
|
|
52
|
-
mainText: "TEXT: " + pageId,
|
|
53
|
-
pagePrefix,
|
|
54
|
-
pageId,
|
|
55
|
-
pageNumber,
|
|
56
|
-
};
|
|
57
|
-
return action;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const excludeByTagActionList = () => {
|
|
61
|
-
const list = [
|
|
62
|
-
excludeByTagAction("tag1"),
|
|
63
|
-
excludeByTagAction("tag2"),
|
|
64
|
-
excludeByTagAction("tag3"),
|
|
65
|
-
excludeByTagAction("tag4"),
|
|
66
|
-
excludeByTagAction("tag5"),
|
|
67
|
-
excludeByTagAction("tag6"),
|
|
68
|
-
excludeByTagAction("tag7"),
|
|
69
|
-
excludeByTagAction("tag8"),
|
|
70
|
-
excludeByTagAction("tag9"),
|
|
71
|
-
excludeByTagAction("tag10"),
|
|
72
|
-
] as const;
|
|
73
|
-
return list;
|
|
74
|
-
};
|
|
75
|
-
export const createRuleVariable = (varId: VarID, pageNumber: number):
|
|
76
|
-
new
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
*/
|
|
81
|
-
export const createPagesAndVars_A_H = (schemaPrefix: SchemaPrefix) => {
|
|
82
|
-
const varId = (pagePrefix: string) => {
|
|
83
|
-
const pxx = PagePrefix.fromStringOrThrow(pagePrefix);
|
|
84
|
-
const qxx = VarID.create(schemaPrefix.value, pxx);
|
|
85
|
-
return qxx;
|
|
86
|
-
};
|
|
87
|
-
const pageAID = PageID.create();
|
|
88
|
-
const pageBID = PageID.create();
|
|
89
|
-
const pageCID = PageID.create();
|
|
90
|
-
const pageDID = PageID.create();
|
|
91
|
-
const pageEID = PageID.create();
|
|
92
|
-
const pageFID = PageID.create();
|
|
93
|
-
const pageGID = PageID.create();
|
|
94
|
-
const pageHID = PageID.create();
|
|
95
|
-
const a = createRuleVariable(varId("a"), 3);
|
|
96
|
-
const b = createRuleVariable(varId("b"), 4);
|
|
97
|
-
const c = createRuleVariable(varId("c"), 5);
|
|
98
|
-
const d = createRuleVariable(varId("d"), 6);
|
|
99
|
-
const e = createRuleVariable(varId("e"), 7);
|
|
100
|
-
const f = createRuleVariable(varId("f"), 8);
|
|
101
|
-
const g = createRuleVariable(varId("g"), 9);
|
|
102
|
-
const h = createRuleVariable(varId("h"), 10);
|
|
103
|
-
const list = [a, b, c, d, e, f, g, h];
|
|
104
|
-
const items = { a, b, c, d, e, f, g, h };
|
|
105
|
-
const pageIds = {
|
|
106
|
-
a: pageAID,
|
|
107
|
-
b: pageBID,
|
|
108
|
-
c: pageCID,
|
|
109
|
-
d: pageDID,
|
|
110
|
-
e: pageEID,
|
|
111
|
-
f: pageFID,
|
|
112
|
-
g: pageGID,
|
|
113
|
-
|
|
114
|
-
h: pageHID,
|
|
115
|
-
};
|
|
116
|
-
const pageIdList = [pageAID, pageBID, pageCID, pageDID, pageEID, pageFID, pageGID, pageHID];
|
|
117
|
-
return { list, items, pageIds, pageIdList };
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export const createConditionDto = (variable:
|
|
121
|
-
const operator: BuilderOperator = Math.random() > 0 ? "equal" : "notEqual";
|
|
122
|
-
const opt = variable.options[0];
|
|
123
|
-
return {
|
|
124
|
-
kind: "condition",
|
|
125
|
-
name: "condition 1",
|
|
126
|
-
variableId: variable.varId,
|
|
127
|
-
operator,
|
|
128
|
-
value: opt.value,
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export const createConditionGroupDto = (
|
|
133
|
-
conditions: BuilderConditionDto[],
|
|
134
|
-
): BuilderConditionGroupDto => {
|
|
135
|
-
return {
|
|
136
|
-
kind: "condition-group",
|
|
137
|
-
conditions,
|
|
138
|
-
type: "all",
|
|
139
|
-
name: "random-group-name",
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const createBuilderRuleDto = (
|
|
144
|
-
schemaPrefix: SchemaPrefix,
|
|
145
|
-
): ReadonlyArray<BuilderRuleDto> => {
|
|
146
|
-
const v = createPagesAndVars_A_H(schemaPrefix);
|
|
147
|
-
const condition0 = createConditionDto(v.items.a);
|
|
148
|
-
const condition1 = createConditionDto(v.items.b);
|
|
149
|
-
const condition3 = createConditionDto(v.items.c);
|
|
150
|
-
const condition5 = createConditionDto(v.items.e);
|
|
151
|
-
const group = createConditionGroupDto([condition0, condition3]);
|
|
152
|
-
// const action1: Exc
|
|
153
|
-
const rule: BuilderRuleDto = {
|
|
154
|
-
name: "rule-name",
|
|
155
|
-
conditions: [condition1, group, condition5],
|
|
156
|
-
excludeTags: [],
|
|
157
|
-
excludePages: [],
|
|
158
|
-
jumpToPage: false,
|
|
159
|
-
type: "all",
|
|
160
|
-
};
|
|
161
|
-
return [];
|
|
162
|
-
};
|
|
163
|
-
export const createExcludeByPageIdList = (): ReadonlyArray<ExcludeByPageIdSelectItem> => [
|
|
164
|
-
ExcludeByPageIdSelectItem.create(
|
|
165
|
-
{
|
|
166
|
-
kind: "exclude-by-pageId",
|
|
167
|
-
pageId: idPxx().id,
|
|
168
|
-
pagePrefix: idPxx().prefix,
|
|
169
|
-
pageNumber: 5,
|
|
170
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
171
|
-
},
|
|
172
|
-
false,
|
|
173
|
-
),
|
|
174
|
-
|
|
175
|
-
ExcludeByPageIdSelectItem.create(
|
|
176
|
-
{
|
|
177
|
-
kind: "exclude-by-pageId",
|
|
178
|
-
pageId: idPxx().id,
|
|
179
|
-
pagePrefix: idPxx().prefix,
|
|
180
|
-
pageNumber: 5,
|
|
181
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
182
|
-
},
|
|
183
|
-
true,
|
|
184
|
-
),
|
|
185
|
-
|
|
186
|
-
ExcludeByPageIdSelectItem.create(
|
|
187
|
-
{
|
|
188
|
-
kind: "exclude-by-pageId",
|
|
189
|
-
pageId: idPxx().id,
|
|
190
|
-
pagePrefix: idPxx().prefix,
|
|
191
|
-
pageNumber: 5,
|
|
192
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
193
|
-
},
|
|
194
|
-
false,
|
|
195
|
-
),
|
|
196
|
-
|
|
197
|
-
ExcludeByPageIdSelectItem.create(
|
|
198
|
-
{
|
|
199
|
-
kind: "exclude-by-pageId",
|
|
200
|
-
pageId: idPxx().id,
|
|
201
|
-
pagePrefix: idPxx().prefix,
|
|
202
|
-
pageNumber: 5,
|
|
203
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
204
|
-
},
|
|
205
|
-
false,
|
|
206
|
-
),
|
|
207
|
-
|
|
208
|
-
ExcludeByPageIdSelectItem.create(
|
|
209
|
-
{
|
|
210
|
-
kind: "exclude-by-pageId",
|
|
211
|
-
pageId: idPxx().id,
|
|
212
|
-
pagePrefix: idPxx().prefix,
|
|
213
|
-
pageNumber: 5,
|
|
214
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
215
|
-
},
|
|
216
|
-
true,
|
|
217
|
-
),
|
|
218
|
-
ExcludeByPageIdSelectItem.create(
|
|
219
|
-
{
|
|
220
|
-
kind: "exclude-by-pageId",
|
|
221
|
-
pageId: idPxx().id,
|
|
222
|
-
pagePrefix: idPxx().prefix,
|
|
223
|
-
pageNumber: 5,
|
|
224
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
225
|
-
},
|
|
226
|
-
false,
|
|
227
|
-
),
|
|
228
|
-
|
|
229
|
-
ExcludeByPageIdSelectItem.create(
|
|
230
|
-
{
|
|
231
|
-
kind: "exclude-by-pageId",
|
|
232
|
-
pageId: idPxx().id,
|
|
233
|
-
pagePrefix: idPxx().prefix,
|
|
234
|
-
pageNumber: 5,
|
|
235
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
236
|
-
},
|
|
237
|
-
true,
|
|
238
|
-
),
|
|
239
|
-
|
|
240
|
-
ExcludeByPageIdSelectItem.create(
|
|
241
|
-
{
|
|
242
|
-
kind: "exclude-by-pageId",
|
|
243
|
-
pageId: idPxx().id,
|
|
244
|
-
pagePrefix: idPxx().prefix,
|
|
245
|
-
pageNumber: 5,
|
|
246
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
247
|
-
},
|
|
248
|
-
false,
|
|
249
|
-
),
|
|
250
|
-
|
|
251
|
-
ExcludeByPageIdSelectItem.create(
|
|
252
|
-
{
|
|
253
|
-
kind: "exclude-by-pageId",
|
|
254
|
-
pageId: idPxx().id,
|
|
255
|
-
pagePrefix: idPxx().prefix,
|
|
256
|
-
pageNumber: 5,
|
|
257
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
258
|
-
},
|
|
259
|
-
false,
|
|
260
|
-
),
|
|
261
|
-
|
|
262
|
-
ExcludeByPageIdSelectItem.create(
|
|
263
|
-
{
|
|
264
|
-
kind: "exclude-by-pageId",
|
|
265
|
-
pageId: idPxx().id,
|
|
266
|
-
pagePrefix: idPxx().prefix,
|
|
267
|
-
pageNumber: 5,
|
|
268
|
-
mainText: "Har du noen gang vært deprimeri?? ",
|
|
269
|
-
},
|
|
270
|
-
true,
|
|
271
|
-
),
|
|
272
|
-
];
|
|
273
|
-
export const createExcludeByTagList = () => [
|
|
274
|
-
ExcludeByTagSelectItem.create(
|
|
275
|
-
{
|
|
276
|
-
kind: "exclude-by-tag",
|
|
277
|
-
tag: "Can_read",
|
|
278
|
-
pageCount: 5,
|
|
279
|
-
description: "",
|
|
280
|
-
},
|
|
281
|
-
false,
|
|
282
|
-
),
|
|
283
|
-
ExcludeByTagSelectItem.create(
|
|
284
|
-
{
|
|
285
|
-
kind: "exclude-by-tag",
|
|
286
|
-
tag: "Is grownup",
|
|
287
|
-
pageCount: 1,
|
|
288
|
-
description: "",
|
|
289
|
-
},
|
|
290
|
-
true,
|
|
291
|
-
),
|
|
292
|
-
ExcludeByTagSelectItem.create(
|
|
293
|
-
{
|
|
294
|
-
kind: "exclude-by-tag",
|
|
295
|
-
tag: "speaks english",
|
|
296
|
-
pageCount: 3,
|
|
297
|
-
description: "",
|
|
298
|
-
},
|
|
299
|
-
false,
|
|
300
|
-
),
|
|
301
|
-
ExcludeByTagSelectItem.create(
|
|
302
|
-
{
|
|
303
|
-
kind: "exclude-by-tag",
|
|
304
|
-
tag: "has work",
|
|
305
|
-
pageCount: 7,
|
|
306
|
-
description: "",
|
|
307
|
-
},
|
|
308
|
-
false,
|
|
309
|
-
),
|
|
310
|
-
ExcludeByTagSelectItem.create(
|
|
311
|
-
{
|
|
312
|
-
kind: "exclude-by-tag",
|
|
313
|
-
tag: "is-depressed",
|
|
314
|
-
pageCount: 2,
|
|
315
|
-
description: "",
|
|
316
|
-
},
|
|
317
|
-
false,
|
|
318
|
-
),
|
|
319
|
-
];
|
|
320
|
-
}
|
|
1
|
+
import { BuilderOption } from "../Builder-option";
|
|
2
|
+
import { type RuleVariable, RuleQuestionVariable } from "./RuleVariable";
|
|
3
|
+
import type { BuilderRuleDto } from "./Builder-rule";
|
|
4
|
+
import type { BuilderConditionGroupDto } from "./condition/Builder-condition-group";
|
|
5
|
+
import type { BuilderConditionDto } from "./condition/Builder-condition";
|
|
6
|
+
import type { BuilderOperator } from "./condition/Builder-operator";
|
|
7
|
+
import type { ExcludeByPageAction, ExcludeByTagAction, JumpToPageAction } from "./RuleAction";
|
|
8
|
+
import { ExcludeByPageIdSelectItem, ExcludeByTagSelectItem } from "./multi-select-item";
|
|
9
|
+
import { PagePrefix } from "../primitives/page-prefix";
|
|
10
|
+
import { VarID } from "../primitives/varID";
|
|
11
|
+
import { SchemaPrefix } from "../primitives/schema-prefix";
|
|
12
|
+
import { PageID } from "../primitives/ID";
|
|
13
|
+
|
|
14
|
+
const idPxx = () => {
|
|
15
|
+
const id = PageID.create();
|
|
16
|
+
const prefix = PagePrefix.fromStringOrThrow("pxx");
|
|
17
|
+
return { id, prefix: prefix };
|
|
18
|
+
};
|
|
19
|
+
export namespace RuleBuilderTestUtils {
|
|
20
|
+
export const createOptions = () => [
|
|
21
|
+
BuilderOption.create(0, "Nei"),
|
|
22
|
+
BuilderOption.create(1, "Ja"),
|
|
23
|
+
BuilderOption.create(9, "Vet ikke"),
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const excludeByTagAction = (tag: string) => {
|
|
27
|
+
const pageCount = Math.floor(Math.random() * 10);
|
|
28
|
+
const action: ExcludeByTagAction = {
|
|
29
|
+
kind: "exclude-by-tag",
|
|
30
|
+
tag,
|
|
31
|
+
description: "Description for tag: " + tag,
|
|
32
|
+
pageCount,
|
|
33
|
+
};
|
|
34
|
+
return action;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const excludeByPageIdAction = (pageId: PageID, pageNumber: number) => {
|
|
38
|
+
const pagePrefix = PagePrefix.castOrCreateRandom("").value;
|
|
39
|
+
const action: ExcludeByPageAction = {
|
|
40
|
+
kind: "exclude-by-pageId",
|
|
41
|
+
mainText: "",
|
|
42
|
+
pageId,
|
|
43
|
+
pagePrefix,
|
|
44
|
+
pageNumber,
|
|
45
|
+
};
|
|
46
|
+
return action;
|
|
47
|
+
};
|
|
48
|
+
export const jumpToPageAction = (pageId: PageID, pageNumber: number) => {
|
|
49
|
+
const pagePrefix = PagePrefix.castOrCreateRandom("").value;
|
|
50
|
+
const action: JumpToPageAction = {
|
|
51
|
+
kind: "jump-to-page",
|
|
52
|
+
mainText: "TEXT: " + pageId,
|
|
53
|
+
pagePrefix,
|
|
54
|
+
pageId,
|
|
55
|
+
pageNumber,
|
|
56
|
+
};
|
|
57
|
+
return action;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const excludeByTagActionList = () => {
|
|
61
|
+
const list = [
|
|
62
|
+
excludeByTagAction("tag1"),
|
|
63
|
+
excludeByTagAction("tag2"),
|
|
64
|
+
excludeByTagAction("tag3"),
|
|
65
|
+
excludeByTagAction("tag4"),
|
|
66
|
+
excludeByTagAction("tag5"),
|
|
67
|
+
excludeByTagAction("tag6"),
|
|
68
|
+
excludeByTagAction("tag7"),
|
|
69
|
+
excludeByTagAction("tag8"),
|
|
70
|
+
excludeByTagAction("tag9"),
|
|
71
|
+
excludeByTagAction("tag10"),
|
|
72
|
+
] as const;
|
|
73
|
+
return list;
|
|
74
|
+
};
|
|
75
|
+
export const createRuleVariable = (varId: VarID, pageNumber: number): RuleQuestionVariable =>
|
|
76
|
+
new RuleQuestionVariable(varId, "Har du " + varId + "?", createOptions(), pageNumber);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
export const createPagesAndVars_A_H = (schemaPrefix: SchemaPrefix) => {
|
|
82
|
+
const varId = (pagePrefix: string) => {
|
|
83
|
+
const pxx = PagePrefix.fromStringOrThrow(pagePrefix);
|
|
84
|
+
const qxx = VarID.create(schemaPrefix.value, pxx);
|
|
85
|
+
return qxx;
|
|
86
|
+
};
|
|
87
|
+
const pageAID = PageID.create();
|
|
88
|
+
const pageBID = PageID.create();
|
|
89
|
+
const pageCID = PageID.create();
|
|
90
|
+
const pageDID = PageID.create();
|
|
91
|
+
const pageEID = PageID.create();
|
|
92
|
+
const pageFID = PageID.create();
|
|
93
|
+
const pageGID = PageID.create();
|
|
94
|
+
const pageHID = PageID.create();
|
|
95
|
+
const a = createRuleVariable(varId("a"), 3);
|
|
96
|
+
const b = createRuleVariable(varId("b"), 4);
|
|
97
|
+
const c = createRuleVariable(varId("c"), 5);
|
|
98
|
+
const d = createRuleVariable(varId("d"), 6);
|
|
99
|
+
const e = createRuleVariable(varId("e"), 7);
|
|
100
|
+
const f = createRuleVariable(varId("f"), 8);
|
|
101
|
+
const g = createRuleVariable(varId("g"), 9);
|
|
102
|
+
const h = createRuleVariable(varId("h"), 10);
|
|
103
|
+
const list = [a, b, c, d, e, f, g, h];
|
|
104
|
+
const items = { a, b, c, d, e, f, g, h };
|
|
105
|
+
const pageIds = {
|
|
106
|
+
a: pageAID,
|
|
107
|
+
b: pageBID,
|
|
108
|
+
c: pageCID,
|
|
109
|
+
d: pageDID,
|
|
110
|
+
e: pageEID,
|
|
111
|
+
f: pageFID,
|
|
112
|
+
g: pageGID,
|
|
113
|
+
|
|
114
|
+
h: pageHID,
|
|
115
|
+
};
|
|
116
|
+
const pageIdList = [pageAID, pageBID, pageCID, pageDID, pageEID, pageFID, pageGID, pageHID];
|
|
117
|
+
return { list, items, pageIds, pageIdList };
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const createConditionDto = (variable: RuleVariable): BuilderConditionDto => {
|
|
121
|
+
const operator: BuilderOperator = Math.random() > 0 ? "equal" : "notEqual";
|
|
122
|
+
const opt = variable.options[0];
|
|
123
|
+
return {
|
|
124
|
+
kind: "condition",
|
|
125
|
+
name: "condition 1",
|
|
126
|
+
variableId: variable.varId,
|
|
127
|
+
operator,
|
|
128
|
+
value: opt.value,
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const createConditionGroupDto = (
|
|
133
|
+
conditions: BuilderConditionDto[],
|
|
134
|
+
): BuilderConditionGroupDto => {
|
|
135
|
+
return {
|
|
136
|
+
kind: "condition-group",
|
|
137
|
+
conditions,
|
|
138
|
+
type: "all",
|
|
139
|
+
name: "random-group-name",
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const createBuilderRuleDto = (
|
|
144
|
+
schemaPrefix: SchemaPrefix,
|
|
145
|
+
): ReadonlyArray<BuilderRuleDto> => {
|
|
146
|
+
const v = createPagesAndVars_A_H(schemaPrefix);
|
|
147
|
+
const condition0 = createConditionDto(v.items.a);
|
|
148
|
+
const condition1 = createConditionDto(v.items.b);
|
|
149
|
+
const condition3 = createConditionDto(v.items.c);
|
|
150
|
+
const condition5 = createConditionDto(v.items.e);
|
|
151
|
+
const group = createConditionGroupDto([condition0, condition3]);
|
|
152
|
+
// const action1: Exc
|
|
153
|
+
const rule: BuilderRuleDto = {
|
|
154
|
+
name: "rule-name",
|
|
155
|
+
conditions: [condition1, group, condition5],
|
|
156
|
+
excludeTags: [],
|
|
157
|
+
excludePages: [],
|
|
158
|
+
jumpToPage: false,
|
|
159
|
+
type: "all",
|
|
160
|
+
};
|
|
161
|
+
return [];
|
|
162
|
+
};
|
|
163
|
+
export const createExcludeByPageIdList = (): ReadonlyArray<ExcludeByPageIdSelectItem> => [
|
|
164
|
+
ExcludeByPageIdSelectItem.create(
|
|
165
|
+
{
|
|
166
|
+
kind: "exclude-by-pageId",
|
|
167
|
+
pageId: idPxx().id,
|
|
168
|
+
pagePrefix: idPxx().prefix,
|
|
169
|
+
pageNumber: 5,
|
|
170
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
171
|
+
},
|
|
172
|
+
false,
|
|
173
|
+
),
|
|
174
|
+
|
|
175
|
+
ExcludeByPageIdSelectItem.create(
|
|
176
|
+
{
|
|
177
|
+
kind: "exclude-by-pageId",
|
|
178
|
+
pageId: idPxx().id,
|
|
179
|
+
pagePrefix: idPxx().prefix,
|
|
180
|
+
pageNumber: 5,
|
|
181
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
182
|
+
},
|
|
183
|
+
true,
|
|
184
|
+
),
|
|
185
|
+
|
|
186
|
+
ExcludeByPageIdSelectItem.create(
|
|
187
|
+
{
|
|
188
|
+
kind: "exclude-by-pageId",
|
|
189
|
+
pageId: idPxx().id,
|
|
190
|
+
pagePrefix: idPxx().prefix,
|
|
191
|
+
pageNumber: 5,
|
|
192
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
193
|
+
},
|
|
194
|
+
false,
|
|
195
|
+
),
|
|
196
|
+
|
|
197
|
+
ExcludeByPageIdSelectItem.create(
|
|
198
|
+
{
|
|
199
|
+
kind: "exclude-by-pageId",
|
|
200
|
+
pageId: idPxx().id,
|
|
201
|
+
pagePrefix: idPxx().prefix,
|
|
202
|
+
pageNumber: 5,
|
|
203
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
204
|
+
},
|
|
205
|
+
false,
|
|
206
|
+
),
|
|
207
|
+
|
|
208
|
+
ExcludeByPageIdSelectItem.create(
|
|
209
|
+
{
|
|
210
|
+
kind: "exclude-by-pageId",
|
|
211
|
+
pageId: idPxx().id,
|
|
212
|
+
pagePrefix: idPxx().prefix,
|
|
213
|
+
pageNumber: 5,
|
|
214
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
215
|
+
},
|
|
216
|
+
true,
|
|
217
|
+
),
|
|
218
|
+
ExcludeByPageIdSelectItem.create(
|
|
219
|
+
{
|
|
220
|
+
kind: "exclude-by-pageId",
|
|
221
|
+
pageId: idPxx().id,
|
|
222
|
+
pagePrefix: idPxx().prefix,
|
|
223
|
+
pageNumber: 5,
|
|
224
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
225
|
+
},
|
|
226
|
+
false,
|
|
227
|
+
),
|
|
228
|
+
|
|
229
|
+
ExcludeByPageIdSelectItem.create(
|
|
230
|
+
{
|
|
231
|
+
kind: "exclude-by-pageId",
|
|
232
|
+
pageId: idPxx().id,
|
|
233
|
+
pagePrefix: idPxx().prefix,
|
|
234
|
+
pageNumber: 5,
|
|
235
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
236
|
+
},
|
|
237
|
+
true,
|
|
238
|
+
),
|
|
239
|
+
|
|
240
|
+
ExcludeByPageIdSelectItem.create(
|
|
241
|
+
{
|
|
242
|
+
kind: "exclude-by-pageId",
|
|
243
|
+
pageId: idPxx().id,
|
|
244
|
+
pagePrefix: idPxx().prefix,
|
|
245
|
+
pageNumber: 5,
|
|
246
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
247
|
+
},
|
|
248
|
+
false,
|
|
249
|
+
),
|
|
250
|
+
|
|
251
|
+
ExcludeByPageIdSelectItem.create(
|
|
252
|
+
{
|
|
253
|
+
kind: "exclude-by-pageId",
|
|
254
|
+
pageId: idPxx().id,
|
|
255
|
+
pagePrefix: idPxx().prefix,
|
|
256
|
+
pageNumber: 5,
|
|
257
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
258
|
+
},
|
|
259
|
+
false,
|
|
260
|
+
),
|
|
261
|
+
|
|
262
|
+
ExcludeByPageIdSelectItem.create(
|
|
263
|
+
{
|
|
264
|
+
kind: "exclude-by-pageId",
|
|
265
|
+
pageId: idPxx().id,
|
|
266
|
+
pagePrefix: idPxx().prefix,
|
|
267
|
+
pageNumber: 5,
|
|
268
|
+
mainText: "Har du noen gang vært deprimeri?? ",
|
|
269
|
+
},
|
|
270
|
+
true,
|
|
271
|
+
),
|
|
272
|
+
];
|
|
273
|
+
export const createExcludeByTagList = () => [
|
|
274
|
+
ExcludeByTagSelectItem.create(
|
|
275
|
+
{
|
|
276
|
+
kind: "exclude-by-tag",
|
|
277
|
+
tag: "Can_read",
|
|
278
|
+
pageCount: 5,
|
|
279
|
+
description: "",
|
|
280
|
+
},
|
|
281
|
+
false,
|
|
282
|
+
),
|
|
283
|
+
ExcludeByTagSelectItem.create(
|
|
284
|
+
{
|
|
285
|
+
kind: "exclude-by-tag",
|
|
286
|
+
tag: "Is grownup",
|
|
287
|
+
pageCount: 1,
|
|
288
|
+
description: "",
|
|
289
|
+
},
|
|
290
|
+
true,
|
|
291
|
+
),
|
|
292
|
+
ExcludeByTagSelectItem.create(
|
|
293
|
+
{
|
|
294
|
+
kind: "exclude-by-tag",
|
|
295
|
+
tag: "speaks english",
|
|
296
|
+
pageCount: 3,
|
|
297
|
+
description: "",
|
|
298
|
+
},
|
|
299
|
+
false,
|
|
300
|
+
),
|
|
301
|
+
ExcludeByTagSelectItem.create(
|
|
302
|
+
{
|
|
303
|
+
kind: "exclude-by-tag",
|
|
304
|
+
tag: "has work",
|
|
305
|
+
pageCount: 7,
|
|
306
|
+
description: "",
|
|
307
|
+
},
|
|
308
|
+
false,
|
|
309
|
+
),
|
|
310
|
+
ExcludeByTagSelectItem.create(
|
|
311
|
+
{
|
|
312
|
+
kind: "exclude-by-tag",
|
|
313
|
+
tag: "is-depressed",
|
|
314
|
+
pageCount: 2,
|
|
315
|
+
description: "",
|
|
316
|
+
},
|
|
317
|
+
false,
|
|
318
|
+
),
|
|
319
|
+
];
|
|
320
|
+
}
|