@media-quest/builder 0.0.1 → 0.0.2

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 (49) hide show
  1. package/dist/public-api.d.mts +634 -0
  2. package/dist/public-api.d.ts +634 -0
  3. package/dist/public-api.js +2161 -0
  4. package/dist/public-api.mjs +2129 -0
  5. package/package.json +12 -3
  6. package/src/Builder-option.ts +67 -0
  7. package/src/Builder-page.spec.ts +313 -0
  8. package/src/Builder-page.ts +249 -0
  9. package/src/Builder-question.spec.ts +68 -0
  10. package/src/Builder-question.ts +101 -0
  11. package/src/Builder-schema.spec.ts +302 -0
  12. package/src/Builder-schema.ts +250 -0
  13. package/src/Builder-text.spec.ts +24 -0
  14. package/src/Builder-text.ts +57 -0
  15. package/src/BuilderMainImageDto.ts +7 -0
  16. package/src/BuilderMainText.ts +81 -0
  17. package/src/BuilderMainVideoDto.ts +10 -0
  18. package/src/BuilderObject.ts +69 -0
  19. package/src/BuilderTag.ts +97 -0
  20. package/src/media-files.ts +28 -0
  21. package/src/public-api.ts +10 -6
  22. package/src/rulebuilder/Builder-condition-group.spec.ts +47 -0
  23. package/src/rulebuilder/Builder-condition-group.ts +109 -0
  24. package/src/rulebuilder/Builder-condition.spec.ts +169 -0
  25. package/src/rulebuilder/Builder-condition.ts +186 -0
  26. package/src/rulebuilder/Builder-operator.spec.ts +9 -0
  27. package/src/rulebuilder/Builder-operator.ts +31 -0
  28. package/src/rulebuilder/Builder-rule.spec.ts +207 -0
  29. package/src/rulebuilder/Builder-rule.ts +165 -0
  30. package/src/rulebuilder/RuleAction.ts +20 -0
  31. package/src/rulebuilder/RuleBuilder-test-utils.ts +254 -0
  32. package/src/rulebuilder/RuleInput.ts +44 -0
  33. package/src/rulebuilder/RuleVariable.ts +39 -0
  34. package/src/rulebuilder/SingleSelectItem.ts +135 -0
  35. package/src/rulebuilder/index.ts +22 -0
  36. package/src/rulebuilder/jump-to-action-manager.ts +33 -0
  37. package/src/rulebuilder/multi-select-item.ts +70 -0
  38. package/src/rulebuilder/page-action-manager.ts +20 -0
  39. package/src/rulebuilder/tag-action-manager.spec.ts +44 -0
  40. package/src/rulebuilder/tag-action-manager.ts +18 -0
  41. package/src/theme/AbstractThemeCompiler.ts +7 -0
  42. package/src/theme/IDefaultTheme.ts +178 -0
  43. package/src/theme/css-theme.ts +7 -0
  44. package/src/theme/default-theme-compiler.ts +395 -0
  45. package/src/theme/icon-urls.ts +29 -0
  46. package/src/theme/standard-props.ts +113 -0
  47. package/src/theme/theme-utils.ts +110 -0
  48. package/src/theme/theme1.spec.ts +52 -0
  49. package/tsconfig.json +0 -2
