@media-quest/builder 0.0.22 → 0.0.24
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 +1 -1
- package/src/Builder-option.ts +66 -66
- package/src/Builder-page.spec.ts +320 -320
- package/src/Builder-page.ts +257 -257
- package/src/Builder-question.spec.ts +68 -68
- package/src/Builder-question.ts +101 -101
- package/src/Builder-schema.spec.ts +51 -0
- package/src/Builder-schema.ts +47 -15
- package/src/Builder-text.spec.ts +24 -24
- package/src/Builder-text.ts +57 -57
- package/src/BuilderMainImageDto.ts +7 -7
- package/src/BuilderMainText.ts +81 -81
- package/src/BuilderMainVideoDto.ts +10 -10
- package/src/BuilderObject.ts +61 -61
- package/src/BuilderTag.ts +97 -97
- package/src/builder-compiler.ts +14 -0
- package/src/codebook.ts +72 -72
- package/src/media-files.ts +28 -28
- package/src/primitives/page-prefix.ts +58 -58
- package/src/primitives/prefix.spec.ts +5 -5
- package/src/primitives/schema-prefix.ts +52 -52
- package/src/primitives/varID.ts +11 -11
- package/src/public-api.ts +3 -1
- package/src/rulebuilder/Builder-rule.spec.ts +322 -322
- package/src/rulebuilder/Builder-rule.ts +190 -190
- package/src/rulebuilder/RuleAction.ts +106 -106
- package/src/rulebuilder/RuleBuilder-test-utils.ts +316 -316
- package/src/rulebuilder/RuleInput.ts +44 -44
- package/src/rulebuilder/RuleVariable.ts +49 -49
- package/src/rulebuilder/SingleSelectItem.ts +135 -135
- package/src/rulebuilder/condition/Builder-condition-group.spec.ts +47 -47
- package/src/rulebuilder/condition/Builder-condition-group.ts +118 -118
- package/src/rulebuilder/condition/Builder-condition.spec.ts +195 -195
- package/src/rulebuilder/condition/Builder-condition.ts +208 -208
- package/src/rulebuilder/condition/Builder-operator.spec.ts +9 -9
- package/src/rulebuilder/condition/Builder-operator.ts +31 -31
- package/src/rulebuilder/index.ts +22 -22
- package/src/rulebuilder/jump-to-action-manager.ts +33 -33
- package/src/rulebuilder/multi-select-item.ts +73 -73
- package/src/rulebuilder/page-action-manager.ts +31 -31
- package/src/rulebuilder/rule2/Rule2.ts +211 -211
- package/src/rulebuilder/tag-action-manager.spec.ts +44 -44
- package/src/rulebuilder/tag-action-manager.ts +28 -28
- package/src/schema-config.ts +25 -25
- package/src/theme/AbstractThemeCompiler.ts +7 -7
- package/src/theme/IDefaultTheme.ts +226 -226
- package/src/theme/css-theme.ts +7 -7
- package/src/theme/default-theme-compiler.ts +358 -358
- package/src/theme/icon-urls.ts +29 -29
- package/src/theme/theme-utils.ts +57 -57
- package/src/theme/theme1.spec.ts +52 -52
- package/src/variable/mq-variable.spec.ts +146 -0
- package/src/{mq-variable.ts → variable/mq-variable.ts} +8 -1
- package/src/variable/sum-score.ts +138 -0
- package/tsconfig.json +15 -15
- package/tsconfig.tsbuildinfo +1 -1
package/src/media-files.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export interface AudioFile {
|
|
2
|
-
readonly kind: "audio-file";
|
|
3
|
-
readonly id: string;
|
|
4
|
-
readonly downloadUrl: string;
|
|
5
|
-
readonly duration: number;
|
|
6
|
-
readonly originalFileName: string;
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly size: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface VideoFile {
|
|
12
|
-
readonly kind: "video-file";
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly downloadUrl: string;
|
|
15
|
-
readonly duration: number;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly size: number;
|
|
18
|
-
readonly type: string;
|
|
19
|
-
readonly originalFileName: string;
|
|
20
|
-
}
|
|
21
|
-
export interface ImageFile {
|
|
22
|
-
readonly kind: "image-file";
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly downloadUrl: string;
|
|
25
|
-
readonly name: string;
|
|
26
|
-
readonly size: number;
|
|
27
|
-
readonly type: string;
|
|
28
|
-
}
|
|
1
|
+
export interface AudioFile {
|
|
2
|
+
readonly kind: "audio-file";
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly downloadUrl: string;
|
|
5
|
+
readonly duration: number;
|
|
6
|
+
readonly originalFileName: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly size: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface VideoFile {
|
|
12
|
+
readonly kind: "video-file";
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly downloadUrl: string;
|
|
15
|
+
readonly duration: number;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly size: number;
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly originalFileName: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ImageFile {
|
|
22
|
+
readonly kind: "image-file";
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly downloadUrl: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly size: number;
|
|
27
|
+
readonly type: string;
|
|
28
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { SchemaPrefix } from "./schema-prefix";
|
|
2
|
-
|
|
3
|
-
export type PagePrefixValue = string & { __PAGE_PREFIX__: true };
|
|
4
|
-
export const createRandomPrefix = <const P extends string>(length: number): P => {
|
|
5
|
-
const letters = "abcdefghijklmnopqrstuvyz";
|
|
6
|
-
const all = letters + letters.toUpperCase();
|
|
7
|
-
let result = "";
|
|
8
|
-
for (let i = 0; i < length; i++) {
|
|
9
|
-
const char = all.charAt(Math.floor(Math.random() * all.length));
|
|
10
|
-
result += char;
|
|
11
|
-
}
|
|
12
|
-
return result as P;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export class PagePrefix {
|
|
16
|
-
public static readonly MIN_LENGTH = 1;
|
|
17
|
-
private static randomLen = 5;
|
|
18
|
-
public static readonly MAX_LENGTH = 16;
|
|
19
|
-
|
|
20
|
-
public static create = (): PagePrefix => {
|
|
21
|
-
const v = createRandomPrefix<PagePrefixValue>(PagePrefix.randomLen);
|
|
22
|
-
return new PagePrefix(v);
|
|
23
|
-
};
|
|
24
|
-
public static fromString = (value: string): PagePrefix | false => {
|
|
25
|
-
if (!PagePrefix.isValid(value)) return false;
|
|
26
|
-
return new PagePrefix(value);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
public static fromStringOrThrow = (value: string): PagePrefixValue => {
|
|
30
|
-
if (!PagePrefix.isValid(value)) throw new Error("Invalid prefix");
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
public static castOrCreateRandom = (value: string): PagePrefix => {
|
|
34
|
-
const v = PagePrefix.isValid(value) ? value : createRandomPrefix<PagePrefixValue>(PagePrefix.randomLen);
|
|
35
|
-
return new PagePrefix(v);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
public static isValid = (prefix: string | 999): prefix is PagePrefixValue => {
|
|
39
|
-
if (typeof prefix !== "string") return false;
|
|
40
|
-
if (prefix.length < SchemaPrefix.MIN_LENGTH) return false;
|
|
41
|
-
if (prefix.length > SchemaPrefix.MAX_LENGTH) return false;
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
get value(): PagePrefixValue {
|
|
46
|
-
return this._value;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
set value(value: string) {
|
|
50
|
-
if (!PagePrefix.isValid(value)) {
|
|
51
|
-
console.log("INVALID PREFIX", value);
|
|
52
|
-
} else {
|
|
53
|
-
this._value = value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private constructor(private _value: PagePrefixValue) {}
|
|
58
|
-
}
|
|
1
|
+
import { SchemaPrefix } from "./schema-prefix";
|
|
2
|
+
|
|
3
|
+
export type PagePrefixValue = string & { __PAGE_PREFIX__: true };
|
|
4
|
+
export const createRandomPrefix = <const P extends string>(length: number): P => {
|
|
5
|
+
const letters = "abcdefghijklmnopqrstuvyz";
|
|
6
|
+
const all = letters + letters.toUpperCase();
|
|
7
|
+
let result = "";
|
|
8
|
+
for (let i = 0; i < length; i++) {
|
|
9
|
+
const char = all.charAt(Math.floor(Math.random() * all.length));
|
|
10
|
+
result += char;
|
|
11
|
+
}
|
|
12
|
+
return result as P;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export class PagePrefix {
|
|
16
|
+
public static readonly MIN_LENGTH = 1;
|
|
17
|
+
private static randomLen = 5;
|
|
18
|
+
public static readonly MAX_LENGTH = 16;
|
|
19
|
+
|
|
20
|
+
public static create = (): PagePrefix => {
|
|
21
|
+
const v = createRandomPrefix<PagePrefixValue>(PagePrefix.randomLen);
|
|
22
|
+
return new PagePrefix(v);
|
|
23
|
+
};
|
|
24
|
+
public static fromString = (value: string): PagePrefix | false => {
|
|
25
|
+
if (!PagePrefix.isValid(value)) return false;
|
|
26
|
+
return new PagePrefix(value);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
public static fromStringOrThrow = (value: string): PagePrefixValue => {
|
|
30
|
+
if (!PagePrefix.isValid(value)) throw new Error("Invalid prefix");
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
public static castOrCreateRandom = (value: string): PagePrefix => {
|
|
34
|
+
const v = PagePrefix.isValid(value) ? value : createRandomPrefix<PagePrefixValue>(PagePrefix.randomLen);
|
|
35
|
+
return new PagePrefix(v);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
public static isValid = (prefix: string | 999): prefix is PagePrefixValue => {
|
|
39
|
+
if (typeof prefix !== "string") return false;
|
|
40
|
+
if (prefix.length < SchemaPrefix.MIN_LENGTH) return false;
|
|
41
|
+
if (prefix.length > SchemaPrefix.MAX_LENGTH) return false;
|
|
42
|
+
return true;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
get value(): PagePrefixValue {
|
|
46
|
+
return this._value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set value(value: string) {
|
|
50
|
+
if (!PagePrefix.isValid(value)) {
|
|
51
|
+
console.log("INVALID PREFIX", value);
|
|
52
|
+
} else {
|
|
53
|
+
this._value = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private constructor(private _value: PagePrefixValue) {}
|
|
58
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
describe("Prefix", () => {
|
|
2
|
-
it("should create an instance", () => {
|
|
3
|
-
expect(true).toBeTruthy();
|
|
4
|
-
});
|
|
5
|
-
});
|
|
1
|
+
describe("Prefix", () => {
|
|
2
|
+
it("should create an instance", () => {
|
|
3
|
+
expect(true).toBeTruthy();
|
|
4
|
+
});
|
|
5
|
+
});
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { createRandomPrefix } from "./page-prefix";
|
|
2
|
-
|
|
3
|
-
export type SchemaPrefixValue = string & { __SCHEMA_PREFIX__: true };
|
|
4
|
-
|
|
5
|
-
export class SchemaPrefix {
|
|
6
|
-
public static readonly MIN_LENGTH = 1;
|
|
7
|
-
private static randomLen = 5;
|
|
8
|
-
public static readonly MAX_LENGTH = 16;
|
|
9
|
-
|
|
10
|
-
public static fromValue = (value: SchemaPrefixValue): SchemaPrefix => {
|
|
11
|
-
return new SchemaPrefix(value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
public static fromValueOrThrow = (value: string): SchemaPrefix => {
|
|
15
|
-
if (!SchemaPrefix.isValid(value)) throw new Error("Invalid prefix");
|
|
16
|
-
return new SchemaPrefix(value);
|
|
17
|
-
};
|
|
18
|
-
public static fromString = (value: string): SchemaPrefix | false => {
|
|
19
|
-
if (!SchemaPrefix.isValid(value)) return false;
|
|
20
|
-
return new SchemaPrefix(value);
|
|
21
|
-
};
|
|
22
|
-
public static castOrCreateRandom = (value: string): SchemaPrefix => {
|
|
23
|
-
const v = SchemaPrefix.isValid(value)
|
|
24
|
-
? value
|
|
25
|
-
: createRandomPrefix<SchemaPrefixValue>(SchemaPrefix.randomLen);
|
|
26
|
-
return new SchemaPrefix(v);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
public static isValid = (prefix: string | 999): prefix is SchemaPrefixValue => {
|
|
30
|
-
if (typeof prefix !== "string") return false;
|
|
31
|
-
if (prefix.length < SchemaPrefix.MIN_LENGTH) return false;
|
|
32
|
-
if (prefix.length > SchemaPrefix.MAX_LENGTH) return false;
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
get value(): SchemaPrefixValue {
|
|
37
|
-
return this._value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get isValid() {
|
|
41
|
-
return SchemaPrefix.isValid(this._value);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
set value(value: string) {
|
|
45
|
-
const casted = value as unknown;
|
|
46
|
-
if (typeof casted === "string") {
|
|
47
|
-
this._value = casted as SchemaPrefixValue;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private constructor(private _value: SchemaPrefixValue) {}
|
|
52
|
-
}
|
|
1
|
+
import { createRandomPrefix } from "./page-prefix";
|
|
2
|
+
|
|
3
|
+
export type SchemaPrefixValue = string & { __SCHEMA_PREFIX__: true };
|
|
4
|
+
|
|
5
|
+
export class SchemaPrefix {
|
|
6
|
+
public static readonly MIN_LENGTH = 1;
|
|
7
|
+
private static randomLen = 5;
|
|
8
|
+
public static readonly MAX_LENGTH = 16;
|
|
9
|
+
|
|
10
|
+
public static fromValue = (value: SchemaPrefixValue): SchemaPrefix => {
|
|
11
|
+
return new SchemaPrefix(value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
public static fromValueOrThrow = (value: string): SchemaPrefix => {
|
|
15
|
+
if (!SchemaPrefix.isValid(value)) throw new Error("Invalid prefix");
|
|
16
|
+
return new SchemaPrefix(value);
|
|
17
|
+
};
|
|
18
|
+
public static fromString = (value: string): SchemaPrefix | false => {
|
|
19
|
+
if (!SchemaPrefix.isValid(value)) return false;
|
|
20
|
+
return new SchemaPrefix(value);
|
|
21
|
+
};
|
|
22
|
+
public static castOrCreateRandom = (value: string): SchemaPrefix => {
|
|
23
|
+
const v = SchemaPrefix.isValid(value)
|
|
24
|
+
? value
|
|
25
|
+
: createRandomPrefix<SchemaPrefixValue>(SchemaPrefix.randomLen);
|
|
26
|
+
return new SchemaPrefix(v);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
public static isValid = (prefix: string | 999): prefix is SchemaPrefixValue => {
|
|
30
|
+
if (typeof prefix !== "string") return false;
|
|
31
|
+
if (prefix.length < SchemaPrefix.MIN_LENGTH) return false;
|
|
32
|
+
if (prefix.length > SchemaPrefix.MAX_LENGTH) return false;
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
get value(): SchemaPrefixValue {
|
|
37
|
+
return this._value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get isValid() {
|
|
41
|
+
return SchemaPrefix.isValid(this._value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
set value(value: string) {
|
|
45
|
+
const casted = value as unknown;
|
|
46
|
+
if (typeof casted === "string") {
|
|
47
|
+
this._value = casted as SchemaPrefixValue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private constructor(private _value: SchemaPrefixValue) {}
|
|
52
|
+
}
|
package/src/primitives/varID.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PagePrefixValue } from "./page-prefix";
|
|
2
|
-
|
|
3
|
-
import { SchemaPrefixValue } from "./schema-prefix";
|
|
4
|
-
|
|
5
|
-
export type VarID = `${SchemaPrefixValue}_${PagePrefixValue}`;
|
|
6
|
-
export const VarID = {
|
|
7
|
-
create: (schemaPrefix: SchemaPrefixValue, pagePrefix: PagePrefixValue): VarID => {
|
|
8
|
-
const varId = schemaPrefix + "_" + pagePrefix;
|
|
9
|
-
return varId as VarID;
|
|
10
|
-
},
|
|
11
|
-
};
|
|
1
|
+
import { PagePrefixValue } from "./page-prefix";
|
|
2
|
+
|
|
3
|
+
import { SchemaPrefixValue } from "./schema-prefix";
|
|
4
|
+
|
|
5
|
+
export type VarID = `${SchemaPrefixValue}_${PagePrefixValue}`;
|
|
6
|
+
export const VarID = {
|
|
7
|
+
create: (schemaPrefix: SchemaPrefixValue, pagePrefix: PagePrefixValue): VarID => {
|
|
8
|
+
const varId = schemaPrefix + "_" + pagePrefix;
|
|
9
|
+
return varId as VarID;
|
|
10
|
+
},
|
|
11
|
+
};
|
package/src/public-api.ts
CHANGED
|
@@ -17,6 +17,8 @@ export * from "./rulebuilder";
|
|
|
17
17
|
export { PagePrefix, PagePrefixValue } from "./primitives/page-prefix";
|
|
18
18
|
export { SchemaPrefix, SchemaPrefixValue } from "./primitives/schema-prefix";
|
|
19
19
|
export * from "./schema-config";
|
|
20
|
-
export * from "./mq-variable";
|
|
21
20
|
export * from "./codebook";
|
|
22
21
|
export { VarID } from "./primitives/varID";
|
|
22
|
+
export * from "./variable/mq-variable";
|
|
23
|
+
export * from "./builder-compiler";
|
|
24
|
+
export * from "./variable/sum-score";
|