Skip to content

Commit

Permalink
IMPROV: Isolate dmnjs typescript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidibl committed Mar 22, 2020
1 parent 50cfda8 commit 1723d29
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 81 deletions.
103 changes: 22 additions & 81 deletions src/app/components/dmnModeller/dmnModeller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,106 +15,47 @@ import { take, filter, map, debounceTime, } from 'rxjs/operators';

import DmnModdle from 'dmn-moddle/lib/dmn-moddle.js';

import { DataModelService } from '../../services/dataModelService';
import { DmnXmlService } from '../../services/dmnXmlService';
import { DMNJS } from '../../model/dmn/dmnJS';
import { DmnColumn } from '../../model/dmn/dmnColumn';
import { ShapeEvent } from '../../model/dmn/shapeEvent';
import { DmnDatatypeMapping } from '../../model/dmn/dmnDatatypeMapping';
import { DmnModdleElement } from '../../model/dmn/dmnModdleElement';
import { DmnModdleRule } from '../../model/dmn/dmnModdleRule';
import { DmnType } from '../../model/dmn/dmnType';
import { DmnExpressionLanguage } from '../../model/dmn/dmnExpressionLanguage';
import { DmnModdleEvent } from '../../model/dmn/dmnModdleEvent';
import { DmnModdleEventType } from '../../model/dmn/dmnModdleEventType';


import { ObjectDefinition } from '../../model/json/objectDefinition';
import { JsonDatatype, JsonDatatypes } from '../../model/json/jsonDatatypes';
import { EventService } from '../../services/eventService';
import { NewViewEvent } from '../../model/event/newViewEvent';
import { RenameArtefactEvent } from '../../model/event/renameArtefactEvent';
import { distinctUntilChanged } from 'rxjs/internal/operators/distinctUntilChanged';
import { DOCUMENT } from '@angular/platform-browser';
import { DecisionDeleteEvent } from '../../model/event/decisionDeleteEvent';
import { EventType } from '../../model/event/eventType';
import { DmnModelService } from '../../services/dmnModelService';
import { DmnModdleElement } from '../../model/dmn/dmnModdleElement';
import { DmnModdleRule } from '../../model/dmn/dmnModdleRule';
import { DmnType } from '../../model/dmn/dmnType';
import { MyDmnModdle } from '../../model/dmn/dmnModdle';
import { DataChangedEvent } from '../../model/event/dataChangedEvent';
import { DataChangeType } from '../../model/event/dataChangedType';
import { SaveStateService } from '../../services/saveStateService';
import { ImportDataEvent } from '../../model/event/importDataEvent';
import { BaseEvent } from '../../model/event/event';
import { IDmnValidationResult } from '../../model/dmnValidationResult';

import { DataModelService } from '../../services/dataModelService';
import { DmnXmlService } from '../../services/dmnXmlService';
import { EventService } from '../../services/eventService';
import { distinctUntilChanged } from 'rxjs/internal/operators/distinctUntilChanged';
import { DOCUMENT } from '@angular/platform-browser';
import { DmnModelService } from '../../services/dmnModelService';
import { SaveStateService } from '../../services/saveStateService';
import { ExportService } from '../../services/exportService';
import { DmnExpressionLanguage } from '../../model/dmn/dmnExpressionLanguage';
import { DmnModdleEvent } from '../../model/dmn/dmnModdleEvent';
import { DmnModdleEventType } from '../../model/dmn/dmnModdleEventType';
import { DomService } from '../../services/domService';
import { isNull } from '@xnoname/web-components';
import { DmnBusinessObject } from '../../model/dmn/dmnBusinessObject';
import { BaseEvent } from '../../model/event/event';
import { DmnClipboardService, ClipBoardDataType } from '../../services/dmnClipboardService';
import { CsvExportService } from '../../services/csvExportService';
import { IDmnValidationResult } from '../../model/dmnValidationResult';

declare var DmnJS: {
new(object: object, object2?: object): DMNJS;
};

declare interface DMNJS {
_viewers: any;
_activeView: DmnModelerView;
_moddle: MyDmnModdle;
importXML(xml: string, callback: (error: any) => void);
saveXML(options: any, callback: (error: any, xml: string) => void);
getViews(): DmnModelerView[];
on(eventname: string, eventCallback: (event) => void);
_updateViews(): void;
_switchView(tableId: string);
getActiveViewer(): DmnModelerView;
}

