-
Notifications
You must be signed in to change notification settings - Fork 14
/
enums.js
63 lines (54 loc) · 1.19 KB
/
enums.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const UnitTypes = {
LU: "lu",
TASK: "task",
AIM: "aim",
};
const ContentTypes = {
TEXT: "text",
VIDEO: "video",
SIMULATION: "simulation",
ASSESMENT: "assesment",
ASSESSMENT: "assessment",
COMPONENT: "component",
};
const BuildEnvs = {
PRODUCTION: 'production',
TESTING: 'testing',
LOCAL: 'local'
};
const PluginScope = {
EXPERIMENT: 'experiment',
PAGE: 'page',
POSTBUILD: 'postbuild'
};
const PluginConfig = {
Default: {
JS_MODULE: 'js/main.js',
CSS_MODULE: 'css/main.css',
},
};
function validType(t, v) {
return Object.values(t).includes(v);
}
function validUnitType(ut) {
if (validType(UnitTypes, ut)) {
return ut;
} else {
throw new Error("Invalid unit type");
}
}
function validContentType(ct) {
if (validType(ContentTypes, ct)) {
return ct;
} else {
throw new Error("Invalid content type");
}
}
function validBuildEnv(e) {
if (validType(BuildEnvs, e)) {
return e;
} else {
throw new Error("Invalid build environment");
}
}
module.exports = {UnitTypes, ContentTypes, BuildEnvs, PluginScope, PluginConfig, validType, validContentType, validUnitType, validBuildEnv};