added ability to revert (#21)

This commit is contained in:
undergroundwires
2020-07-15 19:04:56 +01:00
parent 57028987f1
commit 9c063d59de
58 changed files with 1448 additions and 265 deletions

View File

@@ -1,13 +1,12 @@
import { Category } from '../../domain/Category';
import { Application } from '../../domain/Application';
import { Category } from '@/domain/Category';
import { Application } from '@/domain/Application';
import { IApplication } from '@/domain/IApplication';
import { ApplicationYaml } from 'js-yaml-loader!./../application.yaml';
import { parseCategory } from './CategoryParser';
export function parseApplication(content: ApplicationYaml): Application {
export function parseApplication(content: ApplicationYaml): IApplication {
validate(content);
const categories = new Array<Category>();
if (!content.actions || content.actions.length <= 0) {
throw new Error('Application does not define any action');
}
for (const action of content.actions) {
const category = parseCategory(action);
categories.push(category);
@@ -19,3 +18,12 @@ export function parseApplication(content: ApplicationYaml): Application {
categories);
return app;
}
function validate(content: ApplicationYaml): void {
if (!content) {
throw new Error('application is null or undefined');
}
if (!content.actions || content.actions.length <= 0) {
throw new Error('application does not define any action');
}
}