UNPKG

@eclipse-emfcloud/modelserver-client

Version:

Typescript rest client to interact with an EMF.cloud modelserver

122 lines 5.41 kB
/******************************************************************************** * Copyright (c) 2021-2022 STMicroelectronics and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * https://www.eclipse.org/legal/epl-2.0, or the MIT License which is * available at https://opensource.org/licenses/MIT. * * SPDX-License-Identifier: EPL-2.0 OR MIT *******************************************************************************/ import { Operation } from 'fast-json-patch'; import * as URI from 'urijs'; import { ModelServerObjectV2 } from '.'; import { CommandExecutionResult } from './model/command-model'; import { Diagnostic } from './model/diagnostic'; import { ModelServerMessage } from './model-server-message'; import { AnyObject } from './utils/type-util'; /** * A `ModelServerNotification` represents the payload object that is sent by the modelserver over websocket to * notify subscribers about the current model state. */ export interface ModelServerNotification { modeluri: URI; type: string; } export declare namespace ModelServerNotification { function is(object?: unknown): object is ModelServerNotification; } /** * A `CloseNotification` is sent to notify subscribers that the subscription for a model has ended. Can be triggered * either directly by invoking the `unsubscribe` method of a `ModelServerClient` or indirectly * i.e. the websocket connection gets closed. */ export interface CloseNotification extends ModelServerNotification { /** The status code of the websocket connect */ code: number; /** The reason why the subscription was closed */ reason: string; } export declare namespace CloseNotification { function is(object?: unknown): object is CloseNotification; } /** * An `ErrorNotification` is sent to notify subscribers about an error occurred in connection with the subscribed the subscripted for. */ export interface ErrorNotification extends ModelServerNotification { /** The error that occurred. */ error: unknown; } export declare namespace ErrorNotification { function is(object?: unknown): object is ErrorNotification; } /** * A `DirtyStateNotification` is sent to notify subscribers about dirty state changes. */ export interface DirtyStateNotification extends ModelServerNotification { /** Boolean flag to indicate wether the model is currently dirty */ isDirty: boolean; } export declare namespace DirtyStateNotification { function is(object?: unknown): object is DirtyStateNotification; } /** * An `IncrementalUpdateNotification` is sent to notify subscribers about an incremental model change. * The incremental change is described using {@link CommandExecutionResult}. */ export interface IncrementalUpdateNotification extends ModelServerNotification { /** The description of the incremental change */ result: CommandExecutionResult | string; } export declare namespace IncrementalUpdateNotification { function is(object?: unknown): object is IncrementalUpdateNotification; } /** * An `IncrementalUpdateNotification` is sent to notify subscribers about an incremental model change. * The incremental change is described using JsonPatch {@link Operation}[] */ export interface IncrementalUpdateNotificationV2 extends ModelServerNotification { /** The description of the incremental change */ patch: Operation[]; /** * A function to apply the patch on the previous version of the model. * @param oldModel The model to patch. * @param copy by default, the patch will be directly applied to the oldModel, modifying * it in-place. If copy is true, the patch will be applied on a copy of the model, leaving * the original model unchanged. * @return the patched model. */ patchModel(oldModel: ModelServerObjectV2, copy?: boolean): ModelServerObjectV2; } /** * A `FullUpdateNotification` is sent to notify subscribers about an model change. * The message contains the serialized updated model. * @typeParam M The concrete type of the updated model. Default is {@link AnyObject}. */ export interface FullUpdateNotification<M = AnyObject> extends ModelServerNotification { /** The model that has been updated */ model: M | string; } export declare namespace FullUpdateNotification { function is(object?: unknown): object is FullUpdateNotification; } /** * A `ValidationNotification` is sent to notify subscribers about the result of a validation request. * The validation result is described using {@link Diagnostic}. */ export interface ValidationNotification extends ModelServerNotification { /** The description of the validation result */ diagnostic: Diagnostic; } export declare namespace ValidationNotification { function is(object?: unknown): object is ValidationNotification; } /** * If the type of a incoming notification cannot be mapped to concrete subtype of {@link ModelServerNotification} * it defaults to the unknown type. Exposes the data property of the original {@link ModelServerMessage} to enable custom processing */ export type UnknownNotification = ModelServerNotification & ModelServerMessage; export declare namespace UnknownNotification { function is(object?: unknown): object is UnknownNotification; } //# sourceMappingURL=model-server-notification.d.ts.map