export interface Modeling {
editAllowedValues(businessObject: DmnBusinessObject, restrictionSet: string[]);
editAnnotation(rule: DmnModdleRule, value: string);
editCell(cell: any, value: string);
editDecisionTableId(newId: string);
editDecisionTableName(newName);
editExpressionLanguage(element: DmnModdleElement, language: string);
editHitPolicy(hitPolicy: string, aggregation: string);
editInputExpression(inputExpression: unknown, value);
editInputExpressionTypeRef(inputExpression: unknown, typeRef: string);
editOutputName(output: DmnModdleElement, newName: string);
editOutputTypeRef(output: DmnModdleElement, typeRef: string);

addRow(ruleConfig: Object): { cells: DmnBusinessObject[] };
}

export type DmnModelingType = 'modeling';

export interface DmnModelerView {
element: DmnModdleElement;
get(value: DmnModelingType): Modeling;
}

export interface ShapeEvent {
context: ShapeEventContext;
}

export interface ShapeEventContext {
shape: Shape;
}

export interface Shape {
id: string;
}

export class DmnDatatypeMapping {
static string = JsonDatatype.STRING;
static integer = JsonDatatype.INTEGER;
static long = JsonDatatype.INTEGER;
static double = JsonDatatype.NUMBER;
static boolean = JsonDatatype.BOOLEAN;
static date = JsonDatatype.DATETIME;
}

export interface DmnColumn {
label: string;
id: string;
index: number;
type: string;
}

@Component({
selector: 'xn-dmn-modeller',
templateUrl: 'dmnModeller.html',
Expand Down
6 changes: 6 additions & 0 deletions src/app/model/dmn/dmnColumn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface DmnColumn {
label: string;
id: string;
index: number;
type: string;
}
10 changes: 10 additions & 0 deletions src/app/model/dmn/dmnDatatypeMapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsonDatatype } from '../json/jsonDatatypes';

export class DmnDatatypeMapping {
static string = JsonDatatype.STRING;
static integer = JsonDatatype.INTEGER;
static long = JsonDatatype.INTEGER;
static double = JsonDatatype.NUMBER;
static boolean = JsonDatatype.BOOLEAN;
static date = JsonDatatype.DATETIME;
}
15 changes: 15 additions & 0 deletions src/app/model/dmn/dmnJS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DmnModelerView } from './dmnModelerView';
import { MyDmnModdle } from './dmnModdle';

export interface DMNJS {
_viewers: any;
_activeView: DmnModelerView;
_moddle: MyDmnModdle;
importXML(xml: string, callback: (error: any) => void);
saveXML(options: any, callback: (error: any, xml: string) => void);
getViews(): DmnModelerView[];
on(eventname: string, eventCallback: (event) => void);
_updateViews(): void;
_switchView(tableId: string);
getActiveViewer(): DmnModelerView;
}
8 changes: 8 additions & 0 deletions src/app/model/dmn/dmnModelerView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DmnModdleElement } from './dmnModdleElement';
import { DmnModelingType } from './dmnModelingType';
import { Modeling } from './modeling';

export interface DmnModelerView {
element: DmnModdleElement;
get(value: DmnModelingType): Modeling;
}
1 change: 1 addition & 0 deletions src/app/model/dmn/dmnModelingType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type DmnModelingType = 'modeling';
19 changes: 19 additions & 0 deletions src/app/model/dmn/modeling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { DmnBusinessObject } from './dmnBusinessObject';
import { DmnModdleRule } from './dmnModdleRule';
import { DmnModdleElement } from './dmnModdleElement';

export interface Modeling {
editAllowedValues(businessObject: DmnBusinessObject, restrictionSet: string[]);
editAnnotation(rule: DmnModdleRule, value: string);
editCell(cell: any, value: string);
editDecisionTableId(newId: string);
editDecisionTableName(newName);
editExpressionLanguage(element: DmnModdleElement, language: string);
editHitPolicy(hitPolicy: string, aggregation: string);
editInputExpression(inputExpression: unknown, value);
editInputExpressionTypeRef(inputExpression: unknown, typeRef: string);
editOutputName(output: DmnModdleElement, newName: string);
editOutputTypeRef(output: DmnModdleElement, typeRef: string);

addRow(ruleConfig: Object): { cells: DmnBusinessObject[] };
}
3 changes: 3 additions & 0 deletions src/app/model/dmn/shape.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface Shape {
id: string;
}
5 changes: 5 additions & 0 deletions src/app/model/dmn/shapeEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ShapeEventContext } from './shapeEventContext';

export interface ShapeEvent {
context: ShapeEventContext;
}
5 changes: 5 additions & 0 deletions src/app/model/dmn/shapeEventContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Shape } from './shape';

export interface ShapeEventContext {
shape: Shape;
}

0 comments on commit 1723d29

Please sign in to comment.