@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.
Files changed (44) hide show
  1. package/package.json +15 -15
  2. package/src/Builder-option.ts +64 -64
  3. package/src/Builder-page.spec.ts +2 -160
  4. package/src/Builder-page.ts +6 -83
  5. package/src/Builder-question.spec.ts +68 -68
  6. package/src/Builder-question.ts +102 -102
  7. package/src/Builder-schema.spec.ts +86 -114
  8. package/src/Builder-schema.ts +13 -9
  9. package/src/Builder-text.spec.ts +24 -24
  10. package/src/Builder-text.ts +57 -57
  11. package/src/BuilderObject.ts +30 -29
  12. package/src/BuilderTag.ts +96 -96
  13. package/src/builder-compiler.ts +1 -1
  14. package/src/code-book/codebook-variable.ts +29 -0
  15. package/src/{codebook.ts → code-book/codebook.ts} +72 -72
  16. package/src/primitives/ID.spec.ts +39 -39
  17. package/src/primitives/ID.ts +138 -119
  18. package/src/primitives/page-prefix.ts +59 -59
  19. package/src/primitives/varID.ts +12 -12
  20. package/src/public-api.ts +28 -26
  21. package/src/rulebuilder/Builder-rule.spec.ts +323 -323
  22. package/src/rulebuilder/Builder-rule.ts +191 -191
  23. package/src/rulebuilder/RuleBuilder-test-utils.ts +320 -320
  24. package/src/rulebuilder/RuleInput.ts +30 -30
  25. package/src/rulebuilder/RuleVariable.ts +34 -48
  26. package/src/rulebuilder/SingleSelectItem.ts +9 -8
  27. package/src/rulebuilder/condition/Builder-condition-group.ts +14 -6
  28. package/src/rulebuilder/condition/Builder-condition.spec.ts +12 -12
  29. package/src/rulebuilder/condition/Builder-condition.ts +17 -13
  30. package/src/rulebuilder/index.ts +16 -3
  31. package/src/rulebuilder/page-action-manager.ts +33 -33
  32. package/src/rulebuilder/rule2/Rule2.ts +211 -215
  33. package/src/schema-config.ts +25 -25
  34. package/src/sum-score/sum-score-answer.ts +6 -0
  35. package/src/sum-score/sum-score-manager.spec.ts +189 -0
  36. package/src/sum-score/sum-score-manager.ts +154 -0
  37. package/src/sum-score/sum-score-membership.ts +45 -0
  38. package/src/sum-score/sum-score-variable.spec.ts +151 -0
  39. package/src/sum-score/sum-score-variable.ts +36 -0
  40. package/src/{variable → sum-score}/sum-score.ts +122 -130
  41. package/tsconfig.tsbuildinfo +1 -1
  42. package/src/variable/b-variable.ts +0 -68
  43. package/src/variable/mq-variable.spec.ts +0 -147
  44. package/src/variable/sum-score-variable.ts +0 -50
@@ -1,44 +1,44 @@
1
- import type { QuestionVariable, CustomVariable, BuilderVariable } from "./RuleVariable";
1
+ import type { RuleQuestionVariable, RuleCustomVariable, RuleVariable } from "./RuleVariable";
2
2
  import type { ExcludeByPageAction, ExcludeByTagAction, JumpToPageAction } from "./RuleAction";
3
3
  import { JumpToPageSelectItem } from "./SingleSelectItem";
4
4
 
5
5
  /**
6
- * TODO Crate filters for "cardinality" or "order" of a variable;
6
+ * TODO Crate filters for "cardinality" or "order" of a sum-score;
7
7
  * Return legal lists of variables.
8
8
  */
