generated from Exabyte-io/template-definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
executable.js
53 lines (42 loc) · 1.52 KB
/
executable.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
import { NamedDefaultableInMemoryEntity, RuntimeItemsMixin } from "@mat3ra/code/dist/js/entity";
import { mix } from "mixwith";
import { Flavor } from "./flavor";
export class Executable extends mix(NamedDefaultableInMemoryEntity).with(RuntimeItemsMixin) {
static Flavor = Flavor;
toJSON(exclude) {
return super.toJSON(["flavors"].concat(exclude));
}
get flavorsTree() {
return this.prop("flavors");
}
get flavors() {
return Object.keys(this.flavorsTree).map((key) => {
return this.constructor.Flavor.create({
...this.flavorsTree[key],
name: key,
executable: this,
});
});
}
get flavorsFromTree() {
return Object.keys(this.flavorsTree).map((key) => {
return new this.constructor.Flavor({ ...this.flavorsTree[key], name: key });
});
}
get defaultFlavor() {
return this.getFlavorByName();
}
getFlavorByName(name) {
return this.getEntityByName(this.flavors, "flavor", name);
}
getFlavorByConfig(config) {
return config ? this.getFlavorByName(config.name) : this.defaultFlavor;
}
getFlavorsByApplicationVersion(version) {
const filteredFlavors = this.flavors.filter((flavor) => {
const supportedApplicationVersions = flavor.prop("supportedApplicationVersions");
return !supportedApplicationVersions || supportedApplicationVersions.includes(version);
});
return filteredFlavors;
}
}