@eang/core
Version:
eang - model driven enterprise event processing
67 lines • 1.79 kB
JavaScript
import { Obj } from '../entity.js';
export class EventObj extends Obj {
typeOf = 'Event';
constructor(opts) {
super({ ...opts, typeOf: 'Event' });
}
}
export function isEventObj(obj) {
return obj.typeOf === 'Event';
}
export class EventInstanceObj extends Obj {
typeOf = 'EventInstance';
constructor(opts) {
super({ ...opts, typeOf: 'EventInstance' });
}
get instanceOfId() {
if (this.instanceOf) {
return `Event/${this.instanceOf}`;
}
return undefined;
}
}
export function isEventInstanceObj(obj) {
return obj.typeOf === 'EventInstance';
}
export class ErrorEventObj extends Obj {
typeOf = 'ErrorEvent';
constructor(opts) {
super({ ...opts, typeOf: 'ErrorEvent' });
}
}
export function isErrorEventObj(obj) {
return obj.typeOf === 'ErrorEvent';
}
export class ErrorEventInstanceObj extends Obj {
typeOf = 'ErrorEventInstance';
message;
code;
stack;
cause;
severity = 'error';
/** Error occurrence time is tracked via createdAt */
constructor(opts) {
super({ ...opts, typeOf: 'ErrorEventInstance' });
this.message = opts.message;
if (opts.code !== undefined) {
this.code = opts.code;
}
if (opts.stack !== undefined) {
this.stack = opts.stack;
}
if (opts.cause !== undefined) {
this.cause = opts.cause;
}
this.severity = opts.severity || 'error';
}
get instanceOfId() {
if (this.instanceOf) {
return `ErrorEvent/${this.instanceOf}`;
}
return undefined;
}
}
export function isErrorEventInstanceObj(obj) {
return obj.typeOf === 'ErrorEventInstance';
}
//# sourceMappingURL=events.js.map