@@ -0,0 +1,634 @@
1
+ import { DStyle, SchemaDto } from '@media-quest/engine';
2
+
3
+ /**
4
+ * Builder objects are complex objects that are embedded inside
5
+ * a Builder-schema, and needs to be serialized to json. Often these objects
6
+ * are used in collections, and that is why most of them need an id.
7
+ */
8
+ type BuilderObjectType = "builder-page" | "builder-question-option" | "builder-question" | "builder-main-text" | "builder-text" | "builder-rule" | "builder-tag" | "builder-condition" | "builder-variable" | "builder-condition-group";
9
+ declare namespace BuilderObjectId {
10
+ type QuestionOptionID = string & {
11
+ __OPTION__ID__: true;
12
+ };
13
+ type QuestionID = string & {
14
+ __QUESTION__ID__: true;
15
+ };
16
+ type VideoFileID = string & {
17
+ __VIDEO__ID__: true;
18
+ };
19
+ type AudioFileID = string & {
20
+ __AUDIO__ID__: true;
21
+ };
22
+ type ImageID = string & {
23
+ __IMAGE__ID__: true;
24
+ };
25
+ type TextID = string & {
26
+ __TEXT__ID__: true;
27
+ };
28
+ type MainTextID = string & {
29
+ __MAIN__TEXT__ID__: true;
30
+ };
31
+ type PageID = string & {
32
+ __PAGE__ID__: true;
33
+ };
34
+ type TagId = string & {
35
+ __TAG__ID__: true;
36
+ };
37
+ const createTagId: () => TagId;
38
+ const mainTextId: () => MainTextID;
39
+ const textId: () => TextID;
40
+ const questionOptionId: () => QuestionOptionID;
41
+ const questionId: () => QuestionID;
42
+ const pageId: () => PageID;
43
+ }
44
+ declare abstract class BuilderObject<T extends BuilderObjectType, Dto extends {}> {
45
+ abstract readonly objectType: T;
46
+ abstract toJson(): Dto;
47
+ abstract clone(): Dto;
48
+ protected readonly originalDto: Dto;
49
+ protected constructor(dto: Dto);
50
+ }
51
+
52
+ interface CssTheme<S extends Partial<DStyle> = Partial<DStyle>> {
53
+ css: S;
54
+ cssEnabled: Partial<DStyle>;
55
+ cssDisabled: Partial<DStyle>;
56
+ }
57
+
58
+ type PStyle = Partial<DStyle>;
59
+ interface BuilderOptionTheme {
60
+ name: string;
61
+ div: CssTheme;
62
+ text1: PStyle;
63
+ text2?: CssTheme;
64
+ }
65
+
66
+ interface AudioFile {
67
+ readonly kind: "audio-file";
68
+ readonly id: string;
69
+ readonly downloadUrl: string;
70
+ readonly duration: number;
71
+ readonly originalFileName: string;
72
+ readonly name: string;
73
+ readonly size: number;
74
+ }
75
+ interface VideoFile {
76
+ readonly kind: "video-file";
77
+ readonly id: string;
78
+ readonly downloadUrl: string;
79
+ readonly duration: number;
80
+ readonly name: string;
81
+ readonly size: number;
82
+ readonly type: string;
83
+ readonly originalFileName: string;
84
+ }
85
+ interface ImageFile {
86
+ readonly kind: "image-file";
87
+ readonly id: string;
88
+ readonly downloadUrl: string;
89
+ readonly name: string;
90
+ readonly size: number;
91
+ readonly type: string;
92
+ }
93
+
94
+ interface BuilderOptionDto {
95
+ readonly id: BuilderObjectId.QuestionOptionID;
96
+ readonly value: number;
97
+ readonly label: string;
98
+ readonly labelAudio?: AudioFile;
99
+ }
100
+ declare class BuilderOption extends BuilderObject<"builder-question-option", BuilderOptionDto> {
101
+ readonly objectType = "builder-question-option";
102
+ theme: BuilderOptionTheme;
103
+ id: BuilderObjectId.QuestionOptionID;
104
+ value: number;
105
+ label: string;
106
+ private _labelAudioFile;
107
+ get labelAudioFile(): AudioFile | false;
108
+ set labelAudioFile(audioFile: AudioFile | false);
109
+ private constructor();
110
+ static create(value: number, label: string): BuilderOption;
111
+ static fromJson(dto: BuilderOptionDto): BuilderOption;
112
+ toJson(): BuilderOptionDto;
113
+ clone(): BuilderOptionDto;
114
+ }
115
+
116
+ type BuilderQuestionType = "select-one" | "select-many" | "text" | "color" | "radio" | "email" | "time" | "checkbox" | "textarea" | "date" | "numeric-range" | "duration";
117
+ interface BuilderQuestionDto {
118
+ readonly id: BuilderObjectId.QuestionID;
119
+ _type: BuilderQuestionType;
120
+ text: string;
121
+ options: ReadonlyArray<BuilderOptionDto>;
122
+ prefix: string;
123
+ }
124
+ declare class BuilderQuestion extends BuilderObject<"builder-question", BuilderQuestionDto> {
125
+ readonly objectType = "builder-question";
126
+ id: BuilderObjectId.QuestionID;
127
+ type: BuilderQuestionType;
128
+ questionText: string;
129
+ options: BuilderOption[];
130
+ prefix: string;
131
+ static create: (type: BuilderQuestionType) => BuilderQuestion;
132
+ static fromJson(dto: BuilderQuestionDto): BuilderQuestion;
133
+ private constructor();
134
+ addOption(label: string, value: number, atIndex?: number): BuilderOption;
135
+ deleteOption(option: BuilderOption): boolean;
136
+ toJson(): BuilderQuestionDto;
137
+ clone(): BuilderQuestionDto;
138
+ }
139
+
140
+ interface BuilderMainVideoDto {
141
+ readonly kind: "main-video";
142
+ readonly file: VideoFile;
143
+ mode: "autoplay" | "required" | "optional";
144
+ preDelay: number;
145
+ volume: number;
146
+ controls: boolean;
147
+ }
148
+
149
+ interface BuilderMainImageDto {
150
+ readonly kind: "main-image";
151
+ readonly file: ImageFile;
152
+ readonly overlay: {
153
+ text: string;
154
+ fontsize: number;
155
+ xPos: number;
156
+ yPos: number;
157
+ } | false;
158
+ }
159
+
160
+ interface BuilderMainTextDto {
161
+ text: string;
162
+ audioFile: AudioFile | false;
163
+ autoplay: boolean;
164
+ autoplayDelay: number;
165
+ }
166
+ declare class BuilderMainText extends BuilderObject<"builder-main-text", BuilderMainTextDto> {
167
+ readonly objectType: "builder-main-text";
168
+ autoplay: boolean;
169
+ private _audioFile;
170
+ autoplayDelay: number;
171
+ text: string;
172
+ private constructor();
173
+ get autoplayDelayInSeconds(): string;
174
+ get durationTag(): string;
175
+ static fromJson(dto: BuilderMainTextDto): BuilderMainText;
176
+ static create: () => BuilderMainText;
177
+ clone(): BuilderMainTextDto;
178
+ toJson(): BuilderMainTextDto;
179
+ get audioFile(): AudioFile | false;
180
+ set audioFile(audioFile: AudioFile | false);
181
+ }
182
+
183
+ declare const BuilderVariableType: {
184
+ readonly numericWithOptions: true;
185
+ readonly numericRange: true;
186
+ readonly text: true;
187
+ readonly date: true;
188
+ readonly dateRange: true;
189
+ readonly time: true;
190
+ readonly duration: true;
191
+ readonly boolean: true;
192
+ };
193
+ type BuilderVariableType = keyof typeof BuilderVariableType;
194
+ declare class BuilderVariableOption {
195
+ readonly label: string;
196
+ readonly value: number;
197
+ constructor(label: string, value: number);
198
+ }
199
+ declare class QuestionVariable {
200
+ readonly varId: string;
201
+ readonly label: string;
202
+ readonly options: ReadonlyArray<BuilderVariableOption>;
203
+ readonly pageNumber: number;
204
+ readonly kind: 'question-variable';
205
+ readonly dataType: BuilderVariableType;
206
+ constructor(varId: string, label: string, options: ReadonlyArray<BuilderVariableOption>, pageNumber: number);
207
+ }
208
+ declare class CustomVariable {
209
+ readonly varId: string;
210
+ readonly label: string;
211
+ readonly options: ReadonlyArray<BuilderVariableOption>;
212
+ readonly kind: 'configuration-variable';
213
+ readonly dataType: BuilderVariableType;
214
+ constructor(varId: string, label: string, options: ReadonlyArray<BuilderVariableOption>);
215
+ }
216
+ type BuilderVariable = QuestionVariable | CustomVariable;
217
+
218
+ type BuilderPageType = "info-page" | "question" | "multi-select" | "form";
219
+ interface BuilderPageDto {
220
+ readonly id: BuilderObjectId.PageID;
221
+ prefix: string;
222
+ _type: BuilderPageType;
223
+ mainText: BuilderMainTextDto;
224
+ nextButton: BuilderOptionDto;
225
+ defaultQuestion: BuilderQuestionDto;
226
+ questions: Array<BuilderQuestionDto>;
227
+ mainMedia?: BuilderMainImageDto | BuilderMainVideoDto;
228
+ autoplaySequence: Array<string>;
229
+ tags: ReadonlyArray<string>;
230
+ }
231
+ declare class BuilderPage extends BuilderObject<"builder-page", BuilderPageDto> {
232
+ readonly objectType: "builder-page";
233
+ readonly id: BuilderObjectId.PageID;
234
+ private _pageType;
235
+ private _prefix;
236
+ private _questions;
237
+ private readonly _tags;
238
+ private _backgroundColor;
239
+ mainMedia: BuilderMainVideoDto | BuilderMainImageDto | false;
240
+ defaultQuestion: BuilderQuestion;
241
+ mainText: BuilderMainText;
242
+ nextButton: BuilderOption;
243
+ static create(type: BuilderPageType, _prefix: string): BuilderPage;
244
+ static fromJson(dto: BuilderPageDto): BuilderPage;
245
+ private constructor();
246
+ insertQuestion(question: BuilderQuestion, atIndex: number): boolean;
247
+ addQuestion(type: BuilderQuestionType, atIndex?: number): BuilderQuestion;
248
+ /**
249
+ * Move a question in questions-array
250
+ * @param question (reference)
251
+ * @param toIndex
252
+ */
253
+ moveQuestion(question: BuilderQuestion, toIndex: number): boolean;
254
+ deleteQuestion(question: BuilderQuestion): void;
255
+ private updateRows;
256
+ addTag(tag: string): void;
257
+ deleteTag(tag: string): void;
258
+ set pageType(value: BuilderPageType);
259
+ getQuestionVariables(modulePrefix: string, pageNumber: number): ReadonlyArray<QuestionVariable>;
260
+ get tags(): ReadonlyArray<string>;
261
+ get pageType(): BuilderPageType;
262
+ get prefix(): string;
263
+ set prefix(value: string);
264
+ toJson(): BuilderPageDto;
265
+ clone(): BuilderPageDto;
266
+ get backgroundColor(): string;
267
+ set backgroundColor(color: string);
268
+ get questions(): ReadonlyArray<BuilderQuestion>;
269
+ }
270
+
271
+ interface ExcludeByPageAction {
272
+ readonly kind: 'exclude-by-pageId';
273
+ readonly pageId: string;
274
+ readonly mainText: string;
275
+ readonly pageNumber: number;
276
+ }
277
+ interface JumpToPageAction {
278
+ readonly kind: 'jump-to-page';
279
+ readonly pageId: string;
280
+ readonly mainText: string;
281
+ readonly pageNumber: number;
282
+ }
283
+ interface ExcludeByTagAction {
284
+ readonly kind: 'exclude-by-tag';
285
+ readonly tag: string;
286
+ readonly description: string;
287
+ readonly pageCount: number;
288
+ }
289
+
290
+ declare const BuilderOperatorSymbols: {
291
+ readonly equal: true;
292
+ readonly notEqual: true;
293
+ readonly lessThan: true;
294
+ readonly lessThanOrEqual: true;
295
+ readonly greaterThan: true;
296
+ readonly greaterThanOrEqual: true;
297
+ readonly between: true;
298
+ readonly notBetween: true;
299
+ readonly in: true;
300
+ readonly notIn: true;
301
+ readonly missing: true;
302
+ readonly notMissing: true;
303
+ readonly contains: true;
304
+ readonly notContains: true;
305
+ readonly empty: true;
306
+ readonly notEmpty: true;
307
+ readonly startsWith: true;
308
+ readonly endsWith: true;
309
+ };
310
+ type BuilderOperator = keyof typeof BuilderOperatorSymbols;
311
+ declare namespace BuilderOperator {
312
+ const is: (symbol: string) => symbol is "equal" | "notEqual" | "lessThan" | "lessThanOrEqual" | "greaterThan" | "greaterThanOrEqual" | "between" | "notBetween" | "in" | "notIn" | "missing" | "notMissing" | "contains" | "notContains" | "empty" | "notEmpty" | "startsWith" | "endsWith";
313
+ }
314
+
315
+ declare abstract class SingleSelectItem<T> {
316
+ readonly data: T;
317
+ private readonly _selectLabel;
318
+ private readonly _toolTip;
319
+ private readonly _searchString;
320
+ get selectLabel(): string;
321
+ get tooltip(): string;
322
+ get searchString(): string;
323
+ protected constructor(data: T);
324
+ protected abstract getSelectLabel(): string;
325
+ protected abstract getTooltip(): string;
326
+ protected abstract getSearchString(): string;
327
+ }
328
+ declare class RuleVariableSelectItem extends SingleSelectItem<BuilderVariable> {
329
+ readonly data: BuilderVariable;
330
+ static create: (data: BuilderVariable) => RuleVariableSelectItem;
331
+ readonly options: ReadonlyArray<RuleOptionSelectItem>;
332
+ constructor(data: BuilderVariable);
333
+ protected getSearchString(): string;
334
+ getSelectLabel(): string;
335
+ getTooltip(): string;
336
+ }
337
+ declare class RuleOptionSelectItem extends SingleSelectItem<BuilderVariableOption> {
338
+ static create: (option: BuilderVariableOption) => RuleOptionSelectItem;
339
+ private constructor();
340
+ protected getSearchString(): string;
341
+ protected getSelectLabel(): string;
342
+ protected getTooltip(): string;
343
+ }
344
+ declare class OperatorSelectItem extends SingleSelectItem<BuilderOperator | ""> {
345
+ static readonly EQ: OperatorSelectItem;
346
+ static readonly NOT_EQ: OperatorSelectItem;
347
+ static readonly fromSymbol: (symbol: BuilderOperator | Omit<string, BuilderOperator>) => OperatorSelectItem | false;
348
+ private constructor();
349
+ protected getSearchString(): string;
350
+ protected getSelectLabel(): string;
351
+ protected getTooltip(): string;
352
+ }
353
+ declare class JumpToPageSelectItem extends SingleSelectItem<JumpToPageAction> {
354
+ static readonly create: (pageData: JumpToPageAction) => JumpToPageSelectItem;
355
+ protected constructor(pageData: JumpToPageAction);
356
+ protected getSearchString(): string;
357
+ protected getSelectLabel(): string;
358
+ protected getTooltip(): string;
359
+ }
360
+
361
+ /**
362
+ * TODO Crate filters for "cardinality" or "order" of a variable;
363
+ * Return legal lists of variables.
364
+ */
365
+ declare class RuleInput {
366
+ private readonly _questionVariables;
367
+ private readonly _customVariables;
368
+ private readonly _pageIdActions;
369
+ private readonly _tagActions;
370
+ private readonly _jumpActions;
371
+ constructor(_questionVariables: ReadonlyArray<QuestionVariable>, _customVariables: ReadonlyArray<CustomVariable>, _pageIdActions: ReadonlyArray<ExcludeByPageAction>, _tagActions: ReadonlyArray<ExcludeByTagAction>, _jumpActions: ReadonlyArray<JumpToPageAction>);
372
+ get questionVars(): ReadonlyArray<QuestionVariable>;
373
+ getConditionInput(): ReadonlyArray<BuilderVariable>;
374
+ getJumpToPageOptions(): ReadonlyArray<JumpToPageSelectItem>;
375
+ get customVars(): ReadonlyArray<CustomVariable>;
376
+ get excludeByPageIdActions(): readonly ExcludeByPageAction[];
377
+ get excludeByTagActions(): readonly ExcludeByTagAction[];
378
+ get jumpToPageActions(): readonly JumpToPageAction[];
379
+ }
380
+
381
+ interface BuilderTagDto {
382
+ readonly id: BuilderObjectId.TagId;
383
+ readonly tag: string;
384
+ readonly description: string;
385
+ }
386
+ declare class BuilderTag extends BuilderObject<'builder-tag', BuilderTagDto> {
387
+ readonly objectType: 'builder-tag';
388
+ readonly id: BuilderObjectId.TagId;
389
+ tagText: string;
390
+ tagDescription: string;
391
+ static readonly MAX_LENGTH = 20;
392
+ static readonly MIN_LENGTH = 1;
393
+ static readonly create: (tag: string, description?: string) => BuilderTag;
394
+ static readonly fromDto: (dto: BuilderTagDto) => BuilderTag;
395
+ protected constructor(dto: BuilderTagDto);
396
+ clone(): BuilderTagDto;
397
+ toJson(): BuilderTagDto;
398
+ }
399
+ declare class TagCollection implements Iterable<BuilderTag> {
400
+ private readonly _tags;
401
+ static readonly create: () => TagCollection;
402
+ [Symbol.iterator](): IterableIterator<BuilderTag>;
403
+ private constructor();
404
+ init(tags: ReadonlyArray<BuilderTagDto>): void;
405
+ add(tag: BuilderTag): void;
406
+ /**
407
+ * Delete this tag from collection;
408
+ * @param tag
409
+ */
410
+ delete(tag: BuilderTag): void;
411
+ toJson(): ReadonlyArray<BuilderTagDto>;
412
+ deleteAll(tags: Iterable<BuilderTag>): void;
413
+ }
414
+
415
+ interface BuilderConditionDto {
416
+ readonly kind: "condition";
417
+ readonly operator: BuilderOperator | "";
418
+ readonly name: string;
419
+ readonly variableId: string;
420
+ readonly value: number | string | boolean;
421
+ }
422
+ declare class BuilderCondition extends BuilderObject<"builder-condition", BuilderConditionDto> {
423
+ readonly objectType: "builder-condition";
424
+ static readonly NUMBER_OPERATORS: ReadonlyArray<OperatorSelectItem>;
425
+ private initialDto;
426
+ name: string;
427
+ static create: (variableList: ReadonlyArray<BuilderVariable>) => BuilderCondition;
428
+ static fromDto: (dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) => BuilderCondition;
429
+ private _variable;
430
+ private _operator;
431
+ private _value;
432
+ private _variableList;
433
+ /**
434
+ * Can only set variables that exist in variableList.
435
+ * @param variable
436
+ */
437
+ set variable(variable: BuilderVariable | false);
438
+ get variable(): BuilderVariable | false;
439
+ set value(variableValue: BuilderVariableOption | false);
440
+ get value(): BuilderVariableOption | false;
441
+ validate(): {
442
+ isValid: true;
443
+ } | {
444
+ isValid: false;
445
+ message: string;
446
+ };
447
+ private findVariableInUniverse;
448
+ set operator(operator: BuilderOperator | "");
449
+ get operator(): BuilderOperator | "";
450
+ private constructor();
451
+ get variableSelectItemsInUniverse(): ReadonlyArray<RuleVariableSelectItem>;
452
+ get operatorsSelectItems(): ReadonlyArray<OperatorSelectItem>;
453
+ get selectValueItems(): ReadonlyArray<RuleOptionSelectItem>;
454
+ clone(): BuilderConditionDto;
455
+ private _setVariableList;
456
+ toJson(): BuilderConditionDto;
457
+ }
458
+
459
+ declare const ConditionGroupType: {
460
+ all: boolean;
461
+ any: boolean;
462
+ count: boolean;
463
+ range: boolean;
464
+ };
465
+ type ConditionGroupType = keyof typeof ConditionGroupType;
466
+ interface BuilderConditionGroupDto {
467
+ readonly kind: 'condition-group';
468
+ readonly name: string;
469
+ readonly type: ConditionGroupType;
470
+ readonly conditions: ReadonlyArray<BuilderConditionDto>;
471
+ }
472
+ declare class BuilderConditionGroup extends BuilderObject<'builder-condition-group', BuilderConditionGroupDto> {
473
+ static readonly isConditionGroupType: (value: string | symbol) => value is "all" | "any" | "count" | "range";
474
+ readonly objectType: 'builder-condition-group';
475
+ private _type;
476
+ name: string;
477
+ private readonly _conditions;
478
+ private readonly _variableList;
479
+ static readonly fromDto: (dto: BuilderConditionGroupDto, variableList: ReadonlyArray<BuilderVariable>) => BuilderConditionGroup;
480
+ protected constructor(dto: BuilderConditionGroupDto, variableList: ReadonlyArray<BuilderVariable>);
481
+ get conditions(): ReadonlyArray<BuilderCondition>;
482
+ get conditionCount(): number;
483
+ addCondition(): BuilderCondition;
484
+ removeCondition(condition: BuilderCondition): boolean;
485
+ clone(): BuilderConditionGroupDto;
486
+ toJson(): BuilderConditionGroupDto;
487
+ get type(): ConditionGroupType;
488
+ set type(conditionGroupType: ConditionGroupType);
489
+ }
490
+
491
+ declare abstract class MultiSelectItem<T> {
492
+ readonly data: T;
493
+ private readonly _isSelectedInitially;
494
+ private readonly _selectLabel;
495
+ private readonly _toolTip;
496
+ private readonly _searchString;
497
+ isSelected: boolean;
498
+ get selectLabel(): string;
499
+ get tooltip(): string;
500
+ get searchString(): string;
501
+ protected constructor(data: T, isSelected: boolean);
502
+ protected abstract getSelectLabel(): string;
503
+ protected abstract getTooltip(): string;
504
+ protected abstract getSearchString(): string;
505
+ }
506
+ declare class ExcludeByTagSelectItem extends MultiSelectItem<ExcludeByTagAction> {
507
+ static readonly create: (tagData: ExcludeByTagAction, isSelected: boolean) => ExcludeByTagSelectItem;
508
+ protected constructor(data: ExcludeByTagAction, isSelected: boolean);
509
+ protected getSearchString(): string;
510
+ protected getSelectLabel(): string;
511
+ protected getTooltip(): string;
512
+ }
513
+ declare class ExcludeByPageIdSelectItem extends MultiSelectItem<ExcludeByPageAction> {
514
+ static create: (ruleActionPage: ExcludeByPageAction, isSelected: boolean) => ExcludeByPageIdSelectItem;
515
+ protected constructor(data: ExcludeByPageAction, isSelected: boolean);
516
+ protected getSearchString(): string;
517
+ protected getSelectLabel(): string;
518
+ protected getTooltip(): string;
519
+ }
520
+
521
+ declare class JumpToActionManager {
522
+ private readonly validOptions;
523
+ private readonly initialSelection;
524
+ readonly options: ReadonlyArray<JumpToPageSelectItem>;
525
+ private _selected;
526
+ constructor(validOptions: RuleInput["_jumpActions"], initialSelection: string | false | undefined);
527
+ get selected(): JumpToPageSelectItem | false;
528
+ set selected(selected: JumpToPageSelectItem | false);
529
+ getSelectedPageId(): string | false;
530
+ private findSelected;
531
+ }
532
+
533
+ interface BuilderRuleDto {
534
+ readonly type: ConditionGroupType;
535
+ readonly name: string;
536
+ readonly conditions: ReadonlyArray<BuilderConditionDto | BuilderConditionGroupDto>;
537
+ readonly excludeTags: ReadonlyArray<string>;
538
+ readonly excludePages: ReadonlyArray<string>;
539
+ readonly jumpToPage: string | false;
540
+ }
541
+ declare class BuilderRule extends BuilderObject<'builder-rule', BuilderRuleDto> {
542
+ private readonly dto;
543
+ private readonly _ruleInput;
544
+ readonly objectType: 'builder-rule';
545
+ private _type;
546
+ name: string;
547
+ private readonly _conditions;
548
+ private _tagActionManager;
549
+ private _pageActionManager;
550
+ readonly jumpToActionManager: JumpToActionManager;
551
+ static readonly fromDto: (dto: BuilderRuleDto, input: RuleInput) => BuilderRule;
552
+ protected constructor(dto: BuilderRuleDto, _ruleInput: RuleInput);
553
+ get conditions(): ReadonlyArray<BuilderConditionGroup | BuilderCondition>;
554
+ getTagActions(): readonly ExcludeByTagSelectItem[];
555
+ getValidPageActions(): readonly ExcludeByPageIdSelectItem[];
556
+ get conditionCount(): number;
557
+ set type(type: ConditionGroupType);
558
+ get type(): ConditionGroupType;
559
+ deleteCondition(condition: BuilderCondition | BuilderConditionGroup): boolean;
560
+ addCondition(): BuilderCondition;
561
+ addConditionGroup(): BuilderConditionGroup;
562
+ clone(): BuilderRuleDto;
563
+ toJson(): BuilderRuleDto;
564
+ }
565
+
566
+ interface BuilderSchemaDto {
567
+ readonly id: string;
568
+ readonly prefix: string;
569
+ readonly mainImage: ImageFile | false;
570
+ readonly backgroundColor: string;
571
+ readonly name: string;
572
+ readonly pages: BuilderPageDto[];
573
+ readonly baseHeight: number;
574
+ readonly baseWidth: number;
575
+ readonly rules: ReadonlyArray<BuilderRuleDto>;
576
+ readonly tags: ReadonlyArray<BuilderTagDto>;
577
+ }
578
+ interface SchemaBuildOutput {
579
+ schema: SchemaDto;
580
+ codebook: Record<string, string>;
581
+ schemaConfig: Record<string, string>;
582
+ }
583
+ declare class BuilderSchema {
584
+ readonly id: string;
585
+ name: string;
586
+ prefix: string;
587
+ baseHeight: number;
588
+ baseWidth: number;
589
+ backgroundColor: string;
590
+ pages: BuilderPage[];
591
+ mainImage: ImageFile | false;
592
+ private _rules;
593
+ get rules(): ReadonlyArray<BuilderRule>;
594
+ private readonly _tagCollection;
595
+ get tags(): ReadonlyArray<BuilderTag>;
596
+ static create(id: string, name: string, prefix: string): BuilderSchema;
597
+ static fromJson(dto: BuilderSchemaDto): BuilderSchema;
598
+ toJson(): BuilderSchemaDto;
599
+ private constructor();
600
+ addPage(type: BuilderPageType, atIndex?: number): BuilderPage;
601
+ insertPage(page: BuilderPage, atIndex: number): boolean;
602
+ private insertPageAtIndex;
603
+ addRule(): void;
604
+ deleteRule(rule: BuilderRule): void;
605
+ movePage(page: BuilderPage, toIndex: number): boolean;
606
+ deletePage(page: BuilderPage): boolean;
607
+ reevaluateRules(): void;
608
+ getRuleInput(): RuleInput;
609
+ deleteTags(tags: ReadonlyArray<BuilderTag>): void;
610
+ addTag(builderTag: BuilderTag): void;
611
+ private getQuestionVariables;
612
+ compile(): SchemaBuildOutput;
613
+ }
614
+
615
+ interface BuilderTextDto {
616
+ readonly id: BuilderObjectId.TextID;
617
+ text: string;
618
+ name: string;
619
+ translationRequired: boolean;
620
+ }
621
+ declare class BuilderText extends BuilderObject<'builder-text', BuilderTextDto> {
622
+ readonly objectType = "builder-text";
623
+ id: BuilderObjectId.TextID;
624
+ text: string;
625
+ name: string;
626
+ translateRequired: boolean;
627
+ private constructor();
628
+ static create(name: string): BuilderText;
629
+ static fromJson(dto: BuilderTextDto): BuilderText;
630
+ clone(): BuilderTextDto;
631
+ toJson(): BuilderTextDto;
632
+ }
633
+
634
+ export { AudioFile, BuilderMainImageDto, BuilderMainText, BuilderMainTextDto, BuilderMainVideoDto, BuilderOption, BuilderOptionDto, BuilderPage, BuilderPageDto, BuilderPageType, BuilderQuestion, BuilderQuestionDto, BuilderQuestionType, BuilderSchema, BuilderSchemaDto, BuilderTag, BuilderTagDto, BuilderText, BuilderTextDto, ImageFile, TagCollection, VideoFile };