9
9
  export class RuleInput {
10
- constructor(
11
- private readonly _questionVariables: ReadonlyArray<QuestionVariable>,
12
- private readonly _customVariables: ReadonlyArray<CustomVariable>,
13
- private readonly _pageIdActions: ReadonlyArray<ExcludeByPageAction>,
14
- private readonly _tagActions: ReadonlyArray<ExcludeByTagAction>,
15
- private readonly _jumpActions: ReadonlyArray<JumpToPageAction>
16
- ) {}
10
+ constructor(
11
+ private readonly _questionVariables: ReadonlyArray<RuleQuestionVariable>,
12
+ private readonly _customVariables: ReadonlyArray<RuleCustomVariable>,
13
+ private readonly _pageIdActions: ReadonlyArray<ExcludeByPageAction>,
14
+ private readonly _tagActions: ReadonlyArray<ExcludeByTagAction>,
15
+ private readonly _jumpActions: ReadonlyArray<JumpToPageAction>,
16
+ ) {}
17
17
 
18
- get questionVars(): ReadonlyArray<QuestionVariable> {
19
- return this._questionVariables;
20
- }
18
+ get questionVars(): ReadonlyArray<RuleVariable> {
19
+ return this._questionVariables;
20
+ }
21
21
 
22
- getConditionInput(): ReadonlyArray<BuilderVariable> {
23
- return [...this.questionVars, ...this.customVars];
24
- }
22
+ getConditionInput(): ReadonlyArray<RuleVariable> {
23
+ return [...this.questionVars, ...this.customVars];
24
+ }
25
25
 
26
- getJumpToPageOptions(): ReadonlyArray<JumpToPageSelectItem> {
27
- return this._jumpActions.map(JumpToPageSelectItem.create);
28
- }
26
+ getJumpToPageOptions(): ReadonlyArray<JumpToPageSelectItem> {
27
+ return this._jumpActions.map(JumpToPageSelectItem.create);
28
+ }
29
29
 
30
- get customVars(): ReadonlyArray<CustomVariable> {
31
- return this._customVariables;
32
- }
30
+ get customVars(): ReadonlyArray<RuleCustomVariable> {
31
+ return this._customVariables;
32
+ }
33
33
 
34
- get excludeByPageIdActions() {
35
- return this._pageIdActions;
36
- }
34
+ get excludeByPageIdActions() {
35
+ return this._pageIdActions;
36
+ }
37
37
 
38
- get excludeByTagActions() {
39
- return this._tagActions;
40
- }
41
- get jumpToPageActions() {
42
- return this._jumpActions;
43
- }
38
+ get excludeByTagActions() {
39
+ return this._tagActions;
40
+ }
41
+ get jumpToPageActions() {
42
+ return this._jumpActions;
43
+ }
44
44
  }
@@ -1,48 +1,34 @@
1
- import { VarID } from "../primitives/varID";
2
-
3
- const BuilderVariableType = {
4
- numericWithOptions: true,
5
- numeric: true,
6
- numericRange: true,
7
- text: true,
8
- date: true,
9
- dateRange: true,
10
- time: true,
11
- duration: true,
12
- boolean: true,
13
- } as const;
14
-
15
- export type BuilderVariableType = keyof typeof BuilderVariableType;
16
-
17
- export class BuilderVariableOption {
18
- constructor(
19
- readonly label: string,
20
- readonly value: number,
21
- ) {}
22
- }
23
-
24
- export class QuestionVariable {
25
- readonly kind: "question-variable" = "question-variable";
26
- readonly dataType: BuilderVariableType = "numericWithOptions";
27
-
28
- constructor(
29
- // private schemaPrefix: SchemaPrefix,
30
- // private pagePrefix: PagePrefix,
31
- readonly varId: VarID,
32
- readonly label: string,
33
- readonly options: ReadonlyArray<BuilderVariableOption>,
34
- readonly pageNumber: number,
35
- ) {}
36
- }
37
-
38
- export class CustomVariable {
39
- readonly kind: "configuration-variable" = "configuration-variable";
40
- readonly dataType: BuilderVariableType = "numericWithOptions";
41
- constructor(
42
- readonly varId: VarID,
43
- readonly label: string,
44
- readonly options: ReadonlyArray<BuilderVariableOption>,
45
- ) {}
46
- }
47
-
48
- export type BuilderVariable = QuestionVariable | CustomVariable;
1
+ import { VarID } from "../primitives/varID";
2
+
3
+ /*******************************************
4
+ ** ONLY USE THESE TYPES IN RULE-BUILDER **
5
+ ******************************************/
6
+
7
+ export class RuleVariableOption {
8
+ constructor(
9
+ readonly label: string,
10
+ readonly value: number,
11
+ ) {}
12
+ }
13
+
14
+ export class RuleQuestionVariable {
15
+ readonly kind: "question-variable" = "question-variable";
16
+ constructor(
17
+ readonly varId: VarID,
18
+ readonly label: string,
19
+ readonly options: ReadonlyArray<RuleVariableOption>,
20
+ readonly pageNumber: number,
21
+ ) {}
22
+ }
23
+
24
+ export class RuleCustomVariable {
25
+ readonly kind: "configuration-variable" = "configuration-variable";
26
+ constructor(
27
+ readonly varId: string,
28
+ readonly label: string,
29
+ readonly options: ReadonlyArray<RuleVariableOption>,
30
+ ) {}
31
+ }
32
+
33
+ // export class RuleVariable {}
34
+ export type RuleVariable = RuleQuestionVariable | RuleCustomVariable;
@@ -1,4 +1,4 @@
1
- import { BuilderVariable, BuilderVariableOption } from "./RuleVariable";
1
+ import { RuleVariable, RuleVariableOption } from "./RuleVariable";
2
2
  import { BuilderOperator } from "./condition/Builder-operator";
