@eclipse-emfcloud/model-service
Version:
Model service framework
30 lines • 1.73 kB
TypeScript
import { Trigger, TriggerEngineImpl } from '@eclipse-emfcloud/trigger-engine';
import { Operation } from 'fast-json-patch';
import { ModelTrigger } from '../api/model-trigger';
interface ModelWithId<K = string, M extends object = object> {
modelId: NonNullable<K>;
model: NonNullable<M>;
}
/**
* A customized trigger engine that wraps the models it operates on
* to decorate them with the `modelId`, which is subsequently extracted
* to pass along to the `ModelTrigger`s that are adapted for that usage.
*/
export declare class ModelTriggerEngine<K = string> extends TriggerEngineImpl {
/**
* Compute triggers for changes to a `model`.
*
* @param modelId the model ID for which to compute triggers
* @param model the model document for which to compute triggers
* @param delta the changes for which to compute triggers
* @param previousModel the previous state of the model document before the `delta`
* @returns the new changes provided by triggers to follow up the `delta`, if any
*/
applyModelTriggers<M extends object = object>(modelId: NonNullable<K>, model: NonNullable<M>, delta: Operation[], previousModel: NonNullable<M>): Promise<Operation[] | undefined>;
addModelTrigger<M extends object = object>(modelTrigger: ModelTrigger<K, M>): void;
protected adaptTrigger<M extends object = object>(trigger: ModelTrigger<K, M>): Trigger<ModelWithId<K, M>>;
protected applyPatch(workingCopy: NonNullable<ModelWithId>, patch: Operation[]): void;
protected compare<M extends object = object>(document: NonNullable<ModelWithId<K, M>>, workingCopy: NonNullable<ModelWithId<K, M>>): Operation[];
}
export {};
//# sourceMappingURL=model-trigger-engine.d.ts.map