🔍 support for search

This commit is contained in:
undergroundwires
2020-01-09 23:02:36 +01:00
parent cafe6e809a
commit 89862b2775
19 changed files with 202 additions and 88 deletions

View File

@@ -11,14 +11,12 @@ export class Application implements IApplication {
constructor(
public readonly name: string,
public readonly repositoryUrl: string,
public readonly version: number,
public readonly categories: ReadonlyArray<ICategory>) {
if (!name) {
throw Error('Application has no name');
}
if (!version) {
throw Error('Version cannot be zero');
}
if (!name) { throw Error('Application has no name'); }
if (!repositoryUrl) { throw Error('Application has no repository url'); }
if (!version) { throw Error('Version cannot be zero'); }
this.flattened = flatten(categories);
if (this.flattened.allCategories.length === 0) {
throw new Error('Application must consist of at least one category');
@@ -48,6 +46,10 @@ export class Application implements IApplication {
public getAllScripts(): IScript[] {
return this.flattened.allScripts;
}
public getAllCategories(): ICategory[] {
return this.flattened.allCategories;
}
}
function ensureNoDuplicates<TKey>(entities: ReadonlyArray<IEntity<TKey>>) {

View File

@@ -3,6 +3,7 @@ import { ICategory } from '@/domain/ICategory';
export interface IApplication {
readonly name: string;
readonly repositoryUrl: string;
readonly version: number;
readonly categories: ReadonlyArray<ICategory>;
readonly totalScripts: number;
@@ -12,6 +13,7 @@ export interface IApplication {
findCategory(categoryId: number): ICategory | undefined;
findScript(scriptId: string): IScript | undefined;
getAllScripts(): ReadonlyArray<IScript>;
getAllCategories(): ReadonlyArray<ICategory>;
}
export { IScript } from '@/domain/IScript';