🔍 support for search
This commit is contained in:
@@ -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>>) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user