default selection is now none

This commit is contained in:
undergroundwires
2020-01-06 20:02:12 +01:00
parent 20020af7c1
commit 3140cc663b
21 changed files with 295 additions and 237 deletions

View File

@@ -21,7 +21,13 @@ export class Application implements IApplication {
}
this.flattened = flatten(categories);
if (this.flattened.allCategories.length === 0) {
throw new Error('An application must consist of at least one category');
throw new Error('Application must consist of at least one category');
}
if (this.flattened.allScripts.length === 0) {
throw new Error('Application must consist of at least one script');
}
if (this.flattened.allScripts.filter((script) => script.isRecommended).length === 0) {
throw new Error('Application must consist of at least one recommended script');
}
ensureNoDuplicates(this.flattened.allCategories);
ensureNoDuplicates(this.flattened.allScripts);
@@ -31,6 +37,10 @@ export class Application implements IApplication {
return this.flattened.allCategories.find((category) => category.id === categoryId);
}
public getRecommendedScripts(): readonly IScript[] {
return this.flattened.allScripts.filter((script) => script.isRecommended);
}
public findScript(scriptId: string): IScript | undefined {
return this.flattened.allScripts.find((script) => script.id === scriptId);
}