3
3
  import { JumpToPageAction } from "./RuleAction";
4
4
 
@@ -27,12 +27,12 @@ export abstract class SingleSelectItem<T> {
27
27
  protected abstract getSearchString(): string;
28
28
  }
29
29
 
30
- export class RuleVariableSelectItem extends SingleSelectItem<BuilderVariable> {
31
- public static create = (data: BuilderVariable) => {
30
+ export class RuleVariableSelectItem extends SingleSelectItem<RuleVariable> {
31
+ public static create = (data: RuleVariable) => {
32
32
  return new RuleVariableSelectItem(data);
33
33
  };
34
34
  readonly options: ReadonlyArray<RuleOptionSelectItem>;
35
- constructor(readonly data: BuilderVariable) {
35
+ constructor(readonly data: RuleVariable) {
36
36
  super(data);
37
37
  this.options = data.options.map(RuleOptionSelectItem.create);
38
38
  }
@@ -50,11 +50,11 @@ export class RuleVariableSelectItem extends SingleSelectItem<BuilderVariable> {
50
50
  }
51
51
  }
52
52
 
53
- export class RuleOptionSelectItem extends SingleSelectItem<BuilderVariableOption> {
54
- public static create = (option: BuilderVariableOption) => {
53
+ export class RuleOptionSelectItem extends SingleSelectItem<RuleVariableOption> {
54
+ public static create = (option: RuleVariableOption) => {
55
55
  return new RuleOptionSelectItem(option);
56
56
  };
57
- private constructor(option: BuilderVariableOption) {
57
+ private constructor(option: RuleVariableOption) {
58
58
  super(option);
59
59
  }
60
60
  protected getSearchString(): string {
@@ -116,7 +116,8 @@ export class OperatorSelectItem extends SingleSelectItem<BuilderOperator | ""> {
116
116
  }
117
117
 
118
118
  export class JumpToPageSelectItem extends SingleSelectItem<JumpToPageAction> {
119
- public static readonly create = (pageData: JumpToPageAction) => new JumpToPageSelectItem(pageData);
119
+ public static readonly create = (pageData: JumpToPageAction) =>
120
+ new JumpToPageSelectItem(pageData);
120
121
  protected constructor(pageData: JumpToPageAction) {
121
122
  super(pageData);
122
123
  }
@@ -1,6 +1,6 @@
1
1
  import { BuilderCondition, type BuilderConditionDto } from "./Builder-condition";
2
2
  import { BuilderObject } from "../../BuilderObject";
3
- import type { BuilderVariable } from "../RuleVariable";
3
+ import type { RuleVariable } from "../RuleVariable";
4
4
  import { Condition } from "@media-quest/engine";
5
5
 
6
6
  const ConditionGroupType = {
@@ -18,7 +18,10 @@ export interface BuilderConditionGroupDto {
18
18
  readonly conditions: ReadonlyArray<BuilderConditionDto>;
19
19
  }
20
20
 
21
- export class BuilderConditionGroup extends BuilderObject<"builder-condition-group", BuilderConditionGroupDto> {
21
+ export class BuilderConditionGroup extends BuilderObject<
22
+ "builder-condition-group",
23
+ BuilderConditionGroupDto
24
+ > {
22
25
  static readonly isConditionGroupType = (value: string | symbol): value is ConditionGroupType => {
23
26
  if (typeof value !== "string") {
24
27
  return false;
@@ -31,12 +34,15 @@ export class BuilderConditionGroup extends BuilderObject<"builder-condition-grou
31
34
  private _type: ConditionGroupType;
32
35
  name = "";
33
36
  private readonly _conditions: Array<BuilderCondition>;
34
- private readonly _variableList: ReadonlyArray<BuilderVariable>;
37
+ private readonly _variableList: ReadonlyArray<RuleVariable>;
35
38
 
36
- public static readonly fromDto = (dto: BuilderConditionGroupDto, variableList: ReadonlyArray<BuilderVariable>) => {
39
+ public static readonly fromDto = (
40
+ dto: BuilderConditionGroupDto,
41
+ variableList: ReadonlyArray<RuleVariable>,
42
+ ) => {
37
43
  return new BuilderConditionGroup(dto, variableList);
38
44
  };
39
- protected constructor(dto: BuilderConditionGroupDto, variableList: ReadonlyArray<BuilderVariable>) {
45
+ protected constructor(dto: BuilderConditionGroupDto, variableList: ReadonlyArray<RuleVariable>) {
40
46
  super(dto);
41
47
  this.name = dto.name;
42
48
  this._type = dto.type;
@@ -73,7 +79,9 @@ export class BuilderConditionGroup extends BuilderObject<"builder-condition-grou
73
79
  }
74
80
 
75
81
  toJson(): BuilderConditionGroupDto {
76
- const conditions: ReadonlyArray<BuilderConditionDto> = [...this._conditions.map((c) => c.toJson())];
82
+ const conditions: ReadonlyArray<BuilderConditionDto> = [
83
+ ...this._conditions.map((c) => c.toJson()),
84
+ ];
77
85
  return {
78
86
  name: this.name,
79
87
  conditions,
@@ -1,7 +1,7 @@
1
1
  import { BuilderCondition, type BuilderConditionDto } from "./Builder-condition";
2
2
  import { RuleBuilderTestUtils } from "../RuleBuilder-test-utils";
3
- import type { BuilderVariable, BuilderVariableOption } from "../RuleVariable";
4
- import { QuestionVariable } from "../RuleVariable";
3
+ import { type RuleVariable, RuleVariableOption, RuleQuestionVariable } from "../RuleVariable";
4
+ // import { QuestionVariable } from "../RuleVariable";
5
5
 
6
6
  import { SchemaPrefix } from "../../primitives/schema-prefix";
7
7
 
@@ -77,9 +77,9 @@ describe("Builder Operator", () => {
77
77
  value: 0,
78
78
  };
79
79
  const c = BuilderCondition.fromDto(dto, vs.list);
80
- expect(c.variable).toBeInstanceOf(QuestionVariable);
80
+ expect(c.variable).toBeInstanceOf(RuleQuestionVariable);
81
81
  expect(c.operator === "equal").toBe(true);
82
- const value = c.value as BuilderVariableOption;
82
+ const value = c.value as RuleVariableOption;
83
83
  expect(value.value).toBe(0);
84
84
  expect(value.label).toBe("Nei");
85
85
  expect(c.variable).toBe(a);
@@ -96,9 +96,9 @@ describe("Builder Operator", () => {
96
96
  value: 0,
97
97
  };
98
98
  const c = BuilderCondition.fromDto(dto, vs.list);
99
- expect(c.variable).toBeInstanceOf(QuestionVariable);
99
+ expect(c.variable).toBeInstanceOf(RuleQuestionVariable);
100
100
  expect(c.operator === "equal").toBe(true);
101
- const value = c.value as BuilderVariableOption;
101
+ const value = c.value as RuleVariableOption;
102
102
  expect(value.value).toBe(0);
103
103
  expect(value.label).toBe("Nei");
104
104
  expect(c.validate().isValid).toBe(true);
@@ -114,7 +114,7 @@ describe("Builder Operator", () => {
114
114
  const c = BuilderCondition.fromDto(dto, []);
115
115
  expect(c.validate().isValid).toBe(false);
116
116
  });
117
- test("Condition is invalid, when variable dont exist in universe.", () => {
117
+ test("Condition is invalid, when sum-score dont exist in universe.", () => {
118
118
  const variables = RuleBuilderTestUtils.createPagesAndVars_A_H(as);
119
119
  const dto: BuilderConditionDto = {
120
120
  kind: "condition",
@@ -127,7 +127,7 @@ describe("Builder Operator", () => {
127
127
  expect(c.variable).toBe(false);
128
128
  expect(c.validate().isValid).toBe(false);
129
129
  });
130
- test("Condition is invalid if not all set, when variable dont exist in variables.", () => {
130
+ test("Condition is invalid if not all set, when sum-score dont exist in variables.", () => {
131
131
  const variables = RuleBuilderTestUtils.createPagesAndVars_A_H(as);
132
132
  const dto: BuilderConditionDto = {
133
133
  kind: "condition",
@@ -153,11 +153,11 @@ describe("Builder Operator", () => {
153
153
  };
154
154
  expect(a.varId).toBe("as_a");
155
155
  const c = BuilderCondition.fromDto(dto, variables.list);
156
- expect(c.variable).toBeInstanceOf(QuestionVariable);
156
+ expect(c.variable).toBeInstanceOf(RuleQuestionVariable);
157
157
  expect(c.validate().isValid).toBe(false);
158
158
  expect(c.value).toBe(false);
159
159
  });
160
- test("Condition is invalid if value (from dto) is not found in variable", () => {
160
+ test("Condition is invalid if value (from dto) is not found in sum-score", () => {
161
161
  const { list, items } = RuleBuilderTestUtils.createPagesAndVars_A_H(as);
162
162
  expect(items.a.varId).toBe("as_a");
163
163
  const dto: BuilderConditionDto = {
@@ -169,7 +169,7 @@ describe("Builder Operator", () => {
169
169
  };
170
170
  const c = BuilderCondition.fromDto(dto, list);
171
171
  expect(c).toBeInstanceOf(BuilderCondition);
172
- expect(c.variable).toBeInstanceOf(QuestionVariable);
172
+ expect(c.variable).toBeInstanceOf(RuleQuestionVariable);
173
173
  expect(c.operator).toBe("equal");
174
174
  expect(c.operatorsSelectItems.length).toBe(BuilderCondition.NUMBER_OPERATORS.length);
175
175
  expect(c.value).toBe(false);
@@ -186,7 +186,7 @@ describe("Builder Operator", () => {
186
186
  value: 7,
187
187
  };
188
188
  const c = BuilderCondition.fromDto(dto, variables.list);
189
- expect(c.variable).toBeInstanceOf(QuestionVariable);
189
+ expect(c.variable).toBeInstanceOf(RuleQuestionVariable);
190
190
  expect(c.operator).toBe("equal");
191
191
  expect(c.operatorsSelectItems.length).toBe(BuilderCondition.NUMBER_OPERATORS.length);
192
192
  expect(c.value).toBe(false);
@@ -1,7 +1,11 @@
1
1
  import { BuilderObject } from "../../BuilderObject";
2
2
  import { BuilderOperator } from "./Builder-operator";
3
- import type { BuilderVariable, BuilderVariableOption } from "../RuleVariable";
4
- import { OperatorSelectItem, RuleOptionSelectItem, RuleVariableSelectItem } from "../SingleSelectItem";
3
+ import type { RuleVariable, RuleVariableOption } from "../RuleVariable";
4
+ import {
5
+ OperatorSelectItem,
6
+ RuleOptionSelectItem,
7
+ RuleVariableSelectItem,
8
+ } from "../SingleSelectItem";
5
9
  import { Condition } from "@media-quest/engine";
6
10
  export interface BuilderConditionDto {
7
11
  readonly kind: "condition";
@@ -21,7 +25,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
21
25
  private initialDto: BuilderConditionDto;
22
26
  name = "";
23
27
 
24
- public static create = (variableList: ReadonlyArray<BuilderVariable>) => {
28
+ public static create = (variableList: ReadonlyArray<RuleVariable>) => {
25
29
  const condition = new BuilderCondition(
26
30
  {
27
31
  kind: "condition",
@@ -35,7 +39,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
35
39
  return condition;
36
40
  };
37
41
 
38
- public static fromDto = (dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) => {
42
+ public static fromDto = (dto: BuilderConditionDto, variables: ReadonlyArray<RuleVariable>) => {
39
43
  const _dto: BuilderConditionDto = {
40
44
  kind: "condition",
41
45
  name: dto.name ?? "",
@@ -46,16 +50,16 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
46
50
  const instance = new BuilderCondition(_dto, variables);
47
51
  return instance;
48
52
  };
49
- private _variable: BuilderVariable | false = false;
53
+ private _variable: RuleVariable | false = false;
50
54
  private _operator: BuilderOperator | "" = "";
51
- private _value: BuilderVariableOption | false = false;
52
- private _variableList: ReadonlyArray<BuilderVariable> = [];
55
+ private _value: RuleVariableOption | false = false;
56
+ private _variableList: ReadonlyArray<RuleVariable> = [];
53
57
 
54
58
  /**
55
59
  * Can only set variables that exist in variableList.
56
60
  * @param variable
57
61
  */
58
- set variable(variable: BuilderVariable | false) {
62
+ set variable(variable: RuleVariable | false) {
59
63
  if (variable === this._variable) {
60
64
  return;
61
65
  }
@@ -68,7 +72,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
68
72
  return this._variable;
69
73
  }
70
74
 
71
- set value(variableValue: BuilderVariableOption | false) {
75
+ set value(variableValue: RuleVariableOption | false) {
72
76
  this._value = variableValue;
73
77
  }
74
78
  get value() {
@@ -96,7 +100,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
96
100
  if (!this._value) {
97
101
  return {
98
102
  isValid: false,
99
- message: "Value (BuilderVariableOption) is not initialized",
103
+ message: "Value (RuleVariableOption) is not initialized",
100
104
  };
101
105
  }
102
106
 
@@ -124,7 +128,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
124
128
  return false;
125
129
  }
126
130
 
127
- private findVariableInUniverse(variableId: string): BuilderVariable | false {
131
+ private findVariableInUniverse(variableId: string): RuleVariable | false {
128
132
  const v = this._variableList.find((v) => v.varId === variableId);
129
133
  return v ?? false;
130
134
  }
@@ -141,7 +145,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
141
145
  return this._operator;
142
146
  }
143
147
 
144
- private constructor(dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) {
148
+ private constructor(dto: BuilderConditionDto, variables: ReadonlyArray<RuleVariable>) {
145
149
  super(dto);
146
150
  this.initialDto = dto;
147
151
  this.name = dto.name;
@@ -168,7 +172,7 @@ export class BuilderCondition extends BuilderObject<"builder-condition", Builder
168
172
  return this.toJson();
169
173
  }
170
174
 
171
- private _setVariableList(variables: ReadonlyArray<BuilderVariable>): boolean {
175
+ private _setVariableList(variables: ReadonlyArray<RuleVariable>): boolean {
172
176
  this._variableList = variables;
173
177
  const v = this._variableList.find((v) => v.varId === this.originalDto.variableId);
174
178
  if (!v) {
@@ -7,11 +7,24 @@ export {
7
7
  export { BuilderOperator } from "./condition/Builder-operator";
8
8
  export { BuilderRule, type BuilderRuleDto } from "./Builder-rule";
9
9
  export { JumpToActionManager } from "./jump-to-action-manager";
10
- export { MultiSelectItem, ExcludeByPageIdSelectItem, ExcludeByTagSelectItem } from "./multi-select-item";
10
+ export {
11
+ MultiSelectItem,
12
+ ExcludeByPageIdSelectItem,
13
+ ExcludeByTagSelectItem,
14
+ } from "./multi-select-item";
11
15
  export { PageActionManager } from "./page-action-manager";
12
- export { type ExcludeByPageAction, type ExcludeByTagAction, type JumpToPageAction } from "./RuleAction";
16
+ export {
17
+ type ExcludeByPageAction,
18
+ type ExcludeByTagAction,
19
+ type JumpToPageAction,
20
+ } from "./RuleAction";
13
21
  export { RuleInput } from "./RuleInput";
14
- export { CustomVariable, BuilderVariableOption, type BuilderVariable, QuestionVariable } from "./RuleVariable";
22
+ export {
23
+ RuleCustomVariable,
24
+ RuleVariableOption,
25
+ type RuleVariable,
26
+ RuleQuestionVariable,
27
+ } from "./RuleVariable";
15
28
  export {
16
29
  SingleSelectItem,
17
30
  OperatorSelectItem,
@@ -1,33 +1,33 @@
1
- import type { RuleInput } from "./RuleInput";
2
- import { ExcludeByPageIdSelectItem } from "./multi-select-item";
3
- import { ExcludeByPageAction } from "./RuleAction";
4
- import { PageID } from "../primitives/ID";
5
-
6
- export class PageActionManager {
7
- private readonly _initialSelection: Set<string>;
8
- readonly selectItems: ReadonlyArray<ExcludeByPageIdSelectItem>;
9
-
10
- constructor(
11
- readonly validOptions: RuleInput["_pageIdActions"],
12
- readonly initialSelection: ReadonlyArray<string>,
13
- ) {
14
- this._initialSelection = new Set([...initialSelection]);
15
- this.selectItems = validOptions.map((opt) => {
16
- const isSelected = this._initialSelection.has(opt.pageId);
17
- return ExcludeByPageIdSelectItem.create(opt, isSelected);
18
- });
19
- }
20
-
21
- getCurrentSelection(): ReadonlyArray<PageID> {
22
- const selected = this.selectItems
23
- .filter((item) => item.isSelected)
24
- .map((itm) => itm.data.pageId);
25
- return selected;
26
- }
27
-
28
- getEngineAction(): ReadonlyArray<ExcludeByPageAction> {
29
- const selectItems = this.selectItems.filter((item) => item.isSelected);
30
- const actions = selectItems.map((item) => item.data);
31
- return [...actions];
32
- }
33
- }
1
+ import type { RuleInput } from "./RuleInput";
2
+ import { ExcludeByPageIdSelectItem } from "./multi-select-item";
3
+ import { ExcludeByPageAction } from "./RuleAction";
4
+ import { PageID } from "../primitives/ID";
5
+
6
+ export class PageActionManager {
7
+ private readonly _initialSelection: Set<string>;
8
+ readonly selectItems: ReadonlyArray<ExcludeByPageIdSelectItem>;
9
+
10
+ constructor(
11
+ readonly validOptions: RuleInput["_pageIdActions"],
12
+ readonly initialSelection: ReadonlyArray<string>,
13
+ ) {
14
+ this._initialSelection = new Set([...initialSelection]);
15
+ this.selectItems = validOptions.map((opt) => {
16
+ const isSelected = this._initialSelection.has(opt.pageId);
17
+ return ExcludeByPageIdSelectItem.create(opt, isSelected);
18
+ });
19
+ }
20
+
21
+ getCurrentSelection(): ReadonlyArray<PageID> {
22
+ const selected = this.selectItems
23
+ .filter((item) => item.isSelected)
24
+ .map((itm) => itm.data.pageId);
25
+ return selected;
26
+ }
27
+
28
+ getEngineAction(): ReadonlyArray<ExcludeByPageAction> {
29
+ const selectItems = this.selectItems.filter((item) => item.isSelected);
30
+ const actions = selectItems.map((item) => item.data);
31
+ return [...actions];
32
+ }
33
+ }