@eclipse-glsp/protocol
Advanced tools
Comparing version 1.1.0-next.fe0b297.182 to 2.1.0-next.12ca798.289
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -16,3 +16,2 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
import { JsonPrimitive } from 'sprotty-protocol'; | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
@@ -73,2 +72,6 @@ import { TypeGuard } from '../utils/type-util'; | ||
requestId: string; | ||
/** | ||
* Used to ensure correct typing. Clients must not use this property | ||
*/ | ||
readonly _?: Res; | ||
} | ||
@@ -125,9 +128,9 @@ export declare namespace RequestAction { | ||
*/ | ||
detail?: JsonPrimitive; | ||
detail?: string; | ||
} | ||
export declare namespace RejectAction { | ||
const KIND = "rejectRequest"; | ||
function is(object: any): object is RejectAction; | ||
function is(object: unknown): object is RejectAction; | ||
function create(message: string, options?: { | ||
detail?: JsonPrimitive; | ||
detail?: string; | ||
responseId?: string; | ||
@@ -150,3 +153,3 @@ }): RejectAction; | ||
export declare namespace Operation { | ||
function is(object: any): object is Operation; | ||
function is(object: unknown): object is Operation; | ||
/** | ||
@@ -158,3 +161,3 @@ * Typeguard function to check wether the given object is an {@link Operation} with the given `kind`. | ||
*/ | ||
function hasKind(object: any, kind: string): object is Operation; | ||
function hasKind(object: unknown, kind: string): object is Operation; | ||
} | ||
@@ -175,5 +178,5 @@ /** | ||
const KIND = "compound"; | ||
function is(object: any): object is CompoundOperation; | ||
function is(object: unknown): object is CompoundOperation; | ||
function create(operationList: Operation[]): CompoundOperation; | ||
} | ||
//# sourceMappingURL=base-protocol.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CompoundOperation = exports.Operation = exports.RejectAction = exports.ResponseAction = exports.RequestAction = exports.ActionMessage = exports.Action = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2023 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 | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
const sprotty = require("sprotty-protocol/lib/actions"); | ||
@@ -22,3 +37,3 @@ const type_util_1 = require("../utils/type-util"); | ||
Action.hasKind = hasKind; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
var ActionMessage; | ||
@@ -28,6 +43,6 @@ (function (ActionMessage) { | ||
const actionGuard = typeguard !== null && typeguard !== void 0 ? typeguard : Action.is; | ||
return type_util_1.AnyObject.is(object) && (0, type_util_1.hasStringProp)(object, 'clientId') && actionGuard(object.action); | ||
return type_util_1.AnyObject.is(object) && (0, type_util_1.hasStringProp)(object, 'clientId') && 'action' in object && actionGuard(object.action); | ||
} | ||
ActionMessage.is = is; | ||
})(ActionMessage = exports.ActionMessage || (exports.ActionMessage = {})); | ||
})(ActionMessage || (exports.ActionMessage = ActionMessage = {})); | ||
var RequestAction; | ||
@@ -53,3 +68,3 @@ (function (RequestAction) { | ||
RequestAction.generateRequestId = generateRequestId; | ||
})(RequestAction = exports.RequestAction || (exports.RequestAction = {})); | ||
})(RequestAction || (exports.RequestAction = RequestAction = {})); | ||
var ResponseAction; | ||
@@ -70,3 +85,3 @@ (function (ResponseAction) { | ||
ResponseAction.hasValidResponseId = hasValidResponseId; | ||
})(ResponseAction = exports.ResponseAction || (exports.ResponseAction = {})); | ||
})(ResponseAction || (exports.ResponseAction = ResponseAction = {})); | ||
var RejectAction; | ||
@@ -83,7 +98,7 @@ (function (RejectAction) { | ||
RejectAction.create = create; | ||
})(RejectAction = exports.RejectAction || (exports.RejectAction = {})); | ||
})(RejectAction || (exports.RejectAction = RejectAction = {})); | ||
var Operation; | ||
(function (Operation) { | ||
function is(object) { | ||
return Action.is(object) && object.isOperation === true; | ||
return Action.is(object) && 'isOperation' in object && object.isOperation === true; | ||
} | ||
@@ -101,3 +116,3 @@ Operation.is = is; | ||
Operation.hasKind = hasKind; | ||
})(Operation = exports.Operation || (exports.Operation = {})); | ||
})(Operation || (exports.Operation = Operation = {})); | ||
var CompoundOperation; | ||
@@ -118,3 +133,3 @@ (function (CompoundOperation) { | ||
CompoundOperation.create = create; | ||
})(CompoundOperation = exports.CompoundOperation || (exports.CompoundOperation = {})); | ||
})(CompoundOperation || (exports.CompoundOperation = CompoundOperation = {})); | ||
//# sourceMappingURL=base-protocol.js.map |
@@ -21,2 +21,3 @@ "use strict"; | ||
const base_protocol_1 = require("./base-protocol"); | ||
const type_util_1 = require("../utils/type-util"); | ||
/** | ||
@@ -212,3 +213,3 @@ * Tests for the utility functions declared in the namespaces of the protocol | ||
}); | ||
const isSomeCustomAction = (object) => object !== undefined && object.kind === 'custom'; | ||
const isSomeCustomAction = (object) => type_util_1.AnyObject.is(object) && 'kind' in object && object.kind === 'custom'; | ||
//# sourceMappingURL=base-protocol.spec.js.map |
import { Action } from './base-protocol'; | ||
/** | ||
* Sent by the server to signal a state change. | ||
* Sent by the server (or the client) to signal a status change. | ||
* If a timeout is given the respective status should disappear after the timeout is reached. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `ServerStatusActions`. | ||
* and creating new `StatusAction`s. | ||
*/ | ||
export interface ServerStatusAction extends Action { | ||
kind: typeof ServerStatusAction.KIND; | ||
export interface StatusAction extends Action { | ||
kind: typeof StatusAction.KIND; | ||
/** | ||
* The severity of the status. | ||
*/ | ||
severity: ServerSeverity; | ||
severity: SeverityLevel; | ||
/** | ||
@@ -23,9 +23,9 @@ * The user-facing message describing the status. | ||
} | ||
export declare namespace ServerStatusAction { | ||
const KIND = "serverStatus"; | ||
function is(object: any): object is ServerStatusAction; | ||
export declare namespace StatusAction { | ||
const KIND = "status"; | ||
function is(object: unknown): object is StatusAction; | ||
function create(message: string, options?: { | ||
severity?: ServerSeverity; | ||
severity?: SeverityLevel; | ||
timeout?: number; | ||
}): ServerStatusAction; | ||
}): StatusAction; | ||
} | ||
@@ -35,13 +35,13 @@ /** | ||
*/ | ||
export declare type ServerSeverity = 'NONE' | 'INFO' | 'WARNING' | 'ERROR' | 'FATAL' | 'OK'; | ||
export type SeverityLevel = 'NONE' | 'INFO' | 'WARNING' | 'ERROR' | 'FATAL' | 'OK'; | ||
/** | ||
* Sent by the server to notify the user about something of interest. Typically this message is handled by | ||
* Sent by the server (or the client) to notify the user about something of interest. Typically this message is handled by | ||
* the client by showing a message to the user with the application's message service. | ||
* If a timeout is given the respective message should disappear after the timeout is reached. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `ServerMessageActions`. | ||
* and creating new `MessageAction`s. | ||
*/ | ||
export interface ServerMessageAction extends Action { | ||
kind: typeof ServerMessageAction.KIND; | ||
severity: ServerSeverity; | ||
export interface MessageAction extends Action { | ||
kind: typeof MessageAction.KIND; | ||
severity: SeverityLevel; | ||
/** | ||
@@ -55,16 +55,88 @@ * The message that shall be shown to the user. | ||
details?: string; | ||
/** | ||
* Timeout after which a displayed message disappears. | ||
*/ | ||
timeout?: number; | ||
} | ||
export declare namespace ServerMessageAction { | ||
const KIND = "serverMessage"; | ||
function is(object: any): object is ServerMessageAction; | ||
export declare namespace MessageAction { | ||
const KIND = "message"; | ||
function is(object: unknown): object is MessageAction; | ||
function create(message: string, options?: { | ||
severity?: ServerSeverity; | ||
severity?: SeverityLevel; | ||
details?: string; | ||
timeout?: number; | ||
}): ServerMessageAction; | ||
}): MessageAction; | ||
} | ||
/** | ||
* Sent to request presenting the progress of a long running process in the UI. | ||
*/ | ||
export interface StartProgressAction extends Action { | ||
kind: typeof StartProgressAction.KIND; | ||
/** | ||
* An ID that can be used in subsequent `updateProgress` and `endProgress` events to make them refer to the same progress reporting. | ||
*/ | ||
progressId: string; | ||
/** | ||
* Short title of the progress reporting. Shown in the UI to describe the long running process. | ||
*/ | ||
title: string; | ||
/** | ||
* Optional additional progress message. Shown in the UI to describe the long running process. | ||
*/ | ||
message?: string; | ||
/** | ||
* Progress percentage to display (value range: 0 to 100). If omitted no percentage is shown. | ||
*/ | ||
percentage?: number; | ||
} | ||
export declare namespace StartProgressAction { | ||
const KIND = "startProgress"; | ||
function is(object: unknown): object is StartProgressAction; | ||
function create(options: { | ||
progressId: string; | ||
title: string; | ||
message?: string; | ||
percentage?: number; | ||
}): StartProgressAction; | ||
} | ||
/** | ||
* Sent to presenting an update of the progress of a long running process in the UI. | ||
*/ | ||
export interface UpdateProgressAction extends Action { | ||
kind: typeof UpdateProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
/** | ||
* The percentage (value range: 0 to 100) to show in the progress reporting. | ||
*/ | ||
percentage?: number; | ||
} | ||
export declare namespace UpdateProgressAction { | ||
const KIND = "updateProgress"; | ||
function is(object: unknown): object is UpdateProgressAction; | ||
function create(progressId: string, options?: { | ||
message?: string; | ||
percentage?: number; | ||
}): UpdateProgressAction; | ||
} | ||
/** | ||
* Sent to end the reporting of a progress. | ||
*/ | ||
export interface EndProgressAction extends Action { | ||
kind: typeof EndProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
} | ||
export declare namespace EndProgressAction { | ||
const KIND = "endProgress"; | ||
function is(object: unknown): object is EndProgressAction; | ||
function create(progressId: string, message?: string): EndProgressAction; | ||
} | ||
//# sourceMappingURL=client-notification.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ServerMessageAction = exports.ServerStatusAction = void 0; | ||
exports.EndProgressAction = exports.UpdateProgressAction = exports.StartProgressAction = exports.MessageAction = exports.StatusAction = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -21,26 +21,66 @@ * This program and the accompanying materials are made available under the | ||
const base_protocol_1 = require("./base-protocol"); | ||
var ServerStatusAction; | ||
(function (ServerStatusAction) { | ||
ServerStatusAction.KIND = 'serverStatus'; | ||
var StatusAction; | ||
(function (StatusAction) { | ||
StatusAction.KIND = 'status'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, ServerStatusAction.KIND) && (0, type_util_1.hasStringProp)(object, 'severity') && (0, type_util_1.hasStringProp)(object, 'message'); | ||
return base_protocol_1.Action.hasKind(object, StatusAction.KIND) && (0, type_util_1.hasStringProp)(object, 'severity') && (0, type_util_1.hasStringProp)(object, 'message'); | ||
} | ||
ServerStatusAction.is = is; | ||
StatusAction.is = is; | ||
function create(message, options = {}) { | ||
return Object.assign({ kind: ServerStatusAction.KIND, severity: 'INFO', message }, options); | ||
return Object.assign({ kind: StatusAction.KIND, severity: 'INFO', message }, options); | ||
} | ||
ServerStatusAction.create = create; | ||
})(ServerStatusAction = exports.ServerStatusAction || (exports.ServerStatusAction = {})); | ||
var ServerMessageAction; | ||
(function (ServerMessageAction) { | ||
ServerMessageAction.KIND = 'serverMessage'; | ||
StatusAction.create = create; | ||
})(StatusAction || (exports.StatusAction = StatusAction = {})); | ||
var MessageAction; | ||
(function (MessageAction) { | ||
MessageAction.KIND = 'message'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, ServerMessageAction.KIND) && (0, type_util_1.hasStringProp)(object, 'message') && (0, type_util_1.hasStringProp)(object, 'severity'); | ||
return base_protocol_1.Action.hasKind(object, MessageAction.KIND) && (0, type_util_1.hasStringProp)(object, 'message') && (0, type_util_1.hasStringProp)(object, 'severity'); | ||
} | ||
ServerMessageAction.is = is; | ||
MessageAction.is = is; | ||
function create(message, options = {}) { | ||
return Object.assign({ kind: ServerMessageAction.KIND, message, severity: 'INFO' }, options); | ||
return Object.assign({ kind: MessageAction.KIND, message, severity: 'INFO' }, options); | ||
} | ||
ServerMessageAction.create = create; | ||
})(ServerMessageAction = exports.ServerMessageAction || (exports.ServerMessageAction = {})); | ||
MessageAction.create = create; | ||
})(MessageAction || (exports.MessageAction = MessageAction = {})); | ||
var StartProgressAction; | ||
(function (StartProgressAction) { | ||
StartProgressAction.KIND = 'startProgress'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, StartProgressAction.KIND) && (0, type_util_1.hasStringProp)(object, 'progressId') && (0, type_util_1.hasStringProp)(object, 'title'); | ||
} | ||
StartProgressAction.is = is; | ||
function create(options) { | ||
return Object.assign({ kind: StartProgressAction.KIND }, options); | ||
} | ||
StartProgressAction.create = create; | ||
})(StartProgressAction || (exports.StartProgressAction = StartProgressAction = {})); | ||
var UpdateProgressAction; | ||
(function (UpdateProgressAction) { | ||
UpdateProgressAction.KIND = 'updateProgress'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, UpdateProgressAction.KIND) && (0, type_util_1.hasStringProp)(object, 'progressId'); | ||
} | ||
UpdateProgressAction.is = is; | ||
function create(progressId, options = {}) { | ||
return Object.assign({ kind: UpdateProgressAction.KIND, progressId }, options); | ||
} | ||
UpdateProgressAction.create = create; | ||
})(UpdateProgressAction || (exports.UpdateProgressAction = UpdateProgressAction = {})); | ||
var EndProgressAction; | ||
(function (EndProgressAction) { | ||
EndProgressAction.KIND = 'endProgress'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, EndProgressAction.KIND) && (0, type_util_1.hasStringProp)(object, 'progressId'); | ||
} | ||
EndProgressAction.is = is; | ||
function create(progressId, message) { | ||
return { | ||
kind: EndProgressAction.KIND, | ||
progressId, | ||
message | ||
}; | ||
} | ||
EndProgressAction.create = create; | ||
})(EndProgressAction || (exports.EndProgressAction = EndProgressAction = {})); | ||
//# sourceMappingURL=client-notification.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -26,13 +26,13 @@ * This program and the accompanying materials are made available under the | ||
describe('Client notification actions', () => { | ||
describe('ServerStatusAction', () => { | ||
describe('StatusAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const statusAction = { kind: 'serverStatus', message: 'Some', severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.ServerStatusAction.is(statusAction)).to.be.true; | ||
const statusAction = { kind: client_notification_1.StatusAction.KIND, message: 'Some', severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.StatusAction.is(statusAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(client_notification_1.ServerStatusAction.is(undefined)).to.be.false; | ||
(0, chai_1.expect)(client_notification_1.StatusAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(client_notification_1.ServerStatusAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
(0, chai_1.expect)(client_notification_1.StatusAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -43,8 +43,8 @@ }); | ||
const message = 'someMessage'; | ||
const expected = { kind: client_notification_1.ServerStatusAction.KIND, message, severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.ServerStatusAction.create(message)).to.deep.equals(expected); | ||
const expected = { kind: client_notification_1.StatusAction.KIND, message, severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.StatusAction.create(message)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: client_notification_1.ServerStatusAction.KIND, | ||
kind: client_notification_1.StatusAction.KIND, | ||
message: 'someMessage', | ||
@@ -55,17 +55,17 @@ severity: 'ERROR', | ||
const { message, severity, timeout } = expected; | ||
(0, chai_1.expect)(client_notification_1.ServerStatusAction.create(message, { severity, timeout })).to.deep.equals(expected); | ||
(0, chai_1.expect)(client_notification_1.StatusAction.create(message, { severity, timeout })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('ServerMessageAction', () => { | ||
describe('MessageAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction = { kind: 'serverMessage', message: '', severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.ServerMessageAction.is(messageAction)).to.be.true; | ||
const messageAction = { kind: client_notification_1.MessageAction.KIND, message: '', severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.MessageAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(client_notification_1.ServerMessageAction.is(undefined)).to.be.false; | ||
(0, chai_1.expect)(client_notification_1.MessageAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(client_notification_1.ServerMessageAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
(0, chai_1.expect)(client_notification_1.MessageAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -76,19 +76,112 @@ }); | ||
const message = 'someMessage'; | ||
const expected = { kind: client_notification_1.ServerMessageAction.KIND, message, severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.ServerMessageAction.create(message)).to.deep.equals(expected); | ||
const expected = { kind: client_notification_1.MessageAction.KIND, message, severity: 'INFO' }; | ||
(0, chai_1.expect)(client_notification_1.MessageAction.create(message)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: client_notification_1.ServerMessageAction.KIND, | ||
kind: client_notification_1.MessageAction.KIND, | ||
message: 'someMessage', | ||
details: 'details', | ||
severity: 'ERROR', | ||
timeout: 5 | ||
severity: 'ERROR' | ||
}; | ||
const { message, severity, timeout, details } = expected; | ||
(0, chai_1.expect)(client_notification_1.ServerMessageAction.create(message, { severity, timeout, details })).to.deep.equals(expected); | ||
const { message, severity, details } = expected; | ||
(0, chai_1.expect)(client_notification_1.MessageAction.create(message, { severity, details })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('StartProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction = { kind: 'startProgress', progressId: '1', title: 'Progress title' }; | ||
(0, chai_1.expect)(client_notification_1.StartProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(client_notification_1.StartProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(client_notification_1.StartProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const title = 'Progress title'; | ||
const expected = { kind: client_notification_1.StartProgressAction.KIND, progressId, title }; | ||
(0, chai_1.expect)(client_notification_1.StartProgressAction.create({ progressId, title })).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: client_notification_1.StartProgressAction.KIND, | ||
progressId: '1', | ||
title: 'Progress title', | ||
message: 'Some message', | ||
percentage: 10 | ||
}; | ||
const { progressId, title, message, percentage } = expected; | ||
(0, chai_1.expect)(client_notification_1.StartProgressAction.create({ progressId, title, message, percentage })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('UpdateProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction = { kind: 'updateProgress', progressId: '1' }; | ||
(0, chai_1.expect)(client_notification_1.UpdateProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(client_notification_1.UpdateProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(client_notification_1.UpdateProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const expected = { kind: client_notification_1.UpdateProgressAction.KIND, progressId }; | ||
(0, chai_1.expect)(client_notification_1.UpdateProgressAction.create(progressId)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: client_notification_1.UpdateProgressAction.KIND, | ||
progressId: '1', | ||
message: 'Some message', | ||
percentage: 10 | ||
}; | ||
const { progressId, message, percentage } = expected; | ||
(0, chai_1.expect)(client_notification_1.UpdateProgressAction.create(progressId, { message, percentage })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('EndProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction = { kind: 'endProgress', progressId: '1' }; | ||
(0, chai_1.expect)(client_notification_1.EndProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(client_notification_1.EndProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(client_notification_1.EndProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const expected = { kind: client_notification_1.EndProgressAction.KIND, progressId, message: undefined }; | ||
(0, chai_1.expect)(client_notification_1.EndProgressAction.create(progressId)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: client_notification_1.EndProgressAction.KIND, | ||
progressId: '1', | ||
message: 'Some message' | ||
}; | ||
const { progressId, message } = expected; | ||
(0, chai_1.expect)(client_notification_1.EndProgressAction.create(progressId, message)).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=client-notification.spec.js.map |
@@ -29,3 +29,3 @@ /******************************************************************************** | ||
const KIND = "requestClipboardData"; | ||
function is(object: any): object is RequestClipboardDataAction; | ||
function is(object: unknown): object is RequestClipboardDataAction; | ||
function create(editorContext: EditorContext, options?: { | ||
@@ -49,3 +49,3 @@ requestId?: string; | ||
const KIND = "setClipboardData"; | ||
function is(object: any): object is SetClipboardDataAction; | ||
function is(object: unknown): object is SetClipboardDataAction; | ||
function create(clipboardData: ClipboardData, options?: { | ||
@@ -67,3 +67,3 @@ responseId?: string; | ||
const KIND = "cut"; | ||
function is(object: any): object is CutOperation; | ||
function is(object: unknown): object is CutOperation; | ||
function create(editorContext: EditorContext): CutOperation; | ||
@@ -87,3 +87,3 @@ } | ||
const KIND = "paste"; | ||
function is(object: any): object is PasteOperation; | ||
function is(object: unknown): object is PasteOperation; | ||
function create(options: { | ||
@@ -90,0 +90,0 @@ editorContext: EditorContext; |
@@ -32,3 +32,3 @@ "use strict"; | ||
RequestClipboardDataAction.create = create; | ||
})(RequestClipboardDataAction = exports.RequestClipboardDataAction || (exports.RequestClipboardDataAction = {})); | ||
})(RequestClipboardDataAction || (exports.RequestClipboardDataAction = RequestClipboardDataAction = {})); | ||
var SetClipboardDataAction; | ||
@@ -45,3 +45,3 @@ (function (SetClipboardDataAction) { | ||
SetClipboardDataAction.create = create; | ||
})(SetClipboardDataAction = exports.SetClipboardDataAction || (exports.SetClipboardDataAction = {})); | ||
})(SetClipboardDataAction || (exports.SetClipboardDataAction = SetClipboardDataAction = {})); | ||
var CutOperation; | ||
@@ -62,3 +62,3 @@ (function (CutOperation) { | ||
CutOperation.create = create; | ||
})(CutOperation = exports.CutOperation || (exports.CutOperation = {})); | ||
})(CutOperation || (exports.CutOperation = CutOperation = {})); | ||
var PasteOperation; | ||
@@ -75,3 +75,3 @@ (function (PasteOperation) { | ||
PasteOperation.create = create; | ||
})(PasteOperation = exports.PasteOperation || (exports.PasteOperation = {})); | ||
})(PasteOperation || (exports.PasteOperation = PasteOperation = {})); | ||
//# sourceMappingURL=clipboard.js.map |
@@ -33,3 +33,3 @@ /******************************************************************************** | ||
const KIND = "requestContextActions"; | ||
function is(object: any): object is RequestContextActions; | ||
function is(object: unknown): object is RequestContextActions; | ||
function create(options: { | ||
@@ -59,3 +59,3 @@ contextId: string; | ||
const KIND = "setContextActions"; | ||
function is(object: any): object is SetContextActions; | ||
function is(object: unknown): object is SetContextActions; | ||
function create(actions: LabeledAction[], options?: { | ||
@@ -62,0 +62,0 @@ args?: Args; |
@@ -32,3 +32,3 @@ "use strict"; | ||
RequestContextActions.create = create; | ||
})(RequestContextActions = exports.RequestContextActions || (exports.RequestContextActions = {})); | ||
})(RequestContextActions || (exports.RequestContextActions = RequestContextActions = {})); | ||
var SetContextActions; | ||
@@ -45,3 +45,3 @@ (function (SetContextActions) { | ||
SetContextActions.create = create; | ||
})(SetContextActions = exports.SetContextActions || (exports.SetContextActions = {})); | ||
})(SetContextActions || (exports.SetContextActions = SetContextActions = {})); | ||
//# sourceMappingURL=contexts.js.map |
@@ -41,3 +41,3 @@ /******************************************************************************** | ||
const KIND = "reconnectEdge"; | ||
function is(object: any): object is ReconnectEdgeOperation; | ||
function is(object: unknown): object is ReconnectEdgeOperation; | ||
function create(options: { | ||
@@ -65,5 +65,5 @@ edgeElementId: string; | ||
const KIND = "changeRoutingPoints"; | ||
function is(object: any): object is ChangeRoutingPointsOperation; | ||
function is(object: unknown): object is ChangeRoutingPointsOperation; | ||
function create(newRoutingPoints: ElementAndRoutingPoints[]): ChangeRoutingPointsOperation; | ||
} | ||
//# sourceMappingURL=edge-modification.d.ts.map |
@@ -35,3 +35,3 @@ "use strict"; | ||
ReconnectEdgeOperation.create = create; | ||
})(ReconnectEdgeOperation = exports.ReconnectEdgeOperation || (exports.ReconnectEdgeOperation = {})); | ||
})(ReconnectEdgeOperation || (exports.ReconnectEdgeOperation = ReconnectEdgeOperation = {})); | ||
var ChangeRoutingPointsOperation; | ||
@@ -52,3 +52,3 @@ (function (ChangeRoutingPointsOperation) { | ||
ChangeRoutingPointsOperation.create = create; | ||
})(ChangeRoutingPointsOperation = exports.ChangeRoutingPointsOperation || (exports.ChangeRoutingPointsOperation = {})); | ||
})(ChangeRoutingPointsOperation || (exports.ChangeRoutingPointsOperation = ChangeRoutingPointsOperation = {})); | ||
//# sourceMappingURL=edge-modification.js.map |
@@ -17,2 +17,3 @@ /******************************************************************************** | ||
import { Point } from 'sprotty-protocol'; | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { Operation } from './base-protocol'; | ||
@@ -35,3 +36,3 @@ import { Args } from './types'; | ||
export declare namespace CreateOperation { | ||
function is(object: any): object is CreateOperation; | ||
function is(object: unknown): object is CreateOperation; | ||
/** | ||
@@ -43,3 +44,3 @@ * Typeguard function to check wether the given object is a {@link CreateOperation} with the given `kind`. | ||
*/ | ||
function hasKind(object: any, kind: string): object is CreateOperation; | ||
function hasKind(object: unknown, kind: string): object is CreateOperation; | ||
} | ||
@@ -59,3 +60,3 @@ /** | ||
const KIND = "createNode"; | ||
function is(object: any): object is CreateNodeOperation; | ||
function is(object: unknown): object is CreateNodeOperation; | ||
function create(elementTypeId: string, options?: { | ||
@@ -80,3 +81,3 @@ location?: Point; | ||
const KIND = "createEdge"; | ||
function is(object: any): object is CreateEdgeOperation; | ||
function is(object: unknown): object is CreateEdgeOperation; | ||
function create(options: { | ||
@@ -94,3 +95,3 @@ elementTypeId: string; | ||
*/ | ||
export interface DeleteElementOperation extends Operation { | ||
export interface DeleteElementOperation extends Operation, Omit<sprotty.DeleteElementAction, 'kind'> { | ||
kind: typeof DeleteElementOperation.KIND; | ||
@@ -104,5 +105,5 @@ /** | ||
const KIND = "deleteElement"; | ||
function is(object: any): object is DeleteElementOperation; | ||
function is(object: unknown): object is DeleteElementOperation; | ||
function create(elementIds: string[]): DeleteElementOperation; | ||
} | ||
//# sourceMappingURL=element-creation.d.ts.map |
@@ -37,3 +37,3 @@ "use strict"; | ||
CreateOperation.hasKind = hasKind; | ||
})(CreateOperation = exports.CreateOperation || (exports.CreateOperation = {})); | ||
})(CreateOperation || (exports.CreateOperation = CreateOperation = {})); | ||
var CreateNodeOperation; | ||
@@ -50,3 +50,3 @@ (function (CreateNodeOperation) { | ||
CreateNodeOperation.create = create; | ||
})(CreateNodeOperation = exports.CreateNodeOperation || (exports.CreateNodeOperation = {})); | ||
})(CreateNodeOperation || (exports.CreateNodeOperation = CreateNodeOperation = {})); | ||
var CreateEdgeOperation; | ||
@@ -63,3 +63,3 @@ (function (CreateEdgeOperation) { | ||
CreateEdgeOperation.create = create; | ||
})(CreateEdgeOperation = exports.CreateEdgeOperation || (exports.CreateEdgeOperation = {})); | ||
})(CreateEdgeOperation || (exports.CreateEdgeOperation = CreateEdgeOperation = {})); | ||
var DeleteElementOperation; | ||
@@ -80,3 +80,3 @@ (function (DeleteElementOperation) { | ||
DeleteElementOperation.create = create; | ||
})(DeleteElementOperation = exports.DeleteElementOperation || (exports.DeleteElementOperation = {})); | ||
})(DeleteElementOperation || (exports.DeleteElementOperation = DeleteElementOperation = {})); | ||
//# sourceMappingURL=element-creation.js.map |
@@ -18,4 +18,4 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '../model/model-schema'; | ||
import { RequestAction, ResponseAction } from './base-protocol'; | ||
import { SModelRootSchema } from './model-structure'; | ||
/** | ||
@@ -40,3 +40,3 @@ * Triggered when the user hovers the mouse pointer over an element to get a popup with details on that element. | ||
const KIND = "requestPopupModel"; | ||
function is(object: any): object is RequestPopupModelAction; | ||
function is(object: unknown): object is RequestPopupModelAction; | ||
function create(options: { | ||
@@ -50,3 +50,3 @@ elementId: string; | ||
* Sent from the server to the client to display a popup in response to a RequestPopupModelAction. This action can also be used to remove | ||
* any existing popup by choosing EMPTY_ROOT as root element. | ||
* unknown existing popup by choosing EMPTY_ROOT as root element. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
@@ -57,8 +57,8 @@ * and creating new `SetPopupModelActions`. | ||
kind: typeof SetPopupModelAction.KIND; | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
} | ||
export declare namespace SetPopupModelAction { | ||
const KIND = "setPopupModel"; | ||
function is(object: any): object is SetPopupModelAction; | ||
function create(newRoot: SModelRootSchema, options?: { | ||
function is(object: unknown): object is SetPopupModelAction; | ||
function create(newRoot: GModelRootSchema, options?: { | ||
responseId?: string; | ||
@@ -65,0 +65,0 @@ }): SetPopupModelAction; |
@@ -17,3 +17,3 @@ "use strict"; | ||
RequestPopupModelAction.create = create; | ||
})(RequestPopupModelAction = exports.RequestPopupModelAction || (exports.RequestPopupModelAction = {})); | ||
})(RequestPopupModelAction || (exports.RequestPopupModelAction = RequestPopupModelAction = {})); | ||
var SetPopupModelAction; | ||
@@ -30,3 +30,3 @@ (function (SetPopupModelAction) { | ||
SetPopupModelAction.create = create; | ||
})(SetPopupModelAction = exports.SetPopupModelAction || (exports.SetPopupModelAction = {})); | ||
})(SetPopupModelAction || (exports.SetPopupModelAction = SetPopupModelAction = {})); | ||
//# sourceMappingURL=element-hover.js.map |
@@ -38,3 +38,3 @@ /******************************************************************************** | ||
export declare namespace NavigationTarget { | ||
function is(object: any): object is NavigationTarget; | ||
function is(object: unknown): object is NavigationTarget; | ||
/** | ||
@@ -126,3 +126,3 @@ * Generic key to store element ids as additional argument | ||
const KIND = "requestNavigationTargets"; | ||
function is(object: any): object is RequestNavigationTargetsAction; | ||
function is(object: unknown): object is RequestNavigationTargetsAction; | ||
function create(options: { | ||
@@ -151,3 +151,3 @@ targetTypeId: string; | ||
const KIND = "setNavigationTargets"; | ||
function is(object: any): object is SetNavigationTargetsAction; | ||
function is(object: unknown): object is SetNavigationTargetsAction; | ||
function create(targets: NavigationTarget[], options?: { | ||
@@ -169,3 +169,3 @@ args?: Args; | ||
const KIND = "navigateToTarget"; | ||
function is(object: any): object is NavigateToTargetAction; | ||
function is(object: unknown): object is NavigateToTargetAction; | ||
function create(target: NavigationTarget): NavigateToTargetAction; | ||
@@ -189,3 +189,3 @@ } | ||
const KIND = "resolveNavigationTarget"; | ||
function is(object: any): object is ResolveNavigationTargetAction; | ||
function is(object: unknown): object is ResolveNavigationTargetAction; | ||
function create(navigationTarget: NavigationTarget, options?: { | ||
@@ -214,3 +214,3 @@ requestId?: string; | ||
const KIND = "setResolvedNavigationTarget"; | ||
function is(object: any): object is SetResolvedNavigationTargetAction; | ||
function is(object: unknown): object is SetResolvedNavigationTargetAction; | ||
function create(elementIds: string[], options?: { | ||
@@ -237,5 +237,5 @@ args?: Args; | ||
const KIND = "navigateToExternalTarget"; | ||
function is(object: any): object is NavigateToExternalTargetAction; | ||
function is(object: unknown): object is NavigateToExternalTargetAction; | ||
function create(target: NavigationTarget): NavigateToExternalTargetAction; | ||
} | ||
//# sourceMappingURL=element-navigation.d.ts.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
function is(object) { | ||
return object !== undefined && (0, type_util_1.hasStringProp)(object, 'uri'); | ||
return type_util_1.AnyObject.is(object) && (0, type_util_1.hasStringProp)(object, 'uri'); | ||
} | ||
@@ -113,3 +113,3 @@ NavigationTarget.is = is; | ||
NavigationTarget.getTextPosition = getTextPosition; | ||
})(NavigationTarget = exports.NavigationTarget || (exports.NavigationTarget = {})); | ||
})(NavigationTarget || (exports.NavigationTarget = NavigationTarget = {})); | ||
var RequestNavigationTargetsAction; | ||
@@ -126,3 +126,3 @@ (function (RequestNavigationTargetsAction) { | ||
RequestNavigationTargetsAction.create = create; | ||
})(RequestNavigationTargetsAction = exports.RequestNavigationTargetsAction || (exports.RequestNavigationTargetsAction = {})); | ||
})(RequestNavigationTargetsAction || (exports.RequestNavigationTargetsAction = RequestNavigationTargetsAction = {})); | ||
var SetNavigationTargetsAction; | ||
@@ -139,3 +139,3 @@ (function (SetNavigationTargetsAction) { | ||
SetNavigationTargetsAction.create = create; | ||
})(SetNavigationTargetsAction = exports.SetNavigationTargetsAction || (exports.SetNavigationTargetsAction = {})); | ||
})(SetNavigationTargetsAction || (exports.SetNavigationTargetsAction = SetNavigationTargetsAction = {})); | ||
var NavigateToTargetAction; | ||
@@ -155,3 +155,3 @@ (function (NavigateToTargetAction) { | ||
NavigateToTargetAction.create = create; | ||
})(NavigateToTargetAction = exports.NavigateToTargetAction || (exports.NavigateToTargetAction = {})); | ||
})(NavigateToTargetAction || (exports.NavigateToTargetAction = NavigateToTargetAction = {})); | ||
var ResolveNavigationTargetAction; | ||
@@ -168,3 +168,3 @@ (function (ResolveNavigationTargetAction) { | ||
ResolveNavigationTargetAction.create = create; | ||
})(ResolveNavigationTargetAction = exports.ResolveNavigationTargetAction || (exports.ResolveNavigationTargetAction = {})); | ||
})(ResolveNavigationTargetAction || (exports.ResolveNavigationTargetAction = ResolveNavigationTargetAction = {})); | ||
var SetResolvedNavigationTargetAction; | ||
@@ -181,3 +181,3 @@ (function (SetResolvedNavigationTargetAction) { | ||
SetResolvedNavigationTargetAction.create = create; | ||
})(SetResolvedNavigationTargetAction = exports.SetResolvedNavigationTargetAction || (exports.SetResolvedNavigationTargetAction = {})); | ||
})(SetResolvedNavigationTargetAction || (exports.SetResolvedNavigationTargetAction = SetResolvedNavigationTargetAction = {})); | ||
var NavigateToExternalTargetAction; | ||
@@ -197,3 +197,3 @@ (function (NavigateToExternalTargetAction) { | ||
NavigateToExternalTargetAction.create = create; | ||
})(NavigateToExternalTargetAction = exports.NavigateToExternalTargetAction || (exports.NavigateToExternalTargetAction = {})); | ||
})(NavigateToExternalTargetAction || (exports.NavigateToExternalTargetAction = NavigateToExternalTargetAction = {})); | ||
//# sourceMappingURL=element-navigation.js.map |
@@ -35,10 +35,17 @@ /******************************************************************************** | ||
deselectedElementsIDs: string[]; | ||
/** | ||
* Whether all currently selected elements should be deselected. | ||
*/ | ||
deselectAll?: boolean; | ||
} | ||
export declare namespace SelectAction { | ||
const KIND = "elementSelected"; | ||
function is(object: any): object is SelectAction; | ||
function is(object: unknown): object is SelectAction; | ||
function create(options?: { | ||
selectedElementsIDs?: string[]; | ||
deselectedElementsIDs?: string[]; | ||
deselectedElementsIDs?: string[] | boolean; | ||
}): SelectAction; | ||
function addSelection(selectedElementsIDs: string[]): SelectAction; | ||
function removeSelection(deselectedElementsIDs: string[]): SelectAction; | ||
function setSelection(selectedElementsIDs: string[]): SelectAction; | ||
} | ||
@@ -59,5 +66,5 @@ /** | ||
const KIND = "allSelected"; | ||
function is(object: any): object is SelectAllAction; | ||
function is(object: unknown): object is SelectAllAction; | ||
function create(select?: boolean): SelectAllAction; | ||
} | ||
//# sourceMappingURL=element-selection.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SelectAllAction = exports.SelectAction = void 0; | ||
const array_util_1 = require("../utils/array-util"); | ||
const type_util_1 = require("../utils/type-util"); | ||
@@ -14,6 +15,25 @@ const base_protocol_1 = require("./base-protocol"); | ||
function create(options = {}) { | ||
return Object.assign({ kind: SelectAction.KIND, selectedElementsIDs: [], deselectedElementsIDs: [] }, options); | ||
var _a, _b; | ||
const deselectedElementsIDs = (_a = options.deselectedElementsIDs) !== null && _a !== void 0 ? _a : []; | ||
return { | ||
kind: SelectAction.KIND, | ||
selectedElementsIDs: (_b = options.selectedElementsIDs) !== null && _b !== void 0 ? _b : [], | ||
deselectedElementsIDs: (0, array_util_1.isStringArray)(deselectedElementsIDs, true) ? deselectedElementsIDs : [], | ||
deselectAll: typeof deselectedElementsIDs === 'boolean' ? deselectedElementsIDs : false | ||
}; | ||
} | ||
SelectAction.create = create; | ||
})(SelectAction = exports.SelectAction || (exports.SelectAction = {})); | ||
function addSelection(selectedElementsIDs) { | ||
return create({ selectedElementsIDs }); | ||
} | ||
SelectAction.addSelection = addSelection; | ||
function removeSelection(deselectedElementsIDs) { | ||
return create({ deselectedElementsIDs }); | ||
} | ||
SelectAction.removeSelection = removeSelection; | ||
function setSelection(selectedElementsIDs) { | ||
return create({ selectedElementsIDs, deselectedElementsIDs: true }); | ||
} | ||
SelectAction.setSelection = setSelection; | ||
})(SelectAction || (exports.SelectAction = SelectAction = {})); | ||
var SelectAllAction; | ||
@@ -33,3 +53,3 @@ (function (SelectAllAction) { | ||
SelectAllAction.create = create; | ||
})(SelectAllAction = exports.SelectAllAction || (exports.SelectAllAction = {})); | ||
})(SelectAllAction || (exports.SelectAllAction = SelectAllAction = {})); | ||
//# sourceMappingURL=element-selection.js.map |
@@ -48,3 +48,4 @@ "use strict"; | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: [] | ||
deselectedElementsIDs: [], | ||
deselectAll: false | ||
}; | ||
@@ -57,3 +58,4 @@ (0, chai_1.expect)(element_selection_1.SelectAction.create()).to.deep.equals(expected); | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: ['deselected'] | ||
deselectedElementsIDs: ['deselected'], | ||
deselectAll: false | ||
}; | ||
@@ -63,3 +65,49 @@ const { selectedElementsIDs, deselectedElementsIDs } = expected; | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments: deselectAll', () => { | ||
const expected = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: true | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
(0, chai_1.expect)(element_selection_1.SelectAction.create({ deselectedElementsIDs: true, selectedElementsIDs })).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('addSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: false | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
(0, chai_1.expect)(element_selection_1.SelectAction.addSelection(selectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('removeSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: ['deselected'], | ||
deselectAll: false | ||
}; | ||
const { deselectedElementsIDs } = expected; | ||
(0, chai_1.expect)(element_selection_1.SelectAction.removeSelection(deselectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('setSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: true | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
(0, chai_1.expect)(element_selection_1.SelectAction.setSelection(selectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
@@ -66,0 +114,0 @@ describe('SelectAllAction', () => { |
@@ -0,1 +1,17 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020-2023 EclipseSource 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 | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { Operation, RequestAction, ResponseAction } from './base-protocol'; | ||
@@ -25,3 +41,3 @@ import { Args } from './types'; | ||
const KIND = "requestEditValidation"; | ||
function is(object: any): object is RequestEditValidationAction; | ||
function is(object: unknown): object is RequestEditValidationAction; | ||
function create(options: { | ||
@@ -46,3 +62,3 @@ contextId: string; | ||
const KIND = "setEditValidationResult"; | ||
function is(object: any): object is SetEditValidationResultAction; | ||
function is(object: unknown): object is SetEditValidationResultAction; | ||
function create(status: ValidationStatus, options?: { | ||
@@ -60,3 +76,3 @@ args?: Args; | ||
*/ | ||
export interface ApplyLabelEditOperation extends Operation { | ||
export interface ApplyLabelEditOperation extends Operation, sprotty.ApplyLabelEditAction { | ||
kind: typeof ApplyLabelEditOperation.KIND; | ||
@@ -74,3 +90,3 @@ /** | ||
const KIND = "applyLabelEdit"; | ||
function is(object: any): object is ApplyLabelEditOperation; | ||
function is(object: unknown): object is ApplyLabelEditOperation; | ||
function create(options: { | ||
@@ -153,4 +169,4 @@ labelId: string; | ||
*/ | ||
readonly data: Record<string, any>; | ||
readonly data: Record<string, unknown>; | ||
} | ||
//# sourceMappingURL=element-text-editing.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ValidationStatus = exports.ApplyLabelEditOperation = exports.SetEditValidationResultAction = exports.RequestEditValidationAction = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource 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 | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
const type_util_1 = require("../utils/type-util"); | ||
@@ -35,3 +20,3 @@ const base_protocol_1 = require("./base-protocol"); | ||
RequestEditValidationAction.create = create; | ||
})(RequestEditValidationAction = exports.RequestEditValidationAction || (exports.RequestEditValidationAction = {})); | ||
})(RequestEditValidationAction || (exports.RequestEditValidationAction = RequestEditValidationAction = {})); | ||
var SetEditValidationResultAction; | ||
@@ -48,3 +33,3 @@ (function (SetEditValidationResultAction) { | ||
SetEditValidationResultAction.create = create; | ||
})(SetEditValidationResultAction = exports.SetEditValidationResultAction || (exports.SetEditValidationResultAction = {})); | ||
})(SetEditValidationResultAction || (exports.SetEditValidationResultAction = SetEditValidationResultAction = {})); | ||
var ApplyLabelEditOperation; | ||
@@ -61,3 +46,3 @@ (function (ApplyLabelEditOperation) { | ||
ApplyLabelEditOperation.create = create; | ||
})(ApplyLabelEditOperation = exports.ApplyLabelEditOperation || (exports.ApplyLabelEditOperation = {})); | ||
})(ApplyLabelEditOperation || (exports.ApplyLabelEditOperation = ApplyLabelEditOperation = {})); | ||
var ValidationStatus; | ||
@@ -68,3 +53,2 @@ (function (ValidationStatus) { | ||
*/ | ||
// eslint-disable-next-line no-shadow | ||
let Severity; | ||
@@ -77,3 +61,2 @@ (function (Severity) { | ||
Severity[Severity["OK"] = 4] = "OK"; | ||
// eslint-disable-next-line no-shadow | ||
Severity[Severity["NONE"] = 5] = "NONE"; | ||
@@ -121,3 +104,3 @@ })(Severity = ValidationStatus.Severity || (ValidationStatus.Severity = {})); | ||
ValidationStatus.isError = isError; | ||
})(ValidationStatus = exports.ValidationStatus || (exports.ValidationStatus = {})); | ||
})(ValidationStatus || (exports.ValidationStatus = ValidationStatus = {})); | ||
//# sourceMappingURL=element-text-editing.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -100,3 +100,3 @@ * This program and the accompanying materials are made available under the | ||
kind: 'setEditValidationResult', | ||
responseId: 'myRespsone', | ||
responseId: 'myResponse', | ||
args: { some: 'args' }, | ||
@@ -103,0 +103,0 @@ status: { severity: element_text_editing_1.ValidationStatus.Severity.OK } |
@@ -16,2 +16,3 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { GModelElementSchema } from '../model/model-schema'; | ||
import { RequestAction, ResponseAction } from './base-protocol'; | ||
@@ -49,3 +50,3 @@ /** | ||
/** | ||
* The types of elements that can be contained by this element (if any) | ||
* The types of elements that can be contained by this element (if unknown) | ||
*/ | ||
@@ -59,13 +60,24 @@ readonly containableElementTypeIds?: string[]; | ||
/** | ||
* Specifies whether the routing of this element can be changed. | ||
* Specifies whether the routing points of the edge can be changed | ||
* i.e. edited by the user. | ||
*/ | ||
readonly routable: boolean; | ||
/** | ||
* Allowed source element types for this edge type | ||
* Allowed source element types for this edge type. | ||
* If not defined unknown element can be used as source element for this edge. | ||
*/ | ||
readonly sourceElementTypeIds: string[]; | ||
readonly sourceElementTypeIds?: string[]; | ||
/** | ||
* Allowed targe element types for this edge type | ||
* Allowed target element types for this edge type | ||
* If not defined unknown element can be used as target element for this edge. | ||
*/ | ||
readonly targetElementTypeIds: string[]; | ||
readonly targetElementTypeIds?: string[]; | ||
/** | ||
* Indicates whether this type hint is dynamic or not. Dynamic edge type hints | ||
* require an additional runtime check before creating an edge, when checking | ||
* source and target element types is not sufficient. | ||
* | ||
* @see {@link RequestCheckEdgeAction} | ||
*/ | ||
readonly dynamic?: boolean; | ||
} | ||
@@ -75,3 +87,3 @@ /** | ||
* The `RequestTypeHintsAction` is optional, but should usually be among the first messages sent from the client to the server after | ||
* receiving the model via RequestModelAction. The response is a {@link SetTypeHintsAction}. | ||
* receiving the model via `RequestModelAction`. The response is a {@link SetTypeHintsAction}. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
@@ -85,3 +97,3 @@ * and creating new `RequestTypeHintsActions`. | ||
const KIND = "requestTypeHints"; | ||
function is(object: any): object is RequestTypeHintsAction; | ||
function is(object: unknown): object is RequestTypeHintsAction; | ||
function create(options?: { | ||
@@ -103,3 +115,3 @@ requestId?: string; | ||
const KIND = "setTypeHints"; | ||
function is(object: any): object is SetTypeHintsAction; | ||
function is(object: unknown): object is SetTypeHintsAction; | ||
function create(options: { | ||
@@ -111,2 +123,69 @@ shapeHints: ShapeTypeHint[]; | ||
} | ||
/** | ||
* Sent from the client to the server to check wether the provided edge context information is valid i.e. | ||
* creation of an edge with the given edge type and source/target element is allowed by the server. | ||
* Typically this action is dispatched by edge creation tools in the creation phase of an edge that's associated | ||
* with a dynamic {@link EdgeTypeHint}. | ||
*/ | ||
export interface RequestCheckEdgeAction extends RequestAction<CheckEdgeResultAction> { | ||
kind: typeof RequestCheckEdgeAction.KIND; | ||
/** | ||
* The element type of the edge being created. | ||
*/ | ||
edgeType: string; | ||
/** | ||
* The ID of the edge source element. | ||
*/ | ||
sourceElementId: string; | ||
/** | ||
* The ID of the edge target element to check. | ||
*/ | ||
targetElementId?: string; | ||
} | ||
export declare namespace RequestCheckEdgeAction { | ||
const KIND = "requestCheckEdge"; | ||
function is(object: unknown): object is RequestCheckEdgeAction; | ||
function create(options: { | ||
sourceElement: GModelElementSchema | string; | ||
targetElement?: GModelElementSchema | string; | ||
edgeType: string; | ||
requestId?: string; | ||
}): RequestCheckEdgeAction; | ||
} | ||
/** | ||
* Send from the server to the client as a response for a {@link RequestCheckEdgeAction}. It provides | ||
* a boolean indicating whether the edge context information provided by the corresponding request action is valid | ||
* i.e. creation of an edge with the given edge type and source/target element is allowed. | ||
*/ | ||
export interface CheckEdgeResultAction extends ResponseAction { | ||
kind: typeof CheckEdgeResultAction.KIND; | ||
/** | ||
* true if the selected element is a valid target for this edge, | ||
* false otherwise. | ||
*/ | ||
isValid: boolean; | ||
/** | ||
* The element type of the edge that has been checked. | ||
*/ | ||
edgeType: string; | ||
/** | ||
* The ID of the source element of the edge that has been checked. | ||
*/ | ||
sourceElementId: string; | ||
/** | ||
* The ID of the target element of the edge that has been checked. | ||
*/ | ||
targetElementId?: string; | ||
} | ||
export declare namespace CheckEdgeResultAction { | ||
const KIND = "checkEdgeTargetResult"; | ||
function is(object: unknown): object is CheckEdgeResultAction; | ||
function create(options: { | ||
isValid: boolean; | ||
edgeType: string; | ||
sourceElementId: string; | ||
targetElementId?: string; | ||
responseId?: string; | ||
}): CheckEdgeResultAction; | ||
} | ||
//# sourceMappingURL=element-type-hints.d.ts.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SetTypeHintsAction = exports.RequestTypeHintsAction = void 0; | ||
exports.CheckEdgeResultAction = exports.RequestCheckEdgeAction = exports.SetTypeHintsAction = exports.RequestTypeHintsAction = void 0; | ||
const type_util_1 = require("../utils/type-util"); | ||
@@ -33,3 +33,3 @@ const base_protocol_1 = require("./base-protocol"); | ||
RequestTypeHintsAction.create = create; | ||
})(RequestTypeHintsAction = exports.RequestTypeHintsAction || (exports.RequestTypeHintsAction = {})); | ||
})(RequestTypeHintsAction || (exports.RequestTypeHintsAction = RequestTypeHintsAction = {})); | ||
var SetTypeHintsAction; | ||
@@ -46,3 +46,47 @@ (function (SetTypeHintsAction) { | ||
SetTypeHintsAction.create = create; | ||
})(SetTypeHintsAction = exports.SetTypeHintsAction || (exports.SetTypeHintsAction = {})); | ||
})(SetTypeHintsAction || (exports.SetTypeHintsAction = SetTypeHintsAction = {})); | ||
var RequestCheckEdgeAction; | ||
(function (RequestCheckEdgeAction) { | ||
RequestCheckEdgeAction.KIND = 'requestCheckEdge'; | ||
function is(object) { | ||
return (base_protocol_1.Action.hasKind(object, RequestCheckEdgeAction.KIND) && | ||
(0, type_util_1.hasStringProp)(object, 'edgeType') && | ||
(0, type_util_1.hasStringProp)(object, 'sourceElementId') && | ||
(0, type_util_1.hasStringProp)(object, 'targetElementId', true)); | ||
} | ||
RequestCheckEdgeAction.is = is; | ||
function create(options) { | ||
var _a; | ||
return { | ||
kind: RequestCheckEdgeAction.KIND, | ||
edgeType: options.edgeType, | ||
sourceElementId: getElementTypeId(options.sourceElement), | ||
targetElementId: options.targetElement ? getElementTypeId(options.targetElement) : undefined, | ||
requestId: (_a = options.requestId) !== null && _a !== void 0 ? _a : '' | ||
}; | ||
} | ||
RequestCheckEdgeAction.create = create; | ||
})(RequestCheckEdgeAction || (exports.RequestCheckEdgeAction = RequestCheckEdgeAction = {})); | ||
function getElementTypeId(element) { | ||
if (typeof element === 'string') { | ||
return element; | ||
} | ||
return element.id; | ||
} | ||
var CheckEdgeResultAction; | ||
(function (CheckEdgeResultAction) { | ||
CheckEdgeResultAction.KIND = 'checkEdgeTargetResult'; | ||
function is(object) { | ||
return (base_protocol_1.Action.hasKind(object, CheckEdgeResultAction.KIND) && | ||
(0, type_util_1.hasBooleanProp)(object, 'isValid') && | ||
(0, type_util_1.hasStringProp)(object, 'edgeType') && | ||
(0, type_util_1.hasStringProp)(object, 'sourceElementId') && | ||
(0, type_util_1.hasStringProp)(object, 'targetElementId', true)); | ||
} | ||
CheckEdgeResultAction.is = is; | ||
function create(options) { | ||
return Object.assign({ kind: CheckEdgeResultAction.KIND, responseId: '' }, options); | ||
} | ||
CheckEdgeResultAction.create = create; | ||
})(CheckEdgeResultAction || (exports.CheckEdgeResultAction = CheckEdgeResultAction = {})); | ||
//# sourceMappingURL=element-type-hints.js.map |
@@ -137,3 +137,119 @@ "use strict"; | ||
}); | ||
describe('RequestCheckEdgeAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
requestId: '' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.RequestCheckEdgeAction.is(action)).to.be.true; | ||
}); | ||
it('should return true for an object having the correct type and a value for all required interface & optional properties', () => { | ||
const action = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
requestId: '' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.RequestCheckEdgeAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(element_type_hints_1.RequestCheckEdgeAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(element_type_hints_1.RequestCheckEdgeAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const expected = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
requestId: '', | ||
targetElementId: undefined | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.RequestCheckEdgeAction.create({ edgeType: 'edge', sourceElement: 'source' })).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
requestId: 'myRequest' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.RequestCheckEdgeAction.create({ | ||
edgeType: 'edge', | ||
sourceElement: 'source', | ||
targetElement: 'target', | ||
requestId: 'myRequest' | ||
})).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('CheckEdgeResultAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
responseId: '' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.CheckEdgeResultAction.is(action)).to.be.true; | ||
}); | ||
it('should return true for an object having the correct type and a value for all required interface & optional properties', () => { | ||
const action = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
responseId: 'myResponse' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.CheckEdgeResultAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(element_type_hints_1.CheckEdgeResultAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(element_type_hints_1.CheckEdgeResultAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const expected = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
responseId: '' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.CheckEdgeResultAction.create({ edgeType: 'edge', isValid: true, sourceElementId: 'source' })).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
responseId: 'myResponse' | ||
}; | ||
(0, chai_1.expect)(element_type_hints_1.CheckEdgeResultAction.create({ | ||
edgeType: 'edge', | ||
isValid: true, | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
responseId: 'myResponse' | ||
})).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=element-type-hints.spec.js.map |
@@ -32,2 +32,11 @@ import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
/** | ||
* The default reasons for markers. | ||
*/ | ||
export declare namespace MarkersReason { | ||
/** Markers resulting from a batch validation */ | ||
const BATCH = "batch"; | ||
/** Markers resulting from a live validation */ | ||
const LIVE = "live"; | ||
} | ||
/** | ||
* Action to retrieve markers for the specified model elements. Sent from the client to the server. | ||
@@ -43,8 +52,13 @@ * The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
elementsIDs: string[]; | ||
/** | ||
* The reason for this request, such as `batch` or `live` validation. `batch` by default. | ||
*/ | ||
reason?: string; | ||
} | ||
export declare namespace RequestMarkersAction { | ||
const KIND = "requestMarkers"; | ||
function is(object: any): object is RequestMarkersAction; | ||
function is(object: unknown): object is RequestMarkersAction; | ||
function create(elementsIDs: string[], options?: { | ||
requestId?: string; | ||
reason?: string; | ||
}): RequestMarkersAction; | ||
@@ -55,3 +69,3 @@ } | ||
* Typically, this is a response to the {@link RequestMarkersAction} containing all validation markers, but can be sent by the server at | ||
* any time. | ||
* unknown time. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
@@ -66,8 +80,13 @@ * and creating new `SetMarkersActions`. | ||
readonly markers: Marker[]; | ||
/** | ||
* The reason for message, such as `batch` or `live` validation. | ||
*/ | ||
reason?: string; | ||
} | ||
export declare namespace SetMarkersAction { | ||
const KIND = "setMarkers"; | ||
function is(object: any): object is SetMarkersAction; | ||
function is(object: unknown): object is SetMarkersAction; | ||
function create(markers: Marker[], options?: { | ||
responseId?: string; | ||
reason?: string; | ||
}): SetMarkersAction; | ||
@@ -89,5 +108,5 @@ } | ||
const KIND = "deleteMarkers"; | ||
function is(object: any): object is DeleteMarkersAction; | ||
function is(object: unknown): object is DeleteMarkersAction; | ||
function create(markers: Marker[]): DeleteMarkersAction; | ||
} | ||
//# sourceMappingURL=element-validation.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DeleteMarkersAction = exports.SetMarkersAction = exports.RequestMarkersAction = exports.MarkerKind = void 0; | ||
exports.DeleteMarkersAction = exports.SetMarkersAction = exports.RequestMarkersAction = exports.MarkersReason = exports.MarkerKind = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -29,3 +29,13 @@ * This program and the accompanying materials are made available under the | ||
MarkerKind.ERROR = 'error'; | ||
})(MarkerKind = exports.MarkerKind || (exports.MarkerKind = {})); | ||
})(MarkerKind || (exports.MarkerKind = MarkerKind = {})); | ||
/** | ||
* The default reasons for markers. | ||
*/ | ||
var MarkersReason; | ||
(function (MarkersReason) { | ||
/** Markers resulting from a batch validation */ | ||
MarkersReason.BATCH = 'batch'; | ||
/** Markers resulting from a live validation */ | ||
MarkersReason.LIVE = 'live'; | ||
})(MarkersReason || (exports.MarkersReason = MarkersReason = {})); | ||
var RequestMarkersAction; | ||
@@ -39,6 +49,6 @@ (function (RequestMarkersAction) { | ||
function create(elementsIDs, options = {}) { | ||
return Object.assign({ kind: RequestMarkersAction.KIND, requestId: '', elementsIDs }, options); | ||
return Object.assign({ kind: RequestMarkersAction.KIND, requestId: '', elementsIDs, reason: MarkersReason.BATCH }, options); | ||
} | ||
RequestMarkersAction.create = create; | ||
})(RequestMarkersAction = exports.RequestMarkersAction || (exports.RequestMarkersAction = {})); | ||
})(RequestMarkersAction || (exports.RequestMarkersAction = RequestMarkersAction = {})); | ||
var SetMarkersAction; | ||
@@ -52,6 +62,6 @@ (function (SetMarkersAction) { | ||
function create(markers, options = {}) { | ||
return Object.assign({ kind: SetMarkersAction.KIND, responseId: '', markers }, options); | ||
return Object.assign({ kind: SetMarkersAction.KIND, responseId: '', markers, reason: MarkersReason.BATCH }, options); | ||
} | ||
SetMarkersAction.create = create; | ||
})(SetMarkersAction = exports.SetMarkersAction || (exports.SetMarkersAction = {})); | ||
})(SetMarkersAction || (exports.SetMarkersAction = SetMarkersAction = {})); | ||
var DeleteMarkersAction; | ||
@@ -71,3 +81,3 @@ (function (DeleteMarkersAction) { | ||
DeleteMarkersAction.create = create; | ||
})(DeleteMarkersAction = exports.DeleteMarkersAction || (exports.DeleteMarkersAction = {})); | ||
})(DeleteMarkersAction || (exports.DeleteMarkersAction = DeleteMarkersAction = {})); | ||
//# sourceMappingURL=element-validation.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -48,3 +48,4 @@ * This program and the accompanying materials are made available under the | ||
requestId: '', | ||
elementsIDs: ['myIds'] | ||
elementsIDs: ['myIds'], | ||
reason: 'batch' | ||
}; | ||
@@ -58,3 +59,4 @@ const { elementsIDs } = expected; | ||
requestId: 'myRequest', | ||
elementsIDs: ['myIds'] | ||
elementsIDs: ['myIds'], | ||
reason: 'batch' | ||
}; | ||
@@ -88,2 +90,3 @@ const { elementsIDs, requestId } = expected; | ||
responseId: '', | ||
reason: 'batch', | ||
markers: [{ description: 'desc', elementId: 'myId', kind: 'info', label: 'string' }] | ||
@@ -98,2 +101,3 @@ }; | ||
responseId: 'myResponse', | ||
reason: 'batch', | ||
markers: [{ description: 'desc', elementId: 'myId', kind: 'info', label: 'string' }] | ||
@@ -100,0 +104,0 @@ }; |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -32,3 +32,2 @@ * This program and the accompanying materials are made available under the | ||
export * from './model-saving'; | ||
export * from './model-structure'; | ||
export * from './node-modification'; | ||
@@ -35,0 +34,0 @@ export * from './tool-palette'; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -14,3 +18,3 @@ if (k2 === undefined) k2 = k; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -45,3 +49,2 @@ * This program and the accompanying materials are made available under the | ||
__exportStar(require("./model-saving"), exports); | ||
__exportStar(require("./model-structure"), exports); | ||
__exportStar(require("./node-modification"), exports); | ||
@@ -48,0 +51,0 @@ __exportStar(require("./tool-palette"), exports); |
@@ -17,4 +17,4 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '../model/model-schema'; | ||
import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
import { SModelRootSchema } from './model-structure'; | ||
import { Args } from './types'; | ||
@@ -35,3 +35,3 @@ /** | ||
const KIND = "requestModel"; | ||
function is(object: any): object is RequestModelAction; | ||
function is(object: unknown): object is RequestModelAction; | ||
function create(options?: { | ||
@@ -52,8 +52,8 @@ options?: Args; | ||
*/ | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
} | ||
export declare namespace SetModelAction { | ||
const KIND = "setModel"; | ||
function is(object: any): object is SetModelAction; | ||
function create(newRoot: SModelRootSchema, options?: { | ||
function is(object: unknown): object is SetModelAction; | ||
function create(newRoot: GModelRootSchema, options?: { | ||
responseId?: string; | ||
@@ -70,3 +70,3 @@ }): SetModelAction; | ||
kind: typeof UpdateModelAction.KIND; | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
/** | ||
@@ -79,4 +79,4 @@ * Boolean flag to indicate wether updated/changed elements should be animated in the diagram. | ||
const KIND = "updateModel"; | ||
function is(action: any): action is UpdateModelAction; | ||
function create(newRoot: SModelRootSchema, options?: { | ||
function is(action: unknown): action is UpdateModelAction; | ||
function create(newRoot: GModelRootSchema, options?: { | ||
animate?: boolean; | ||
@@ -100,5 +100,5 @@ }): UpdateModelAction; | ||
const KIND = "sourceModelChanged"; | ||
function is(object: any): object is SourceModelChangedAction; | ||
function is(object: unknown): object is SourceModelChangedAction; | ||
function create(sourceModelName: string): SourceModelChangedAction; | ||
} | ||
//# sourceMappingURL=model-data.d.ts.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
RequestModelAction.create = create; | ||
})(RequestModelAction = exports.RequestModelAction || (exports.RequestModelAction = {})); | ||
})(RequestModelAction || (exports.RequestModelAction = RequestModelAction = {})); | ||
var SetModelAction; | ||
@@ -30,3 +30,3 @@ (function (SetModelAction) { | ||
SetModelAction.create = create; | ||
})(SetModelAction = exports.SetModelAction || (exports.SetModelAction = {})); | ||
})(SetModelAction || (exports.SetModelAction = SetModelAction = {})); | ||
var UpdateModelAction; | ||
@@ -43,3 +43,3 @@ (function (UpdateModelAction) { | ||
UpdateModelAction.create = create; | ||
})(UpdateModelAction = exports.UpdateModelAction || (exports.UpdateModelAction = {})); | ||
})(UpdateModelAction || (exports.UpdateModelAction = UpdateModelAction = {})); | ||
var SourceModelChangedAction; | ||
@@ -59,3 +59,3 @@ (function (SourceModelChangedAction) { | ||
SourceModelChangedAction.create = create; | ||
})(SourceModelChangedAction = exports.SourceModelChangedAction || (exports.SourceModelChangedAction = {})); | ||
})(SourceModelChangedAction || (exports.SourceModelChangedAction = SourceModelChangedAction = {})); | ||
//# sourceMappingURL=model-data.js.map |
@@ -17,3 +17,3 @@ import { Action } from './base-protocol'; | ||
const KIND = "setEditMode"; | ||
function is(object: any): object is SetEditModeAction; | ||
function is(object: unknown): object is SetEditModeAction; | ||
function create(editMode: string): SetEditModeAction; | ||
@@ -20,0 +20,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
SetEditModeAction.create = create; | ||
})(SetEditModeAction = exports.SetEditModeAction || (exports.SetEditModeAction = {})); | ||
})(SetEditModeAction || (exports.SetEditModeAction = SetEditModeAction = {})); | ||
/** | ||
@@ -44,3 +44,3 @@ * The potential default values for the `editMode` property of a {@link SetEditModeAction}. | ||
EditMode.EDITABLE = 'editable'; | ||
})(EditMode = exports.EditMode || (exports.EditMode = {})); | ||
})(EditMode || (exports.EditMode = EditMode = {})); | ||
//# sourceMappingURL=model-edit-mode.js.map |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -17,5 +17,5 @@ * This program and the accompanying materials are made available under the | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '..'; | ||
import { Operation, RequestAction, ResponseAction } from './base-protocol'; | ||
import { SModelRootSchema } from './model-structure'; | ||
import { ElementAndAlignment, ElementAndBounds } from './types'; | ||
import { ElementAndAlignment, ElementAndBounds, ElementAndRoutingPoints } from './types'; | ||
/** | ||
@@ -28,3 +28,3 @@ * Sent from the server to the client to request bounds for the given model. The model is rendered invisibly so the bounds can | ||
*/ | ||
export interface RequestBoundsAction extends RequestAction<ComputedBoundsAction>, sprotty.RequestBoundsAction { | ||
export interface RequestBoundsAction extends RequestAction<ComputedBoundsAction>, Omit<sprotty.RequestBoundsAction, '_'> { | ||
kind: typeof RequestBoundsAction.KIND; | ||
@@ -34,8 +34,8 @@ /** | ||
*/ | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
} | ||
export declare namespace RequestBoundsAction { | ||
const KIND = "requestBounds"; | ||
function is(object: any): object is RequestBoundsAction; | ||
function create(newRoot: SModelRootSchema, options?: { | ||
function is(object: unknown): object is RequestBoundsAction; | ||
function create(newRoot: GModelRootSchema, options?: { | ||
requestId?: string; | ||
@@ -61,6 +61,10 @@ }): RequestBoundsAction; | ||
alignments?: ElementAndAlignment[]; | ||
/** | ||
* The route of the model elements. | ||
*/ | ||
routes?: ElementAndRoutingPoints[]; | ||
} | ||
export declare namespace ComputedBoundsAction { | ||
const KIND = "computedBounds"; | ||
function is(object: any): object is ComputedBoundsAction; | ||
function is(object: unknown): object is ComputedBoundsAction; | ||
function create(bounds: ElementAndBounds[], options?: { | ||
@@ -70,2 +74,3 @@ revision?: number; | ||
alignments?: ElementAndAlignment[]; | ||
routes?: ElementAndRoutingPoints[]; | ||
}): ComputedBoundsAction; | ||
@@ -81,11 +86,11 @@ } | ||
/** | ||
* The identifiers of the elements that should be layouted, may be just the root element. | ||
* The identifiers of the elements that should be layouted, will default to the root element if not defined. | ||
*/ | ||
elementIds: string[]; | ||
elementIds?: string[]; | ||
} | ||
export declare namespace LayoutOperation { | ||
const KIND = "layout"; | ||
function is(object: any): object is LayoutOperation; | ||
function create(elementIds: string[]): LayoutOperation; | ||
function is(object: unknown): object is LayoutOperation; | ||
function create(elementIds?: string[]): LayoutOperation; | ||
} | ||
//# sourceMappingURL=model-layout.d.ts.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
RequestBoundsAction.create = create; | ||
})(RequestBoundsAction = exports.RequestBoundsAction || (exports.RequestBoundsAction = {})); | ||
})(RequestBoundsAction || (exports.RequestBoundsAction = RequestBoundsAction = {})); | ||
var ComputedBoundsAction; | ||
@@ -30,3 +30,3 @@ (function (ComputedBoundsAction) { | ||
ComputedBoundsAction.create = create; | ||
})(ComputedBoundsAction = exports.ComputedBoundsAction || (exports.ComputedBoundsAction = {})); | ||
})(ComputedBoundsAction || (exports.ComputedBoundsAction = ComputedBoundsAction = {})); | ||
var LayoutOperation; | ||
@@ -47,3 +47,3 @@ (function (LayoutOperation) { | ||
LayoutOperation.create = create; | ||
})(LayoutOperation = exports.LayoutOperation || (exports.LayoutOperation = {})); | ||
})(LayoutOperation || (exports.LayoutOperation = LayoutOperation = {})); | ||
//# sourceMappingURL=model-layout.js.map |
@@ -98,6 +98,7 @@ "use strict"; | ||
revision: 5, | ||
bounds: [{ elementId: '', newSize: sprotty_protocol_1.Dimension.EMPTY, newPosition: sprotty_protocol_1.Point.ORIGIN }] | ||
bounds: [{ elementId: '', newSize: sprotty_protocol_1.Dimension.EMPTY, newPosition: sprotty_protocol_1.Point.ORIGIN }], | ||
routes: [{ elementId: 'myEdge', newRoutingPoints: [{ x: 42, y: 1337 }] }] | ||
}; | ||
const { bounds, responseId, alignments, revision } = expected; | ||
(0, chai_1.expect)(model_layout_1.ComputedBoundsAction.create(bounds, { responseId, alignments, revision })).to.deep.equals(expected); | ||
const { bounds, responseId, alignments, revision, routes } = expected; | ||
(0, chai_1.expect)(model_layout_1.ComputedBoundsAction.create(bounds, { responseId, alignments, revision, routes })).to.deep.equals(expected); | ||
}); | ||
@@ -104,0 +105,0 @@ }); |
@@ -17,3 +17,3 @@ import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
const KIND = "saveModel"; | ||
function is(object: any): object is SaveModelAction; | ||
function is(object: unknown): object is SaveModelAction; | ||
function create(options?: { | ||
@@ -40,6 +40,6 @@ fileUri?: string; | ||
} | ||
export declare type DirtyStateChangeReason = 'operation' | 'undo' | 'redo' | 'save' | 'external'; | ||
export type DirtyStateChangeReason = 'operation' | 'undo' | 'redo' | 'save' | 'external'; | ||
export declare namespace SetDirtyStateAction { | ||
const KIND = "setDirtyState"; | ||
function is(object: any): object is SetDirtyStateAction; | ||
function is(object: unknown): object is SetDirtyStateAction; | ||
function create(isDirty: boolean, options?: { | ||
@@ -59,3 +59,3 @@ reason?: DirtyStateChangeReason; | ||
const KIND = "requestExportSvg"; | ||
function is(object: any): object is RequestExportSvgAction; | ||
function is(object: unknown): object is RequestExportSvgAction; | ||
function create(options?: { | ||
@@ -79,3 +79,3 @@ requestId?: string; | ||
const KIND = "exportSvg"; | ||
function is(object: any): object is RequestExportSvgAction; | ||
function is(object: unknown): object is ExportSvgAction; | ||
function create(svg: string, options?: { | ||
@@ -82,0 +82,0 @@ responseId?: string; |
@@ -32,3 +32,3 @@ "use strict"; | ||
SaveModelAction.create = create; | ||
})(SaveModelAction = exports.SaveModelAction || (exports.SaveModelAction = {})); | ||
})(SaveModelAction || (exports.SaveModelAction = SaveModelAction = {})); | ||
var SetDirtyStateAction; | ||
@@ -45,3 +45,3 @@ (function (SetDirtyStateAction) { | ||
SetDirtyStateAction.create = create; | ||
})(SetDirtyStateAction = exports.SetDirtyStateAction || (exports.SetDirtyStateAction = {})); | ||
})(SetDirtyStateAction || (exports.SetDirtyStateAction = SetDirtyStateAction = {})); | ||
var RequestExportSvgAction; | ||
@@ -58,3 +58,3 @@ (function (RequestExportSvgAction) { | ||
RequestExportSvgAction.create = create; | ||
})(RequestExportSvgAction = exports.RequestExportSvgAction || (exports.RequestExportSvgAction = {})); | ||
})(RequestExportSvgAction || (exports.RequestExportSvgAction = RequestExportSvgAction = {})); | ||
var ExportSvgAction; | ||
@@ -71,3 +71,3 @@ (function (ExportSvgAction) { | ||
ExportSvgAction.create = create; | ||
})(ExportSvgAction = exports.ExportSvgAction || (exports.ExportSvgAction = {})); | ||
})(ExportSvgAction || (exports.ExportSvgAction = ExportSvgAction = {})); | ||
//# sourceMappingURL=model-saving.js.map |
@@ -32,3 +32,3 @@ /******************************************************************************** | ||
const KIND = "changeBounds"; | ||
function is(object: any): object is ChangeBoundsOperation; | ||
function is(object: unknown): object is ChangeBoundsOperation; | ||
function create(newBounds: ElementAndBounds[]): ChangeBoundsOperation; | ||
@@ -59,3 +59,3 @@ } | ||
const KIND = "changeContainer"; | ||
function is(object: any): object is ChangeContainerOperation; | ||
function is(object: unknown): object is ChangeContainerOperation; | ||
function create(options: { | ||
@@ -62,0 +62,0 @@ elementId: string; |
@@ -36,3 +36,3 @@ "use strict"; | ||
ChangeBoundsOperation.create = create; | ||
})(ChangeBoundsOperation = exports.ChangeBoundsOperation || (exports.ChangeBoundsOperation = {})); | ||
})(ChangeBoundsOperation || (exports.ChangeBoundsOperation = ChangeBoundsOperation = {})); | ||
var ChangeContainerOperation; | ||
@@ -49,3 +49,3 @@ (function (ChangeContainerOperation) { | ||
ChangeContainerOperation.create = create; | ||
})(ChangeContainerOperation = exports.ChangeContainerOperation || (exports.ChangeContainerOperation = {})); | ||
})(ChangeContainerOperation || (exports.ChangeContainerOperation = ChangeContainerOperation = {})); | ||
//# sourceMappingURL=node-modification.js.map |
@@ -23,3 +23,3 @@ "use strict"; | ||
/** | ||
* The schema of an SModelElement describes its serializable form. The actual class-based model is derived | ||
* The schema of an GModelElement describes its serializable form. The actual class-based model is derived | ||
* its schema whenever the client or server deserializes a received schema`. | ||
@@ -26,0 +26,0 @@ * Each model element must have a unique ID and a type that is used on the client to look up its view. |
@@ -37,3 +37,3 @@ /******************************************************************************** | ||
const KIND = "triggerNodeCreation"; | ||
function is(object: any): object is TriggerNodeCreationAction; | ||
function is(object: unknown): object is TriggerNodeCreationAction; | ||
function create(elementTypeId: string, options?: { | ||
@@ -63,3 +63,3 @@ args?: Args; | ||
const KIND = "triggerEdgeCreation"; | ||
function is(object: any): object is TriggerEdgeCreationAction; | ||
function is(object: unknown): object is TriggerEdgeCreationAction; | ||
function create(elementTypeId: string, options?: { | ||
@@ -66,0 +66,0 @@ args?: Args; |
@@ -32,3 +32,3 @@ "use strict"; | ||
TriggerNodeCreationAction.create = create; | ||
})(TriggerNodeCreationAction = exports.TriggerNodeCreationAction || (exports.TriggerNodeCreationAction = {})); | ||
})(TriggerNodeCreationAction || (exports.TriggerNodeCreationAction = TriggerNodeCreationAction = {})); | ||
var TriggerEdgeCreationAction; | ||
@@ -45,3 +45,3 @@ (function (TriggerEdgeCreationAction) { | ||
TriggerEdgeCreationAction.create = create; | ||
})(TriggerEdgeCreationAction = exports.TriggerEdgeCreationAction || (exports.TriggerEdgeCreationAction = {})); | ||
})(TriggerEdgeCreationAction || (exports.TriggerEdgeCreationAction = TriggerEdgeCreationAction = {})); | ||
//# sourceMappingURL=tool-palette.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -22,3 +22,3 @@ * This program and the accompanying materials are made available under the | ||
describe('Tool palette Actions', () => { | ||
describe('TrigerNodeCreationAction', () => { | ||
describe('TriggerNodeCreationAction', () => { | ||
describe('is', () => { | ||
@@ -25,0 +25,0 @@ it('should return true for an object having the correct type and a value for all required interface properties', () => { |
@@ -90,3 +90,3 @@ /******************************************************************************** | ||
export declare namespace EditorContext { | ||
function is(object: any): object is EditorContext; | ||
function is(object: unknown): object is EditorContext; | ||
} | ||
@@ -113,3 +113,3 @@ /** | ||
export declare namespace LabeledAction { | ||
function is(object: any): object is LabeledAction; | ||
function is(object: unknown): object is LabeledAction; | ||
function toActionArray(input: LabeledAction | Action[] | Action): Action[]; | ||
@@ -130,6 +130,6 @@ } | ||
export declare namespace PaletteItem { | ||
function is(object: any): object is PaletteItem; | ||
function is(object: unknown): object is PaletteItem; | ||
function getTriggerAction(item?: PaletteItem): TriggerElementCreationAction | undefined; | ||
type TriggerElementCreationAction = TriggerEdgeCreationAction | TriggerNodeCreationAction; | ||
function isTriggerElementCreationAction(object: any): object is TriggerElementCreationAction; | ||
function isTriggerElementCreationAction(object: unknown): object is TriggerElementCreationAction; | ||
} | ||
@@ -162,4 +162,4 @@ /** | ||
export declare namespace MenuItem { | ||
function is(object: any): object is MenuItem; | ||
function is(object: unknown): object is MenuItem; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -9,6 +9,6 @@ "use strict"; | ||
function is(object) { | ||
return object !== undefined && (0, type_util_1.hasArrayProp)(object, 'selectedElementIds'); | ||
return type_util_1.AnyObject.is(object) && (0, type_util_1.hasArrayProp)(object, 'selectedElementIds'); | ||
} | ||
EditorContext.is = is; | ||
})(EditorContext = exports.EditorContext || (exports.EditorContext = {})); | ||
})(EditorContext || (exports.EditorContext = EditorContext = {})); | ||
var LabeledAction; | ||
@@ -30,3 +30,3 @@ (function (LabeledAction) { | ||
LabeledAction.toActionArray = toActionArray; | ||
})(LabeledAction = exports.LabeledAction || (exports.LabeledAction = {})); | ||
})(LabeledAction || (exports.LabeledAction = LabeledAction = {})); | ||
var PaletteItem; | ||
@@ -52,3 +52,3 @@ (function (PaletteItem) { | ||
PaletteItem.isTriggerElementCreationAction = isTriggerElementCreationAction; | ||
})(PaletteItem = exports.PaletteItem || (exports.PaletteItem = {})); | ||
})(PaletteItem || (exports.PaletteItem = PaletteItem = {})); | ||
var MenuItem; | ||
@@ -60,3 +60,3 @@ (function (MenuItem) { | ||
MenuItem.is = is; | ||
})(MenuItem = exports.MenuItem || (exports.MenuItem = {})); | ||
})(MenuItem || (exports.MenuItem = MenuItem = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -16,15 +16,15 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Operation } from './base-protocol'; | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
/** | ||
* Trigger an undo of the latest executed command. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `UndoOperations`. | ||
* and creating new `UndoAction`. | ||
*/ | ||
export interface UndoOperation extends Operation { | ||
kind: typeof UndoOperation.KIND; | ||
export interface UndoAction extends Omit<sprotty.UndoAction, 'kind'> { | ||
kind: typeof UndoAction.KIND; | ||
} | ||
export declare namespace UndoOperation { | ||
export declare namespace UndoAction { | ||
const KIND = "glspUndo"; | ||
function is(object: any): object is UndoOperation; | ||
function create(): UndoOperation; | ||
function is(object: unknown): object is UndoAction; | ||
function create(): UndoAction; | ||
} | ||
@@ -34,12 +34,12 @@ /** | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `RedoOperations`. | ||
* and creating new `RedoAction`. | ||
*/ | ||
export interface RedoOperation extends Operation { | ||
kind: typeof RedoOperation.KIND; | ||
export interface RedoAction extends Omit<sprotty.RedoAction, 'kind'> { | ||
kind: typeof RedoAction.KIND; | ||
} | ||
export declare namespace RedoOperation { | ||
export declare namespace RedoAction { | ||
const KIND = "glspRedo"; | ||
function is(object: any): object is RedoOperation; | ||
function create(): RedoOperation; | ||
function is(object: unknown): object is RedoAction; | ||
function create(): RedoAction; | ||
} | ||
//# sourceMappingURL=undo-redo.d.ts.map |
@@ -18,34 +18,32 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RedoOperation = exports.UndoOperation = void 0; | ||
exports.RedoAction = exports.UndoAction = void 0; | ||
const base_protocol_1 = require("./base-protocol"); | ||
var UndoOperation; | ||
(function (UndoOperation) { | ||
UndoOperation.KIND = 'glspUndo'; | ||
var UndoAction; | ||
(function (UndoAction) { | ||
UndoAction.KIND = 'glspUndo'; | ||
function is(object) { | ||
return base_protocol_1.Operation.hasKind(object, UndoOperation.KIND); | ||
return base_protocol_1.Action.hasKind(object, UndoAction.KIND); | ||
} | ||
UndoOperation.is = is; | ||
UndoAction.is = is; | ||
function create() { | ||
return { | ||
kind: UndoOperation.KIND, | ||
isOperation: true | ||
kind: UndoAction.KIND | ||
}; | ||
} | ||
UndoOperation.create = create; | ||
})(UndoOperation = exports.UndoOperation || (exports.UndoOperation = {})); | ||
var RedoOperation; | ||
(function (RedoOperation) { | ||
RedoOperation.KIND = 'glspRedo'; | ||
UndoAction.create = create; | ||
})(UndoAction || (exports.UndoAction = UndoAction = {})); | ||
var RedoAction; | ||
(function (RedoAction) { | ||
RedoAction.KIND = 'glspRedo'; | ||
function is(object) { | ||
return base_protocol_1.Operation.hasKind(object, RedoOperation.KIND); | ||
return base_protocol_1.Action.hasKind(object, RedoAction.KIND); | ||
} | ||
RedoOperation.is = is; | ||
RedoAction.is = is; | ||
function create() { | ||
return { | ||
kind: RedoOperation.KIND, | ||
isOperation: true | ||
kind: RedoAction.KIND | ||
}; | ||
} | ||
RedoOperation.create = create; | ||
})(RedoOperation = exports.RedoOperation || (exports.RedoOperation = {})); | ||
RedoAction.create = create; | ||
})(RedoAction || (exports.RedoAction = RedoAction = {})); | ||
//# sourceMappingURL=undo-redo.js.map |
@@ -21,16 +21,15 @@ "use strict"; | ||
describe('Undo & Redo Actions', () => { | ||
describe('UndoOperation', () => { | ||
describe('UndoAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action = { | ||
kind: 'glspUndo', | ||
isOperation: true | ||
kind: 'glspUndo' | ||
}; | ||
(0, chai_1.expect)(undo_redo_1.UndoOperation.is(action)).to.be.true; | ||
(0, chai_1.expect)(undo_redo_1.UndoAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(undo_redo_1.UndoOperation.is(undefined)).to.be.false; | ||
(0, chai_1.expect)(undo_redo_1.UndoAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(undo_redo_1.UndoOperation.is({ kind: 'notTheRightOne' })).to.be.false; | ||
(0, chai_1.expect)(undo_redo_1.UndoAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -41,23 +40,21 @@ }); | ||
const expected = { | ||
kind: 'glspUndo', | ||
isOperation: true | ||
kind: 'glspUndo' | ||
}; | ||
(0, chai_1.expect)(undo_redo_1.UndoOperation.create()).to.deep.equals(expected); | ||
(0, chai_1.expect)(undo_redo_1.UndoAction.create()).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('RedoOperation', () => { | ||
describe('RedoAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action = { | ||
kind: 'glspRedo', | ||
isOperation: true | ||
kind: 'glspRedo' | ||
}; | ||
(0, chai_1.expect)(undo_redo_1.RedoOperation.is(action)).to.be.true; | ||
(0, chai_1.expect)(undo_redo_1.RedoAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
(0, chai_1.expect)(undo_redo_1.RedoOperation.is(undefined)).to.be.false; | ||
(0, chai_1.expect)(undo_redo_1.RedoAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
(0, chai_1.expect)(undo_redo_1.RedoOperation.is({ kind: 'notTheRightOne' })).to.be.false; | ||
(0, chai_1.expect)(undo_redo_1.RedoAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -68,6 +65,5 @@ }); | ||
const expected = { | ||
kind: 'glspRedo', | ||
isOperation: true | ||
kind: 'glspRedo' | ||
}; | ||
(0, chai_1.expect)(undo_redo_1.RedoOperation.create()).to.deep.equals(expected); | ||
(0, chai_1.expect)(undo_redo_1.RedoAction.create()).to.deep.equals(expected); | ||
}); | ||
@@ -74,0 +70,0 @@ }); |
@@ -43,3 +43,3 @@ /******************************************************************************** | ||
const KIND = "center"; | ||
function is(object: any): object is CenterAction; | ||
function is(object: unknown): object is CenterAction; | ||
function create(elementIds: string[], options?: { | ||
@@ -76,3 +76,3 @@ animate?: boolean; | ||
const KIND = "fit"; | ||
function is(object: any): object is FitToScreenAction; | ||
function is(object: unknown): object is FitToScreenAction; | ||
function create(elementIds: string[], options?: { | ||
@@ -79,0 +79,0 @@ padding?: number; |
@@ -17,3 +17,3 @@ "use strict"; | ||
CenterAction.create = create; | ||
})(CenterAction = exports.CenterAction || (exports.CenterAction = {})); | ||
})(CenterAction || (exports.CenterAction = CenterAction = {})); | ||
var FitToScreenAction; | ||
@@ -30,3 +30,3 @@ (function (FitToScreenAction) { | ||
FitToScreenAction.create = create; | ||
})(FitToScreenAction = exports.FitToScreenAction || (exports.FitToScreenAction = {})); | ||
})(FitToScreenAction || (exports.FitToScreenAction = FitToScreenAction = {})); | ||
//# sourceMappingURL=viewport.js.map |
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource and others. | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
@@ -16,11 +16,2 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
import { SetBoundsAction, SetViewportAction } from 'sprotty-protocol/lib/actions'; | ||
declare module 'sprotty-protocol/lib/actions' { | ||
namespace SetViewportAction { | ||
function is(object: any): object is SetViewportAction; | ||
} | ||
namespace SetBoundsAction { | ||
function is(object: any): object is SetBoundsAction; | ||
} | ||
} | ||
export { Viewport } from 'sprotty-protocol/lib/model'; | ||
@@ -30,12 +21,21 @@ export * from 'sprotty-protocol/lib/utils/async'; | ||
export * from 'sprotty-protocol/lib/utils/json'; | ||
export * from 'sprotty-protocol/lib/utils/model-utils'; | ||
export { applyBounds, cloneModel, findElement, getBasicType, getSubType } from 'sprotty-protocol/lib/utils/model-utils'; | ||
export * from './action-protocol'; | ||
export * from './glsp-client'; | ||
export * from './jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './jsonrpc/glsp-jsonrpc-client'; | ||
export * from './client-server-protocol/base-glsp-client'; | ||
export * from './client-server-protocol/glsp-client'; | ||
export * from './client-server-protocol/glsp-server'; | ||
export * from './client-server-protocol/jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-server'; | ||
export * from './client-server-protocol/jsonrpc/websocket-connection'; | ||
export * from './client-server-protocol/jsonrpc/ws-connection-provider'; | ||
export * from './client-server-protocol/types'; | ||
export * from './model/default-types'; | ||
export * from './model/model-schema'; | ||
export * from './sprotty-actions'; | ||
export * from './utils/array-util'; | ||
export * from './utils/di-util'; | ||
export * from './utils/disposable'; | ||
export * from './utils/event'; | ||
export * from './utils/type-util'; | ||
export { SetBoundsAction, SetViewportAction }; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SetViewportAction = exports.SetBoundsAction = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource and others. | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
@@ -29,25 +17,46 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
const actions_1 = require("sprotty-protocol/lib/actions"); | ||
Object.defineProperty(exports, "SetBoundsAction", { enumerable: true, get: function () { return actions_1.SetBoundsAction; } }); | ||
Object.defineProperty(exports, "SetViewportAction", { enumerable: true, get: function () { return actions_1.SetViewportAction; } }); | ||
const action_protocol_1 = require("./action-protocol"); | ||
const type_util_1 = require("./utils/type-util"); | ||
actions_1.SetViewportAction.is = (object) => action_protocol_1.Action.hasKind(object, actions_1.SetViewportAction.KIND) && | ||
(0, type_util_1.hasStringProp)(object, 'elementId') && | ||
(0, type_util_1.hasObjectProp)(object, 'newViewport') && | ||
(0, type_util_1.hasBooleanProp)(object, 'animate'); | ||
actions_1.SetBoundsAction.is = (object) => action_protocol_1.Action.hasKind(object, actions_1.SetBoundsAction.KIND) && (0, type_util_1.hasObjectProp)(object, 'bounds'); | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSubType = exports.getBasicType = exports.findElement = exports.cloneModel = exports.applyBounds = void 0; | ||
__exportStar(require("sprotty-protocol/lib/utils/async"), exports); | ||
__exportStar(require("sprotty-protocol/lib/utils/geometry"), exports); | ||
__exportStar(require("sprotty-protocol/lib/utils/json"), exports); | ||
__exportStar(require("sprotty-protocol/lib/utils/model-utils"), exports); | ||
var model_utils_1 = require("sprotty-protocol/lib/utils/model-utils"); | ||
Object.defineProperty(exports, "applyBounds", { enumerable: true, get: function () { return model_utils_1.applyBounds; } }); | ||
Object.defineProperty(exports, "cloneModel", { enumerable: true, get: function () { return model_utils_1.cloneModel; } }); | ||
Object.defineProperty(exports, "findElement", { enumerable: true, get: function () { return model_utils_1.findElement; } }); | ||
Object.defineProperty(exports, "getBasicType", { enumerable: true, get: function () { return model_utils_1.getBasicType; } }); | ||
Object.defineProperty(exports, "getSubType", { enumerable: true, get: function () { return model_utils_1.getSubType; } }); | ||
// Default export of @eclipse-glsp/protocol | ||
__exportStar(require("./action-protocol"), exports); | ||
__exportStar(require("./glsp-client"), exports); | ||
__exportStar(require("./jsonrpc/base-jsonrpc-glsp-client"), exports); | ||
__exportStar(require("./jsonrpc/glsp-jsonrpc-client"), exports); | ||
__exportStar(require("./client-server-protocol/base-glsp-client"), exports); | ||
__exportStar(require("./client-server-protocol/glsp-client"), exports); | ||
__exportStar(require("./client-server-protocol/glsp-server"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/base-jsonrpc-glsp-client"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/glsp-jsonrpc-client"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/glsp-jsonrpc-server"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/websocket-connection"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/ws-connection-provider"), exports); | ||
__exportStar(require("./client-server-protocol/types"), exports); | ||
__exportStar(require("./model/default-types"), exports); | ||
__exportStar(require("./model/model-schema"), exports); | ||
__exportStar(require("./sprotty-actions"), exports); | ||
__exportStar(require("./utils/array-util"), exports); | ||
__exportStar(require("./utils/di-util"), exports); | ||
__exportStar(require("./utils/disposable"), exports); | ||
__exportStar(require("./utils/event"), exports); | ||
__exportStar(require("./utils/type-util"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -32,3 +32,3 @@ /******************************************************************************** | ||
const ROUTING_POINT = "routing-point"; | ||
const VOLATILE_ROUTING_POINT: string; | ||
const VOLATILE_ROUTING_POINT = "volatile-routing-point"; | ||
const LABEL = "label"; | ||
@@ -35,0 +35,0 @@ const BUTTON = "button"; |
@@ -50,3 +50,3 @@ "use strict"; | ||
DefaultTypes.NODE_DIAMOND = 'node:diamond'; | ||
})(DefaultTypes = exports.DefaultTypes || (exports.DefaultTypes = {})); | ||
})(DefaultTypes || (exports.DefaultTypes = DefaultTypes = {})); | ||
//# sourceMappingURL=default-types.js.map |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -16,10 +16,12 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
/** | ||
* Reexport of the sprotty-protocol model definitions with a `Schema` suffix. We use a class based | ||
* model representation on client and server side. The `Schema` suffix is used for type that represent | ||
* the serializable description of these graphical model elements. | ||
* The basic types `SModelElementSchema` and `SRootElementSchema` are already exported by the base action protocol so | ||
* we only have to reexport the advanced model element interfaces from sprotty-protocol. | ||
import { SCompartment as GCompartmentSchema, SEdge as GEdgeSchema, ForeignObjectElement as GForeignObjectElementSchema, SGraph as GGraphSchema, HtmlRoot as GHtmlRootSchema, SLabel as GLabelSchema, SModelElement as GModelElementSchema, SModelRoot as GModelRootSchema, SNode as GNodeSchema, SPort as GPortSchema, PreRenderedElement as GPreRenderedElementSchema, SShapeElement as GShapeElementSchema, ShapedPreRenderedElement as GShapePreRenderedElementSchema, ViewportRootElement as GViewPortRootElementSchema } from 'sprotty-protocol/lib/model'; | ||
/** Serializable representation of GModel elements. This is the transfer format | ||
* used to exchange model information between client and server. Both the client and | ||
* server have a deserialization mechanism in place to convert a GModelElementSchema | ||
* into the corresponding class-based model (or EMF-based in case of the Java Server). | ||
* | ||
* To ensure sprotty compatibility all types are just aliases of the corresponding Sprotty SModel API element. | ||
*/ | ||
export { HtmlRoot as HtmlRootSchema, PreRenderedElement as PreRenderedElementSchema, SCompartment as SCompartmentSchema, SEdge as SEdgeSchema, SGraph as SGraphSchema, ShapedPreRenderedElement as ShapedPreRenderedElementSchema, SLabel as SLabelSchema, SNode as SNodeSchema, SPort as SPortSchema, SShapeElement as SShapeElementSchema } from 'sprotty-protocol/lib/model'; | ||
export declare function isGModelElementSchema(object: any): object is GModelElementSchema; | ||
export { GCompartmentSchema, GEdgeSchema, GForeignObjectElementSchema, GGraphSchema, GHtmlRootSchema, GLabelSchema, GModelElementSchema, GModelRootSchema, GNodeSchema, GPortSchema, GPreRenderedElementSchema, GShapeElementSchema, GShapePreRenderedElementSchema, GViewPortRootElementSchema }; | ||
//# sourceMappingURL=model-schema.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isGModelElementSchema = void 0; | ||
const type_util_1 = require("../utils/type-util"); | ||
/** Serializable representation of GModel elements. This is the transfer format | ||
* used to exchange model information between client and server. Both the client and | ||
* server have a deserialization mechanism in place to convert a GModelElementSchema | ||
* into the corresponding class-based model (or EMF-based in case of the Java Server). | ||
* | ||
* To ensure sprotty compatibility all types are just aliases of the corresponding Sprotty SModel API element. | ||
*/ | ||
function isGModelElementSchema(object) { | ||
return typeof object === 'object' && (0, type_util_1.hasStringProp)(object, 'type') && (0, type_util_1.hasStringProp)(object, 'id'); | ||
} | ||
exports.isGModelElementSchema = isGModelElementSchema; | ||
//# sourceMappingURL=model-schema.js.map |
/******************************************************************************** | ||
* Copyright (c) 2019-2022 EclipseSource and others. | ||
* Copyright (c) 2019-2023 EclipseSource and others. | ||
* | ||
@@ -20,3 +20,3 @@ * This program and the accompanying materials are made available under the | ||
*/ | ||
export declare type MaybeArray<T> = T | T[]; | ||
export type MaybeArray<T> = T | T[]; | ||
/** | ||
@@ -70,2 +70,8 @@ * Returns the first element of the given array. | ||
/** | ||
* Helper function to convert a {@link MaybeArray} into an array. | ||
* @param maybe The MaybeArray to convert | ||
* @returns The corresponding array | ||
*/ | ||
export declare function asArray<T>(maybe: MaybeArray<T>): T[]; | ||
/** | ||
* Adds the given values to the given array. The add operation is executed distinct meaning | ||
@@ -85,3 +91,3 @@ * a value will not be pushed to the array if its already present in the array. | ||
*/ | ||
export declare function isArrayOfType<T>(object: any, typeGuard: (elem: any) => elem is T, supportEmpty?: boolean): object is T[]; | ||
export declare function isArrayOfType<T>(object: unknown, typeGuard: (elem: unknown) => elem is T, supportEmpty?: boolean): object is T[]; | ||
/** | ||
@@ -95,3 +101,3 @@ * A typeguard function to check wether a given object is an array of a class`T`. As it checks the wether each individual element | ||
*/ | ||
export declare function isArrayOfClass<T>(object: any, constructor: Constructor<T>, supportEmpty?: boolean): object is T[]; | ||
export declare function isArrayOfClass<T>(object: unknown, constructor: Constructor<T>, supportEmpty?: boolean): object is T[]; | ||
/** | ||
@@ -105,3 +111,3 @@ * A typeguard function to check wether a given object is an array of a {@link PrimitiveType} `T. As it checks the type of each individual | ||
*/ | ||
export declare function isArrayOfPrimitive<T>(object: any, primitiveType: Primitive, supportEmpty?: boolean): object is T[]; | ||
export declare function isArrayOfPrimitive<T>(object: unknown, primitiveType: Primitive, supportEmpty?: boolean): object is T[]; | ||
/** | ||
@@ -114,3 +120,3 @@ * A typeguard function to check wether a given object is an array of a strings. As it checks the type of each individual | ||
*/ | ||
export declare function isStringArray(object: any, supportEmpty?: boolean): object is string[]; | ||
export declare function isStringArray(object: unknown, supportEmpty?: boolean): object is string[]; | ||
/** | ||
@@ -123,3 +129,3 @@ * A typeguard function to check wether a given object is an array where each element matches the given predicate. | ||
*/ | ||
export declare function isArrayMatching(object: any, predicate: (elem: any) => boolean, supportEmpty?: boolean): boolean; | ||
export declare function isArrayMatching(object: unknown, predicate: (elem: unknown) => boolean, supportEmpty?: boolean): boolean; | ||
//# sourceMappingURL=array-util.d.ts.map |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2019-2022 EclipseSource and others. | ||
* Copyright (c) 2019-2023 EclipseSource and others. | ||
* | ||
@@ -18,3 +18,3 @@ * This program and the accompanying materials are made available under the | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isArrayMatching = exports.isStringArray = exports.isArrayOfPrimitive = exports.isArrayOfClass = exports.isArrayOfType = exports.distinctAdd = exports.flatPush = exports.remove = exports.pluck = exports.last = exports.first = void 0; | ||
exports.isArrayMatching = exports.isStringArray = exports.isArrayOfPrimitive = exports.isArrayOfClass = exports.isArrayOfType = exports.distinctAdd = exports.asArray = exports.flatPush = exports.remove = exports.pluck = exports.last = exports.first = void 0; | ||
function first(array, n) { | ||
@@ -70,2 +70,14 @@ if (n) { | ||
/** | ||
* Helper function to convert a {@link MaybeArray} into an array. | ||
* @param maybe The MaybeArray to convert | ||
* @returns The corresponding array | ||
*/ | ||
function asArray(maybe) { | ||
if (Array.isArray(maybe)) { | ||
return maybe; | ||
} | ||
return [maybe]; | ||
} | ||
exports.asArray = asArray; | ||
/** | ||
* Adds the given values to the given array. The add operation is executed distinct meaning | ||
@@ -72,0 +84,0 @@ * a value will not be pushed to the array if its already present in the array. |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 EclipseSource and others. | ||
* Copyright (c) 2021-2023 EclipseSource and others. | ||
* | ||
@@ -16,8 +16,4 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
/** | ||
* The built-in 'object' & 'Object' types are currently hard to use | ||
* an should be avoided. It's recommended to use Record instead to describe the | ||
* type meaning of "any object"; | ||
*/ | ||
export declare type AnyObject = Record<PropertyKey, unknown>; | ||
/** Helper type to describe any defined object*/ | ||
export type AnyObject = object; | ||
export declare namespace AnyObject { | ||
@@ -34,8 +30,8 @@ /** | ||
*/ | ||
export declare type Primitive = string | number | boolean | bigint | symbol | undefined | null; | ||
export type Primitive = string | number | boolean | bigint | symbol | undefined | null; | ||
/** | ||
* Utility type to describe objects that have a constructor function i.e. classes. | ||
*/ | ||
export interface Constructor<T> { | ||
new (...args: any[]): T; | ||
export interface Constructor<T, A extends any[] = any[]> { | ||
new (...args: A): T; | ||
} | ||
@@ -45,15 +41,19 @@ /** | ||
* all readonly modifiers of the type`s properties. Please use with care and only in instances | ||
* where you know that overwriting a readonly property is safe and doesn't cause any unintended side effects. | ||
* where you know that overwriting a readonly property is safe and doesn't cause unknown unintended side effects. | ||
*/ | ||
export declare type Writable<T> = { | ||
export type Writable<T> = { | ||
-readonly [P in keyof T]: Writable<T[P]>; | ||
}; | ||
/** | ||
* Utility type to describe a value as might be provided as a promise. | ||
*/ | ||
export type MaybePromise<T> = T | PromiseLike<T>; | ||
/** | ||
* Utility type to describe typeguard functions. | ||
*/ | ||
export declare type TypeGuard<T> = (element: any, ...args: any[]) => element is T; | ||
export type TypeGuard<T> = (element: any) => element is T; | ||
/** | ||
* Utility function that create a typeguard function for a given class constructor. | ||
* Essentially this wraps an instance of check as typeguard function. | ||
* @param constructor The constructor fo the class for which the typeguard should be created. | ||
* @param constructor The constructor of the class for which the typeguard should be created. | ||
* @returns The typeguard for this class. | ||
@@ -63,36 +63,54 @@ */ | ||
/** | ||
* Validates whether the given object as a property of type `string` with the given key. | ||
* Utility type that represents an arbitrary function. Should be used instead | ||
* of the default `Function` type which is considered to be unsafe. | ||
*/ | ||
export type SafeFunction<T = any> = (...args: any[]) => T; | ||
/** | ||
* Validates whether the given object has a property of type `string` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `string`. | ||
*/ | ||
export declare function hasStringProp(object: AnyObject, propertyKey: string): boolean; | ||
export declare function hasStringProp(object: AnyObject, propertyKey: string, optional?: boolean): boolean; | ||
/** | ||
* Validates whether the given object as a property of type `boolean` with the given key. | ||
* Validates whether the given object has a property of type `boolean` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `boolean`. | ||
*/ | ||
export declare function hasBooleanProp(object: AnyObject, propertyKey: string): boolean; | ||
export declare function hasBooleanProp(object: AnyObject, propertyKey: string, optional?: boolean): boolean; | ||
/** | ||
* Validates whether the given object as a property of type `number` with the given key. | ||
* Validates whether the given object has a property of type `number` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `number`. | ||
*/ | ||
export declare function hasNumberProp(object: AnyObject, propertyKey: string): boolean; | ||
export declare function hasNumberProp(object: AnyObject, propertyKey: string, optional?: boolean): boolean; | ||
/** | ||
* Validates whether the given object as a property of type `object` with the given key. | ||
* Validates whether the given object has a property of type `object` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `object`. | ||
*/ | ||
export declare function hasObjectProp(object: AnyObject, propertyKey: string): boolean; | ||
export declare function hasObjectProp<T extends string>(object: AnyObject, propertyKey: T, optional?: boolean): boolean; | ||
/** | ||
* Validates whether the given object as a property of type `Array` with the given key. | ||
* Validates whether the given object has a property of type `function` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `function`. | ||
*/ | ||
export declare function hasFunctionProp(object: AnyObject, propertyKey: string, optional?: boolean): boolean; | ||
/** | ||
* Validates whether the given object has a property of type `Array` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `Array`. | ||
*/ | ||
export declare function hasArrayProp(object: AnyObject, propertyKey: string): boolean; | ||
export declare function hasArrayProp(object: AnyObject, propertyKey: string, optional?: boolean): boolean; | ||
//# sourceMappingURL=type-util.d.ts.map |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2022 EclipseSource and others. | ||
* Copyright (c) 2021-2023 EclipseSource and others. | ||
* | ||
@@ -18,3 +18,3 @@ * This program and the accompanying materials are made available under the | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasArrayProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.toTypeGuard = exports.AnyObject = void 0; | ||
exports.hasArrayProp = exports.hasFunctionProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.toTypeGuard = exports.AnyObject = void 0; | ||
var AnyObject; | ||
@@ -32,7 +32,7 @@ (function (AnyObject) { | ||
AnyObject.is = is; | ||
})(AnyObject = exports.AnyObject || (exports.AnyObject = {})); | ||
})(AnyObject || (exports.AnyObject = AnyObject = {})); | ||
/** | ||
* Utility function that create a typeguard function for a given class constructor. | ||
* Essentially this wraps an instance of check as typeguard function. | ||
* @param constructor The constructor fo the class for which the typeguard should be created. | ||
* @param constructor The constructor of the class for which the typeguard should be created. | ||
* @returns The typeguard for this class. | ||
@@ -45,51 +45,73 @@ */ | ||
/** | ||
* Validates whether the given object as a property of type `string` with the given key. | ||
* Validates whether the given object has a property of type `string` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `string`. | ||
*/ | ||
function hasStringProp(object, propertyKey) { | ||
return propertyKey in object && typeof object[propertyKey] === 'string'; | ||
function hasStringProp(object, propertyKey, optional = false) { | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'string' : optional; | ||
} | ||
exports.hasStringProp = hasStringProp; | ||
/** | ||
* Validates whether the given object as a property of type `boolean` with the given key. | ||
* Validates whether the given object has a property of type `boolean` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `boolean`. | ||
*/ | ||
function hasBooleanProp(object, propertyKey) { | ||
return propertyKey in object && typeof object[propertyKey] === 'boolean'; | ||
function hasBooleanProp(object, propertyKey, optional = false) { | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'boolean' : optional; | ||
} | ||
exports.hasBooleanProp = hasBooleanProp; | ||
/** | ||
* Validates whether the given object as a property of type `number` with the given key. | ||
* Validates whether the given object has a property of type `number` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `number`. | ||
*/ | ||
function hasNumberProp(object, propertyKey) { | ||
return propertyKey in object && typeof object[propertyKey] === 'number'; | ||
function hasNumberProp(object, propertyKey, optional = false) { | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'number' : optional; | ||
} | ||
exports.hasNumberProp = hasNumberProp; | ||
/** | ||
* Validates whether the given object as a property of type `object` with the given key. | ||
* Validates whether the given object has a property of type `object` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `object`. | ||
*/ | ||
function hasObjectProp(object, propertyKey) { | ||
return propertyKey in object && AnyObject.is(object[propertyKey]); | ||
function hasObjectProp(object, propertyKey, optional = false) { | ||
const property = object[propertyKey]; | ||
return property !== undefined ? AnyObject.is(property) : optional; | ||
} | ||
exports.hasObjectProp = hasObjectProp; | ||
/** | ||
* Validates whether the given object as a property of type `Array` with the given key. | ||
* Validates whether the given object has a property of type `function` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `function`. | ||
*/ | ||
function hasFunctionProp(object, propertyKey, optional = false) { | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'function' : optional; | ||
} | ||
exports.hasFunctionProp = hasFunctionProp; | ||
/** | ||
* Validates whether the given object has a property of type `Array` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `Array`. | ||
*/ | ||
function hasArrayProp(object, propertyKey) { | ||
return propertyKey in object && Array.isArray(object[propertyKey]); | ||
function hasArrayProp(object, propertyKey, optional = false) { | ||
const property = object[propertyKey]; | ||
return property !== undefined ? Array.isArray(property) : optional; | ||
} | ||
exports.hasArrayProp = hasArrayProp; | ||
//# sourceMappingURL=type-util.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -36,3 +36,3 @@ * This program and the accompanying materials are made available under the | ||
}); | ||
it('should return false for any object of primitive type', () => { | ||
it('should return false for unknown object of primitive type', () => { | ||
(0, chai_1.expect)(type_util_1.AnyObject.is('')).to.be.false; | ||
@@ -55,5 +55,17 @@ (0, chai_1.expect)(type_util_1.AnyObject.is(5)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasStringProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasStringProp)({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasStringProp)({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasStringProp)({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasStringProp)({ someProp: 'someKey' }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -67,5 +79,17 @@ describe('hasBooleanProp', () => { | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasBooleanProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasBooleanProp)({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasBooleanProp)({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasBooleanProp)({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasBooleanProp)({ someProp: true }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -79,5 +103,17 @@ describe('hasNumberProp', () => { | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasBooleanProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasNumberProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasNumberProp)({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasNumberProp)({ someProp: '123' }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasNumberProp)({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasNumberProp)({ someProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -91,6 +127,43 @@ describe('hasObjectProp', () => { | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasObjectProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasObjectProp)({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasObjectProp)({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasObjectProp)({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasObjectProp)({ someProp: { value: 'someKey' } }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
describe('hasFunctionProp', () => { | ||
it('should return true for an object that has a property that matches the given key and type', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ someProp: () => { } }, 'someProp')).to.be.true; | ||
}); | ||
it('should return false for an object that has a property that matches the given but not the given type', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ someProp: '123' }, 'someProp')).to.be.false; | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
(0, chai_1.expect)((0, type_util_1.hasFunctionProp)({ someProp: () => { } }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
describe('hasArrayProp', () => { | ||
@@ -103,7 +176,19 @@ it('should return true for an object that has a property that matches the given key and type', () => { | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasArrayProp)({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasArrayProp)({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasArrayProp)({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasArrayProp)({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
(0, chai_1.expect)((0, type_util_1.hasArrayProp)({ someProp: ['some', 'prop'] }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=type-util.spec.js.map |
{ | ||
"name": "@eclipse-glsp/protocol", | ||
"version": "1.1.0-next.fe0b297.182+fe0b297", | ||
"version": "2.1.0-next.12ca798.289+12ca798", | ||
"description": "The protocol definition for client-server communication in GLSP", | ||
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", | ||
"keywords": [ | ||
@@ -15,6 +14,4 @@ "eclipse", | ||
], | ||
"author": { | ||
"name": "Eclipse GLSP" | ||
}, | ||
"homepage": "https://www.eclipse.org/glsp/", | ||
"bugs": "https://github.com/eclipse-glsp/glsp/issues", | ||
"repository": { | ||
@@ -24,3 +21,6 @@ "type": "git", | ||
}, | ||
"bugs": "https://github.com/eclipse-glsp/glsp/issues", | ||
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", | ||
"author": { | ||
"name": "Eclipse GLSP" | ||
}, | ||
"contributors": [ | ||
@@ -33,2 +33,4 @@ { | ||
], | ||
"main": "lib/index", | ||
"types": "lib/index", | ||
"files": [ | ||
@@ -38,6 +40,17 @@ "lib", | ||
], | ||
"scripts": { | ||
"build": "tsc -b", | ||
"clean": "rimraf lib tsconfig.tsbuildinfo coverage .nyc_output ", | ||
"lint": "eslint --ext .ts,.tsx ./src", | ||
"lint:ci": "yarn lint -o eslint.xml -f checkstyle", | ||
"prepare": "yarn clean && yarn build", | ||
"test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"", | ||
"test:ci": "export JUNIT_REPORT_PATH=./report.xml && yarn test --reporter mocha-jenkins-reporter", | ||
"test:coverage": "nyc yarn test", | ||
"watch": "tsc -w" | ||
}, | ||
"dependencies": { | ||
"sprotty-protocol": "0.12.0", | ||
"sprotty-protocol": "0.15.0-next.044bba2.13", | ||
"uuid": "7.0.3", | ||
"vscode-ws-jsonrpc": "0.2.0" | ||
"vscode-jsonrpc": "^8.0.2" | ||
}, | ||
@@ -47,10 +60,4 @@ "devDependencies": { | ||
}, | ||
"scripts": { | ||
"prepare": "yarn clean && yarn build && yarn lint", | ||
"clean": "rimraf lib tsconfig.tsbuildinfo ", | ||
"build": "tsc", | ||
"lint": "eslint -c ./.eslintrc.js --ext .ts ./src", | ||
"test": "mocha --config ../../.mocharc.json \"./src/**/*.spec.?(ts|tsx)\"", | ||
"test:ci": "export JUNIT_REPORT_PATH=./report.xml && yarn test --reporter mocha-jenkins-reporter", | ||
"watch": "tsc -w" | ||
"peerDependencies": { | ||
"inversify": "^6.0.1" | ||
}, | ||
@@ -60,5 +67,3 @@ "publishConfig": { | ||
}, | ||
"main": "lib/index", | ||
"types": "lib/index", | ||
"gitHead": "fe0b29761e9844d8541ce4cafeaf7e00976157e1" | ||
"gitHead": "12ca7983757966419ca1c15cdc333cefdf56558f" | ||
} |
@@ -1,4 +0,5 @@ | ||
# Eclipse GLSP - Client [](https://ci.eclipse.org/glsp/job/eclipse-glsp/job/glsp-client/job/master) [](https://ci.eclipse.org/glsp/job/deploy-npm-glsp-client/) | ||
# Eclipse GLSP - Protocol | ||
The generic client-server communication protocol for the [Graphical Language Server Platform (GLSP)](https://github.com/eclipse-glsp/glsp) and a json-rpc based default implementation. | ||
In addition, this package provides shared common code and utility libraries for GLSP components. | ||
@@ -10,4 +11,4 @@ This project is built with `yarn` and is available from npm via [@eclipse-glsp/protocol](https://www.npmjs.com/package/@eclipse-glsp/protocol). | ||
For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). | ||
If you have questions, contact us on our [spectrum chat](https://spectrum.chat/glsp/) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). | ||
If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). | ||
 |
@@ -19,2 +19,3 @@ /******************************************************************************** | ||
import { Action, ActionMessage, CompoundOperation, Operation, RejectAction, RequestAction, ResponseAction } from './base-protocol'; | ||
import { AnyObject } from '../utils/type-util'; | ||
@@ -237,2 +238,3 @@ /** | ||
} | ||
const isSomeCustomAction = (object: any): object is SomeCustomAction => object !== undefined && object.kind === 'custom'; | ||
const isSomeCustomAction = (object: unknown): object is SomeCustomAction => | ||
AnyObject.is(object) && 'kind' in object && object.kind === 'custom'; |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -16,5 +16,4 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
import { JsonPrimitive } from 'sprotty-protocol'; | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { AnyObject, hasArrayProp, hasStringProp, TypeGuard } from '../utils/type-util'; | ||
import { AnyObject, TypeGuard, hasArrayProp, hasStringProp } from '../utils/type-util'; | ||
@@ -69,3 +68,3 @@ /** | ||
const actionGuard = typeguard ?? Action.is; | ||
return AnyObject.is(object) && hasStringProp(object, 'clientId') && actionGuard(object.action); | ||
return AnyObject.is(object) && hasStringProp(object, 'clientId') && 'action' in object && actionGuard(object.action); | ||
} | ||
@@ -87,2 +86,6 @@ } | ||
requestId: string; | ||
/** | ||
* Used to ensure correct typing. Clients must not use this property | ||
*/ | ||
readonly _?: Res; | ||
} | ||
@@ -156,3 +159,3 @@ | ||
*/ | ||
detail?: JsonPrimitive; | ||
detail?: string; | ||
} | ||
@@ -163,7 +166,7 @@ | ||
export function is(object: any): object is RejectAction { | ||
export function is(object: unknown): object is RejectAction { | ||
return Action.hasKind(object, RejectAction.KIND) && hasStringProp(object, 'message'); | ||
} | ||
export function create(message: string, options: { detail?: JsonPrimitive; responseId?: string } = {}): RejectAction { | ||
export function create(message: string, options: { detail?: string; responseId?: string } = {}): RejectAction { | ||
return { | ||
@@ -193,4 +196,4 @@ kind: KIND, | ||
export namespace Operation { | ||
export function is(object: any): object is Operation { | ||
return Action.is(object) && (object as any).isOperation === true; | ||
export function is(object: unknown): object is Operation { | ||
return Action.is(object) && 'isOperation' in object && object.isOperation === true; | ||
} | ||
@@ -204,3 +207,3 @@ | ||
*/ | ||
export function hasKind(object: any, kind: string): object is Operation { | ||
export function hasKind(object: unknown, kind: string): object is Operation { | ||
return Operation.is(object) && object.kind === kind; | ||
@@ -226,3 +229,3 @@ } | ||
export function is(object: any): object is CompoundOperation { | ||
export function is(object: unknown): object is CompoundOperation { | ||
return Operation.hasKind(object, KIND) && hasArrayProp(object, 'operationList'); | ||
@@ -229,0 +232,0 @@ } |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -18,3 +18,3 @@ * This program and the accompanying materials are made available under the | ||
import { expect } from 'chai'; | ||
import { ServerMessageAction, ServerStatusAction } from './client-notification'; | ||
import { EndProgressAction, MessageAction, StartProgressAction, StatusAction, UpdateProgressAction } from './client-notification'; | ||
/** | ||
@@ -25,13 +25,13 @@ * Tests for the utility functions declared in the namespaces of the protocol | ||
describe('Client notification actions', () => { | ||
describe('ServerStatusAction', () => { | ||
describe('StatusAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const statusAction: ServerStatusAction = { kind: 'serverStatus', message: 'Some', severity: 'INFO' }; | ||
expect(ServerStatusAction.is(statusAction)).to.be.true; | ||
const statusAction: StatusAction = { kind: StatusAction.KIND, message: 'Some', severity: 'INFO' }; | ||
expect(StatusAction.is(statusAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(ServerStatusAction.is(undefined)).to.be.false; | ||
expect(StatusAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(ServerStatusAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
expect(StatusAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -43,8 +43,8 @@ }); | ||
const message = 'someMessage'; | ||
const expected: ServerStatusAction = { kind: ServerStatusAction.KIND, message, severity: 'INFO' }; | ||
expect(ServerStatusAction.create(message)).to.deep.equals(expected); | ||
const expected: StatusAction = { kind: StatusAction.KIND, message, severity: 'INFO' }; | ||
expect(StatusAction.create(message)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: ServerStatusAction = { | ||
kind: ServerStatusAction.KIND, | ||
const expected: StatusAction = { | ||
kind: StatusAction.KIND, | ||
message: 'someMessage', | ||
@@ -55,3 +55,3 @@ severity: 'ERROR', | ||
const { message, severity, timeout } = expected; | ||
expect(ServerStatusAction.create(message, { severity, timeout })).to.deep.equals(expected); | ||
expect(StatusAction.create(message, { severity, timeout })).to.deep.equals(expected); | ||
}); | ||
@@ -61,13 +61,13 @@ }); | ||
describe('ServerMessageAction', () => { | ||
describe('MessageAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: ServerMessageAction = { kind: 'serverMessage', message: '', severity: 'INFO' }; | ||
expect(ServerMessageAction.is(messageAction)).to.be.true; | ||
const messageAction: MessageAction = { kind: MessageAction.KIND, message: '', severity: 'INFO' }; | ||
expect(MessageAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(ServerMessageAction.is(undefined)).to.be.false; | ||
expect(MessageAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(ServerMessageAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
expect(MessageAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -79,18 +79,117 @@ }); | ||
const message = 'someMessage'; | ||
const expected: ServerMessageAction = { kind: ServerMessageAction.KIND, message, severity: 'INFO' }; | ||
expect(ServerMessageAction.create(message)).to.deep.equals(expected); | ||
const expected: MessageAction = { kind: MessageAction.KIND, message, severity: 'INFO' }; | ||
expect(MessageAction.create(message)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: ServerMessageAction = { | ||
kind: ServerMessageAction.KIND, | ||
const expected: MessageAction = { | ||
kind: MessageAction.KIND, | ||
message: 'someMessage', | ||
details: 'details', | ||
severity: 'ERROR', | ||
timeout: 5 | ||
severity: 'ERROR' | ||
}; | ||
const { message, severity, timeout, details } = expected; | ||
expect(ServerMessageAction.create(message, { severity, timeout, details })).to.deep.equals(expected); | ||
const { message, severity, details } = expected; | ||
expect(MessageAction.create(message, { severity, details })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('StartProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: StartProgressAction = { kind: 'startProgress', progressId: '1', title: 'Progress title' }; | ||
expect(StartProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(StartProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(StartProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const title = 'Progress title'; | ||
const expected: StartProgressAction = { kind: StartProgressAction.KIND, progressId, title }; | ||
expect(StartProgressAction.create({ progressId, title })).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: StartProgressAction = { | ||
kind: StartProgressAction.KIND, | ||
progressId: '1', | ||
title: 'Progress title', | ||
message: 'Some message', | ||
percentage: 10 | ||
}; | ||
const { progressId, title, message, percentage } = expected; | ||
expect(StartProgressAction.create({ progressId, title, message, percentage })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('UpdateProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: UpdateProgressAction = { kind: 'updateProgress', progressId: '1' }; | ||
expect(UpdateProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(UpdateProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(UpdateProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const expected: UpdateProgressAction = { kind: UpdateProgressAction.KIND, progressId }; | ||
expect(UpdateProgressAction.create(progressId)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: UpdateProgressAction = { | ||
kind: UpdateProgressAction.KIND, | ||
progressId: '1', | ||
message: 'Some message', | ||
percentage: 10 | ||
}; | ||
const { progressId, message, percentage } = expected; | ||
expect(UpdateProgressAction.create(progressId, { message, percentage })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('EndProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: EndProgressAction = { kind: 'endProgress', progressId: '1' }; | ||
expect(EndProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(EndProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(EndProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const expected: EndProgressAction = { kind: EndProgressAction.KIND, progressId, message: undefined }; | ||
expect(EndProgressAction.create(progressId)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: EndProgressAction = { | ||
kind: EndProgressAction.KIND, | ||
progressId: '1', | ||
message: 'Some message' | ||
}; | ||
const { progressId, message } = expected; | ||
expect(EndProgressAction.create(progressId, message)).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -20,13 +20,13 @@ * This program and the accompanying materials are made available under the | ||
/** | ||
* Sent by the server to signal a state change. | ||
* Sent by the server (or the client) to signal a status change. | ||
* If a timeout is given the respective status should disappear after the timeout is reached. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `ServerStatusActions`. | ||
* and creating new `StatusAction`s. | ||
*/ | ||
export interface ServerStatusAction extends Action { | ||
kind: typeof ServerStatusAction.KIND; | ||
export interface StatusAction extends Action { | ||
kind: typeof StatusAction.KIND; | ||
/** | ||
* The severity of the status. | ||
*/ | ||
severity: ServerSeverity; | ||
severity: SeverityLevel; | ||
@@ -44,10 +44,10 @@ /** | ||
export namespace ServerStatusAction { | ||
export const KIND = 'serverStatus'; | ||
export namespace StatusAction { | ||
export const KIND = 'status'; | ||
export function is(object: any): object is ServerStatusAction { | ||
export function is(object: unknown): object is StatusAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'severity') && hasStringProp(object, 'message'); | ||
} | ||
export function create(message: string, options: { severity?: ServerSeverity; timeout?: number } = {}): ServerStatusAction { | ||
export function create(message: string, options: { severity?: SeverityLevel; timeout?: number } = {}): StatusAction { | ||
return { | ||
@@ -66,15 +66,15 @@ kind: KIND, | ||
export type ServerSeverity = 'NONE' | 'INFO' | 'WARNING' | 'ERROR' | 'FATAL' | 'OK'; | ||
export type SeverityLevel = 'NONE' | 'INFO' | 'WARNING' | 'ERROR' | 'FATAL' | 'OK'; | ||
/** | ||
* Sent by the server to notify the user about something of interest. Typically this message is handled by | ||
* Sent by the server (or the client) to notify the user about something of interest. Typically this message is handled by | ||
* the client by showing a message to the user with the application's message service. | ||
* If a timeout is given the respective message should disappear after the timeout is reached. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `ServerMessageActions`. | ||
* and creating new `MessageAction`s. | ||
*/ | ||
export interface ServerMessageAction extends Action { | ||
kind: typeof ServerMessageAction.KIND; | ||
export interface MessageAction extends Action { | ||
kind: typeof MessageAction.KIND; | ||
severity: ServerSeverity; | ||
severity: SeverityLevel; | ||
@@ -90,13 +90,8 @@ /** | ||
details?: string; | ||
/** | ||
* Timeout after which a displayed message disappears. | ||
*/ | ||
timeout?: number; | ||
} | ||
export namespace ServerMessageAction { | ||
export const KIND = 'serverMessage'; | ||
export namespace MessageAction { | ||
export const KIND = 'message'; | ||
export function is(object: any): object is ServerMessageAction { | ||
export function is(object: unknown): object is MessageAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'message') && hasStringProp(object, 'severity'); | ||
@@ -108,7 +103,6 @@ } | ||
options: { | ||
severity?: ServerSeverity; | ||
severity?: SeverityLevel; | ||
details?: string; | ||
timeout?: number; | ||
} = {} | ||
): ServerMessageAction { | ||
): MessageAction { | ||
return { | ||
@@ -122,1 +116,114 @@ kind: KIND, | ||
} | ||
/** | ||
* Sent to request presenting the progress of a long running process in the UI. | ||
*/ | ||
export interface StartProgressAction extends Action { | ||
kind: typeof StartProgressAction.KIND; | ||
/** | ||
* An ID that can be used in subsequent `updateProgress` and `endProgress` events to make them refer to the same progress reporting. | ||
*/ | ||
progressId: string; | ||
/** | ||
* Short title of the progress reporting. Shown in the UI to describe the long running process. | ||
*/ | ||
title: string; | ||
/** | ||
* Optional additional progress message. Shown in the UI to describe the long running process. | ||
*/ | ||
message?: string; | ||
/** | ||
* Progress percentage to display (value range: 0 to 100). If omitted no percentage is shown. | ||
*/ | ||
percentage?: number; | ||
} | ||
export namespace StartProgressAction { | ||
export const KIND = 'startProgress'; | ||
export function is(object: unknown): object is StartProgressAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'progressId') && hasStringProp(object, 'title'); | ||
} | ||
export function create(options: { progressId: string; title: string; message?: string; percentage?: number }): StartProgressAction { | ||
return { | ||
kind: KIND, | ||
...options | ||
}; | ||
} | ||
} | ||
/** | ||
* Sent to presenting an update of the progress of a long running process in the UI. | ||
*/ | ||
export interface UpdateProgressAction extends Action { | ||
kind: typeof UpdateProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
/** | ||
* The percentage (value range: 0 to 100) to show in the progress reporting. | ||
*/ | ||
percentage?: number; | ||
} | ||
export namespace UpdateProgressAction { | ||
export const KIND = 'updateProgress'; | ||
export function is(object: unknown): object is UpdateProgressAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'progressId'); | ||
} | ||
export function create( | ||
progressId: string, | ||
options: { | ||
message?: string; | ||
percentage?: number; | ||
} = {} | ||
): UpdateProgressAction { | ||
return { | ||
kind: KIND, | ||
progressId, | ||
...options | ||
}; | ||
} | ||
} | ||
/** | ||
* Sent to end the reporting of a progress. | ||
*/ | ||
export interface EndProgressAction extends Action { | ||
kind: typeof EndProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
} | ||
export namespace EndProgressAction { | ||
export const KIND = 'endProgress'; | ||
export function is(object: unknown): object is EndProgressAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'progressId'); | ||
} | ||
export function create(progressId: string, message?: string): EndProgressAction { | ||
return { | ||
kind: KIND, | ||
progressId, | ||
message | ||
}; | ||
} | ||
} |
@@ -35,3 +35,3 @@ /******************************************************************************** | ||
export function is(object: any): object is RequestClipboardDataAction { | ||
export function is(object: unknown): object is RequestClipboardDataAction { | ||
return RequestAction.hasKind(object, KIND) && hasObjectProp(object, 'editorContext'); | ||
@@ -67,3 +67,3 @@ } | ||
export function is(object: any): object is SetClipboardDataAction { | ||
export function is(object: unknown): object is SetClipboardDataAction { | ||
return Action.hasKind(object, KIND) && hasObjectProp(object, 'clipboardData'); | ||
@@ -97,3 +97,3 @@ } | ||
export function is(object: any): object is CutOperation { | ||
export function is(object: unknown): object is CutOperation { | ||
return Operation.hasKind(object, KIND) && hasObjectProp(object, 'editorContext'); | ||
@@ -131,3 +131,3 @@ } | ||
export function is(object: any): object is PasteOperation { | ||
export function is(object: unknown): object is PasteOperation { | ||
return Operation.hasKind(object, KIND) && hasObjectProp(object, 'clipboardData') && hasObjectProp(object, 'editorContext'); | ||
@@ -134,0 +134,0 @@ } |
@@ -40,3 +40,3 @@ /******************************************************************************** | ||
export function is(object: any): object is RequestContextActions { | ||
export function is(object: unknown): object is RequestContextActions { | ||
return RequestAction.hasKind(object, KIND) && hasStringProp(object, 'contextId') && hasObjectProp(object, 'editorContext'); | ||
@@ -76,3 +76,3 @@ } | ||
export function is(object: any): object is SetContextActions { | ||
export function is(object: unknown): object is SetContextActions { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'actions'); | ||
@@ -79,0 +79,0 @@ } |
@@ -53,3 +53,3 @@ /******************************************************************************** | ||
export function is(object: any): object is ReconnectEdgeOperation { | ||
export function is(object: unknown): object is ReconnectEdgeOperation { | ||
return ( | ||
@@ -95,3 +95,3 @@ Operation.hasKind(object, KIND) && | ||
export function is(object: any): object is ChangeRoutingPointsOperation { | ||
export function is(object: unknown): object is ChangeRoutingPointsOperation { | ||
return Operation.hasKind(object, KIND) && hasArrayProp(object, 'newRoutingPoints'); | ||
@@ -98,0 +98,0 @@ } |
@@ -18,2 +18,3 @@ /******************************************************************************** | ||
import { Point } from 'sprotty-protocol'; | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { hasArrayProp, hasStringProp } from '../utils/type-util'; | ||
@@ -39,3 +40,3 @@ import { Operation } from './base-protocol'; | ||
export namespace CreateOperation { | ||
export function is(object: any): object is CreateOperation { | ||
export function is(object: unknown): object is CreateOperation { | ||
return Operation.is(object) && hasStringProp(object, 'elementTypeId'); | ||
@@ -50,3 +51,3 @@ } | ||
*/ | ||
export function hasKind(object: any, kind: string): object is CreateOperation { | ||
export function hasKind(object: unknown, kind: string): object is CreateOperation { | ||
return CreateOperation.is(object) && object.kind === kind; | ||
@@ -80,3 +81,3 @@ } | ||
export function is(object: any): object is CreateNodeOperation { | ||
export function is(object: unknown): object is CreateNodeOperation { | ||
return CreateOperation.hasKind(object, KIND); | ||
@@ -114,3 +115,3 @@ } | ||
export function is(object: any): object is CreateEdgeOperation { | ||
export function is(object: unknown): object is CreateEdgeOperation { | ||
return ( | ||
@@ -139,3 +140,3 @@ CreateOperation.hasKind(object, KIND) && hasStringProp(object, 'sourceElementId') && hasStringProp(object, 'targetElementId') | ||
*/ | ||
export interface DeleteElementOperation extends Operation { | ||
export interface DeleteElementOperation extends Operation, Omit<sprotty.DeleteElementAction, 'kind'> { | ||
kind: typeof DeleteElementOperation.KIND; | ||
@@ -152,3 +153,3 @@ | ||
export function is(object: any): object is DeleteElementOperation { | ||
export function is(object: unknown): object is DeleteElementOperation { | ||
return Operation.hasKind(object, KIND) && hasArrayProp(object, 'elementIds'); | ||
@@ -155,0 +156,0 @@ } |
@@ -18,5 +18,5 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '../model/model-schema'; | ||
import { hasObjectProp, hasStringProp } from '../utils/type-util'; | ||
import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
import { SModelRootSchema } from './model-structure'; | ||
@@ -46,3 +46,3 @@ /** | ||
export function is(object: any): object is RequestPopupModelAction { | ||
export function is(object: unknown): object is RequestPopupModelAction { | ||
return RequestAction.hasKind(object, KIND) && hasStringProp(object, 'elementId') && hasObjectProp(object, 'bounds'); | ||
@@ -62,3 +62,3 @@ } | ||
* Sent from the server to the client to display a popup in response to a RequestPopupModelAction. This action can also be used to remove | ||
* any existing popup by choosing EMPTY_ROOT as root element. | ||
* unknown existing popup by choosing EMPTY_ROOT as root element. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
@@ -70,3 +70,3 @@ * and creating new `SetPopupModelActions`. | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
} | ||
@@ -77,7 +77,7 @@ | ||
export function is(object: any): object is SetPopupModelAction { | ||
export function is(object: unknown): object is SetPopupModelAction { | ||
return Action.hasKind(object, KIND) && hasObjectProp(object, 'newRoot'); | ||
} | ||
export function create(newRoot: SModelRootSchema, options: { responseId?: string } = {}): SetPopupModelAction { | ||
export function create(newRoot: GModelRootSchema, options: { responseId?: string } = {}): SetPopupModelAction { | ||
return { | ||
@@ -84,0 +84,0 @@ kind: KIND, |
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import { JsonPrimitive } from 'sprotty-protocol'; | ||
import { hasArrayProp, hasObjectProp, hasStringProp } from '../utils/type-util'; | ||
import { AnyObject, hasArrayProp, hasObjectProp, hasStringProp } from '../utils/type-util'; | ||
import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
@@ -44,4 +44,4 @@ import { Args, EditorContext } from './types'; | ||
export namespace NavigationTarget { | ||
export function is(object: any): object is NavigationTarget { | ||
return object !== undefined && hasStringProp(object, 'uri'); | ||
export function is(object: unknown): object is NavigationTarget { | ||
return AnyObject.is(object) && hasStringProp(object, 'uri'); | ||
} | ||
@@ -180,3 +180,3 @@ /** | ||
export function is(object: any): object is RequestNavigationTargetsAction { | ||
export function is(object: unknown): object is RequestNavigationTargetsAction { | ||
return RequestAction.hasKind(object, KIND) && hasStringProp(object, 'targetTypeId') && hasObjectProp(object, 'editorContext'); | ||
@@ -219,3 +219,3 @@ } | ||
export function is(object: any): object is SetNavigationTargetsAction { | ||
export function is(object: unknown): object is SetNavigationTargetsAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'targets'); | ||
@@ -248,3 +248,3 @@ } | ||
export function is(object: any): object is NavigateToTargetAction { | ||
export function is(object: unknown): object is NavigateToTargetAction { | ||
return Action.hasKind(object, KIND) && hasObjectProp(object, 'target'); | ||
@@ -280,3 +280,3 @@ } | ||
export function is(object: any): object is ResolveNavigationTargetAction { | ||
export function is(object: unknown): object is ResolveNavigationTargetAction { | ||
return RequestAction.hasKind(object, KIND) && hasObjectProp(object, 'navigationTarget'); | ||
@@ -318,3 +318,3 @@ } | ||
export function is(object: any): object is SetResolvedNavigationTargetAction { | ||
export function is(object: unknown): object is SetResolvedNavigationTargetAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'elementIds'); | ||
@@ -352,3 +352,3 @@ } | ||
export function is(object: any): object is NavigateToExternalTargetAction { | ||
export function is(object: unknown): object is NavigateToExternalTargetAction { | ||
return Action.hasKind(object, KIND) && hasObjectProp(object, 'target'); | ||
@@ -355,0 +355,0 @@ } |
@@ -48,3 +48,4 @@ /******************************************************************************** | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: [] | ||
deselectedElementsIDs: [], | ||
deselectAll: false | ||
}; | ||
@@ -57,3 +58,4 @@ expect(SelectAction.create()).to.deep.equals(expected); | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: ['deselected'] | ||
deselectedElementsIDs: ['deselected'], | ||
deselectAll: false | ||
}; | ||
@@ -63,3 +65,49 @@ const { selectedElementsIDs, deselectedElementsIDs } = expected; | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments: deselectAll', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: true | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
expect(SelectAction.create({ deselectedElementsIDs: true, selectedElementsIDs })).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('addSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: false | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
expect(SelectAction.addSelection(selectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('removeSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: ['deselected'], | ||
deselectAll: false | ||
}; | ||
const { deselectedElementsIDs } = expected; | ||
expect(SelectAction.removeSelection(deselectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('setSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: true | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
expect(SelectAction.setSelection(selectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
@@ -66,0 +114,0 @@ |
@@ -17,2 +17,3 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { isStringArray } from '../utils/array-util'; | ||
import { hasArrayProp, hasBooleanProp } from '../utils/type-util'; | ||
@@ -40,2 +41,7 @@ import { Action } from './base-protocol'; | ||
deselectedElementsIDs: string[]; | ||
/** | ||
* Whether all currently selected elements should be deselected. | ||
*/ | ||
deselectAll?: boolean; | ||
} | ||
@@ -46,14 +52,27 @@ | ||
export function is(object: any): object is SelectAction { | ||
export function is(object: unknown): object is SelectAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'selectedElementsIDs') && hasArrayProp(object, 'deselectedElementsIDs'); | ||
} | ||
export function create(options: { selectedElementsIDs?: string[]; deselectedElementsIDs?: string[] } = {}): SelectAction { | ||
export function create(options: { selectedElementsIDs?: string[]; deselectedElementsIDs?: string[] | boolean } = {}): SelectAction { | ||
const deselectedElementsIDs = options.deselectedElementsIDs ?? []; | ||
return { | ||
kind: KIND, | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: [], | ||
...options | ||
selectedElementsIDs: options.selectedElementsIDs ?? [], | ||
deselectedElementsIDs: isStringArray(deselectedElementsIDs, true) ? deselectedElementsIDs : [], | ||
deselectAll: typeof deselectedElementsIDs === 'boolean' ? deselectedElementsIDs : false | ||
}; | ||
} | ||
export function addSelection(selectedElementsIDs: string[]): SelectAction { | ||
return create({ selectedElementsIDs }); | ||
} | ||
export function removeSelection(deselectedElementsIDs: string[]): SelectAction { | ||
return create({ deselectedElementsIDs }); | ||
} | ||
export function setSelection(selectedElementsIDs: string[]): SelectAction { | ||
return create({ selectedElementsIDs, deselectedElementsIDs: true }); | ||
} | ||
} | ||
@@ -78,3 +97,3 @@ | ||
export function is(object: any): object is SelectAllAction { | ||
export function is(object: unknown): object is SelectAllAction { | ||
return Action.hasKind(object, KIND) && hasBooleanProp(object, 'select'); | ||
@@ -81,0 +100,0 @@ } |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -107,3 +107,3 @@ * This program and the accompanying materials are made available under the | ||
kind: 'setEditValidationResult', | ||
responseId: 'myRespsone', | ||
responseId: 'myResponse', | ||
args: { some: 'args' }, | ||
@@ -110,0 +110,0 @@ status: { severity: ValidationStatus.Severity.OK } |
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource and others. | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
@@ -16,2 +16,3 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { hasObjectProp, hasStringProp } from '../utils/type-util'; | ||
@@ -48,3 +49,3 @@ import { Action, Operation, RequestAction, ResponseAction } from './base-protocol'; | ||
export function is(object: any): object is RequestEditValidationAction { | ||
export function is(object: unknown): object is RequestEditValidationAction { | ||
return ( | ||
@@ -91,3 +92,3 @@ RequestAction.hasKind(object, KIND) && | ||
export function is(object: any): object is SetEditValidationResultAction { | ||
export function is(object: unknown): object is SetEditValidationResultAction { | ||
return Action.hasKind(object, KIND) && hasObjectProp(object, 'status'); | ||
@@ -113,3 +114,3 @@ } | ||
*/ | ||
export interface ApplyLabelEditOperation extends Operation { | ||
export interface ApplyLabelEditOperation extends Operation, sprotty.ApplyLabelEditAction { | ||
kind: typeof ApplyLabelEditOperation.KIND; | ||
@@ -131,3 +132,3 @@ | ||
export function is(object: any): object is ApplyLabelEditOperation { | ||
export function is(object: unknown): object is ApplyLabelEditOperation { | ||
return Operation.hasKind(object, KIND) && hasStringProp(object, 'labelId') && hasStringProp(object, 'text'); | ||
@@ -171,3 +172,2 @@ } | ||
*/ | ||
// eslint-disable-next-line no-shadow | ||
export enum Severity { | ||
@@ -179,3 +179,2 @@ FATAL, | ||
OK, | ||
// eslint-disable-next-line no-shadow | ||
NONE | ||
@@ -245,3 +244,3 @@ } | ||
*/ | ||
readonly data: Record<string, any>; | ||
readonly data: Record<string, unknown>; | ||
} |
@@ -18,3 +18,3 @@ /******************************************************************************** | ||
import { expect } from 'chai'; | ||
import { RequestTypeHintsAction, SetTypeHintsAction } from './element-type-hints'; | ||
import { CheckEdgeResultAction, RequestCheckEdgeAction, RequestTypeHintsAction, SetTypeHintsAction } from './element-type-hints'; | ||
/** | ||
@@ -140,2 +140,129 @@ * Tests for the utility functions declared in the namespaces of the protocol | ||
}); | ||
describe('RequestCheckEdgeAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action: RequestCheckEdgeAction = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
requestId: '' | ||
}; | ||
expect(RequestCheckEdgeAction.is(action)).to.be.true; | ||
}); | ||
it('should return true for an object having the correct type and a value for all required interface & optional properties', () => { | ||
const action: RequestCheckEdgeAction = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
requestId: '' | ||
}; | ||
expect(RequestCheckEdgeAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(RequestCheckEdgeAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(RequestCheckEdgeAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const expected: RequestCheckEdgeAction = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
requestId: '', | ||
targetElementId: undefined | ||
}; | ||
expect(RequestCheckEdgeAction.create({ edgeType: 'edge', sourceElement: 'source' })).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: RequestCheckEdgeAction = { | ||
kind: 'requestCheckEdge', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
requestId: 'myRequest' | ||
}; | ||
expect( | ||
RequestCheckEdgeAction.create({ | ||
edgeType: 'edge', | ||
sourceElement: 'source', | ||
targetElement: 'target', | ||
requestId: 'myRequest' | ||
}) | ||
).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('CheckEdgeResultAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action: CheckEdgeResultAction = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
responseId: '' | ||
}; | ||
expect(CheckEdgeResultAction.is(action)).to.be.true; | ||
}); | ||
it('should return true for an object having the correct type and a value for all required interface & optional properties', () => { | ||
const action: CheckEdgeResultAction = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
responseId: 'myResponse' | ||
}; | ||
expect(CheckEdgeResultAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(CheckEdgeResultAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(CheckEdgeResultAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const expected: CheckEdgeResultAction = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
responseId: '' | ||
}; | ||
expect(CheckEdgeResultAction.create({ edgeType: 'edge', isValid: true, sourceElementId: 'source' })).to.deep.equals( | ||
expected | ||
); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: CheckEdgeResultAction = { | ||
isValid: true, | ||
kind: 'checkEdgeTargetResult', | ||
edgeType: 'edge', | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
responseId: 'myResponse' | ||
}; | ||
expect( | ||
CheckEdgeResultAction.create({ | ||
edgeType: 'edge', | ||
isValid: true, | ||
sourceElementId: 'source', | ||
targetElementId: 'target', | ||
responseId: 'myResponse' | ||
}) | ||
).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -17,3 +17,4 @@ /******************************************************************************** | ||
import { hasArrayProp } from '../utils/type-util'; | ||
import { GModelElementSchema } from '../model/model-schema'; | ||
import { hasArrayProp, hasBooleanProp, hasStringProp } from '../utils/type-util'; | ||
import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
@@ -57,3 +58,3 @@ | ||
/** | ||
* The types of elements that can be contained by this element (if any) | ||
* The types of elements that can be contained by this element (if unknown) | ||
*/ | ||
@@ -68,3 +69,4 @@ readonly containableElementTypeIds?: string[]; | ||
/** | ||
* Specifies whether the routing of this element can be changed. | ||
* Specifies whether the routing points of the edge can be changed | ||
* i.e. edited by the user. | ||
*/ | ||
@@ -74,10 +76,21 @@ readonly routable: boolean; | ||
/** | ||
* Allowed source element types for this edge type | ||
* Allowed source element types for this edge type. | ||
* If not defined unknown element can be used as source element for this edge. | ||
*/ | ||
readonly sourceElementTypeIds: string[]; | ||
readonly sourceElementTypeIds?: string[]; | ||
/** | ||
* Allowed targe element types for this edge type | ||
* Allowed target element types for this edge type | ||
* If not defined unknown element can be used as target element for this edge. | ||
*/ | ||
readonly targetElementTypeIds: string[]; | ||
readonly targetElementTypeIds?: string[]; | ||
/** | ||
* Indicates whether this type hint is dynamic or not. Dynamic edge type hints | ||
* require an additional runtime check before creating an edge, when checking | ||
* source and target element types is not sufficient. | ||
* | ||
* @see {@link RequestCheckEdgeAction} | ||
*/ | ||
readonly dynamic?: boolean; | ||
} | ||
@@ -88,3 +101,3 @@ | ||
* The `RequestTypeHintsAction` is optional, but should usually be among the first messages sent from the client to the server after | ||
* receiving the model via RequestModelAction. The response is a {@link SetTypeHintsAction}. | ||
* receiving the model via `RequestModelAction`. The response is a {@link SetTypeHintsAction}. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
@@ -100,3 +113,3 @@ * and creating new `RequestTypeHintsActions`. | ||
export function is(object: any): object is RequestTypeHintsAction { | ||
export function is(object: unknown): object is RequestTypeHintsAction { | ||
return RequestAction.hasKind(object, KIND); | ||
@@ -130,3 +143,3 @@ } | ||
export function is(object: any): object is SetTypeHintsAction { | ||
export function is(object: unknown): object is SetTypeHintsAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'shapeHints') && hasArrayProp(object, 'edgeHints'); | ||
@@ -143,1 +156,117 @@ } | ||
} | ||
/** | ||
* Sent from the client to the server to check wether the provided edge context information is valid i.e. | ||
* creation of an edge with the given edge type and source/target element is allowed by the server. | ||
* Typically this action is dispatched by edge creation tools in the creation phase of an edge that's associated | ||
* with a dynamic {@link EdgeTypeHint}. | ||
*/ | ||
export interface RequestCheckEdgeAction extends RequestAction<CheckEdgeResultAction> { | ||
kind: typeof RequestCheckEdgeAction.KIND; | ||
/** | ||
* The element type of the edge being created. | ||
*/ | ||
edgeType: string; | ||
/** | ||
* The ID of the edge source element. | ||
*/ | ||
sourceElementId: string; | ||
/** | ||
* The ID of the edge target element to check. | ||
*/ | ||
targetElementId?: string; | ||
} | ||
export namespace RequestCheckEdgeAction { | ||
export const KIND = 'requestCheckEdge'; | ||
export function is(object: unknown): object is RequestCheckEdgeAction { | ||
return ( | ||
Action.hasKind(object, KIND) && | ||
hasStringProp(object, 'edgeType') && | ||
hasStringProp(object, 'sourceElementId') && | ||
hasStringProp(object, 'targetElementId', true) | ||
); | ||
} | ||
export function create(options: { | ||
sourceElement: GModelElementSchema | string; | ||
targetElement?: GModelElementSchema | string; | ||
edgeType: string; | ||
requestId?: string; | ||
}): RequestCheckEdgeAction { | ||
return { | ||
kind: KIND, | ||
edgeType: options.edgeType, | ||
sourceElementId: getElementTypeId(options.sourceElement), | ||
targetElementId: options.targetElement ? getElementTypeId(options.targetElement) : undefined, | ||
requestId: options.requestId ?? '' | ||
}; | ||
} | ||
} | ||
function getElementTypeId(element: GModelElementSchema | string): string { | ||
if (typeof element === 'string') { | ||
return element; | ||
} | ||
return element.id; | ||
} | ||
/** | ||
* Send from the server to the client as a response for a {@link RequestCheckEdgeAction}. It provides | ||
* a boolean indicating whether the edge context information provided by the corresponding request action is valid | ||
* i.e. creation of an edge with the given edge type and source/target element is allowed. | ||
*/ | ||
export interface CheckEdgeResultAction extends ResponseAction { | ||
kind: typeof CheckEdgeResultAction.KIND; | ||
/** | ||
* true if the selected element is a valid target for this edge, | ||
* false otherwise. | ||
*/ | ||
isValid: boolean; | ||
/** | ||
* The element type of the edge that has been checked. | ||
*/ | ||
edgeType: string; | ||
/** | ||
* The ID of the source element of the edge that has been checked. | ||
*/ | ||
sourceElementId: string; | ||
/** | ||
* The ID of the target element of the edge that has been checked. | ||
*/ | ||
targetElementId?: string; | ||
} | ||
export namespace CheckEdgeResultAction { | ||
export const KIND = 'checkEdgeTargetResult'; | ||
export function is(object: unknown): object is CheckEdgeResultAction { | ||
return ( | ||
Action.hasKind(object, KIND) && | ||
hasBooleanProp(object, 'isValid') && | ||
hasStringProp(object, 'edgeType') && | ||
hasStringProp(object, 'sourceElementId') && | ||
hasStringProp(object, 'targetElementId', true) | ||
); | ||
} | ||
export function create(options: { | ||
isValid: boolean; | ||
edgeType: string; | ||
sourceElementId: string; | ||
targetElementId?: string; | ||
responseId?: string; | ||
}): CheckEdgeResultAction { | ||
return { | ||
kind: KIND, | ||
responseId: '', | ||
...options | ||
}; | ||
} | ||
} |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -48,3 +48,4 @@ * This program and the accompanying materials are made available under the | ||
requestId: '', | ||
elementsIDs: ['myIds'] | ||
elementsIDs: ['myIds'], | ||
reason: 'batch' | ||
}; | ||
@@ -58,3 +59,4 @@ const { elementsIDs } = expected; | ||
requestId: 'myRequest', | ||
elementsIDs: ['myIds'] | ||
elementsIDs: ['myIds'], | ||
reason: 'batch' | ||
}; | ||
@@ -90,2 +92,3 @@ const { elementsIDs, requestId } = expected; | ||
responseId: '', | ||
reason: 'batch', | ||
markers: [{ description: 'desc', elementId: 'myId', kind: 'info', label: 'string' }] | ||
@@ -100,2 +103,3 @@ }; | ||
responseId: 'myResponse', | ||
reason: 'batch', | ||
markers: [{ description: 'desc', elementId: 'myId', kind: 'info', label: 'string' }] | ||
@@ -102,0 +106,0 @@ }; |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -51,2 +51,12 @@ * This program and the accompanying materials are made available under the | ||
/** | ||
* The default reasons for markers. | ||
*/ | ||
export namespace MarkersReason { | ||
/** Markers resulting from a batch validation */ | ||
export const BATCH = 'batch'; | ||
/** Markers resulting from a live validation */ | ||
export const LIVE = 'live'; | ||
} | ||
/** | ||
* Action to retrieve markers for the specified model elements. Sent from the client to the server. | ||
@@ -63,2 +73,7 @@ * The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
elementsIDs: string[]; | ||
/** | ||
* The reason for this request, such as `batch` or `live` validation. `batch` by default. | ||
*/ | ||
reason?: string; | ||
} | ||
@@ -69,7 +84,7 @@ | ||
export function is(object: any): object is RequestMarkersAction { | ||
export function is(object: unknown): object is RequestMarkersAction { | ||
return RequestAction.hasKind(object, KIND) && hasArrayProp(object, 'elementsIDs'); | ||
} | ||
export function create(elementsIDs: string[], options: { requestId?: string } = {}): RequestMarkersAction { | ||
export function create(elementsIDs: string[], options: { requestId?: string; reason?: string } = {}): RequestMarkersAction { | ||
return { | ||
@@ -79,2 +94,3 @@ kind: KIND, | ||
elementsIDs, | ||
reason: MarkersReason.BATCH, | ||
...options | ||
@@ -88,3 +104,3 @@ }; | ||
* Typically, this is a response to the {@link RequestMarkersAction} containing all validation markers, but can be sent by the server at | ||
* any time. | ||
* unknown time. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
@@ -100,2 +116,7 @@ * and creating new `SetMarkersActions`. | ||
readonly markers: Marker[]; | ||
/** | ||
* The reason for message, such as `batch` or `live` validation. | ||
*/ | ||
reason?: string; | ||
} | ||
@@ -106,7 +127,7 @@ | ||
export function is(object: any): object is SetMarkersAction { | ||
export function is(object: unknown): object is SetMarkersAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'markers'); | ||
} | ||
export function create(markers: Marker[], options: { responseId?: string } = {}): SetMarkersAction { | ||
export function create(markers: Marker[], options: { responseId?: string; reason?: string } = {}): SetMarkersAction { | ||
return { | ||
@@ -116,2 +137,3 @@ kind: KIND, | ||
markers, | ||
reason: MarkersReason.BATCH, | ||
...options | ||
@@ -139,3 +161,3 @@ }; | ||
export function is(object: any): object is DeleteMarkersAction { | ||
export function is(object: unknown): object is DeleteMarkersAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'markers'); | ||
@@ -142,0 +164,0 @@ } |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -32,3 +32,2 @@ * This program and the accompanying materials are made available under the | ||
export * from './model-saving'; | ||
export * from './model-structure'; | ||
export * from './node-modification'; | ||
@@ -35,0 +34,0 @@ export * from './tool-palette'; |
@@ -17,5 +17,5 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '../model/model-schema'; | ||
import { hasObjectProp, hasStringProp } from '../utils/type-util'; | ||
import { Action, RequestAction, ResponseAction } from './base-protocol'; | ||
import { SModelRootSchema } from './model-structure'; | ||
import { Args } from './types'; | ||
@@ -40,3 +40,3 @@ | ||
export function is(object: any): object is RequestModelAction { | ||
export function is(object: unknown): object is RequestModelAction { | ||
return RequestAction.hasKind(object, KIND); | ||
@@ -64,3 +64,3 @@ } | ||
*/ | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
} | ||
@@ -71,7 +71,7 @@ | ||
export function is(object: any): object is SetModelAction { | ||
export function is(object: unknown): object is SetModelAction { | ||
return Action.hasKind(object, KIND) && hasObjectProp(object, 'newRoot'); | ||
} | ||
export function create(newRoot: SModelRootSchema, options: { responseId?: string } = {}): SetModelAction { | ||
export function create(newRoot: GModelRootSchema, options: { responseId?: string } = {}): SetModelAction { | ||
return { | ||
@@ -95,3 +95,3 @@ kind: KIND, | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
/** | ||
@@ -106,7 +106,7 @@ * Boolean flag to indicate wether updated/changed elements should be animated in the diagram. | ||
export function is(action: any): action is UpdateModelAction { | ||
export function is(action: unknown): action is UpdateModelAction { | ||
return Action.hasKind(action, KIND) && hasObjectProp(action, 'newRoot'); | ||
} | ||
export function create(newRoot: SModelRootSchema, options: { animate?: boolean } = {}): UpdateModelAction { | ||
export function create(newRoot: GModelRootSchema, options: { animate?: boolean } = {}): UpdateModelAction { | ||
return { | ||
@@ -139,3 +139,3 @@ kind: KIND, | ||
export function is(object: any): object is SourceModelChangedAction { | ||
export function is(object: unknown): object is SourceModelChangedAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'sourceModelName'); | ||
@@ -142,0 +142,0 @@ } |
@@ -37,3 +37,3 @@ /******************************************************************************** | ||
export function is(object: any): object is SetEditModeAction { | ||
export function is(object: unknown): object is SetEditModeAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'editMode'); | ||
@@ -40,0 +40,0 @@ } |
@@ -100,6 +100,7 @@ /******************************************************************************** | ||
revision: 5, | ||
bounds: [{ elementId: '', newSize: Dimension.EMPTY, newPosition: Point.ORIGIN }] | ||
bounds: [{ elementId: '', newSize: Dimension.EMPTY, newPosition: Point.ORIGIN }], | ||
routes: [{ elementId: 'myEdge', newRoutingPoints: [{ x: 42, y: 1337 }] }] | ||
}; | ||
const { bounds, responseId, alignments, revision } = expected; | ||
expect(ComputedBoundsAction.create(bounds, { responseId, alignments, revision })).to.deep.equals(expected); | ||
const { bounds, responseId, alignments, revision, routes } = expected; | ||
expect(ComputedBoundsAction.create(bounds, { responseId, alignments, revision, routes })).to.deep.equals(expected); | ||
}); | ||
@@ -106,0 +107,0 @@ }); |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -17,6 +17,6 @@ * This program and the accompanying materials are made available under the | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '..'; | ||
import { hasArrayProp, hasObjectProp } from '../utils/type-util'; | ||
import { Action, Operation, RequestAction, ResponseAction } from './base-protocol'; | ||
import { SModelRootSchema } from './model-structure'; | ||
import { ElementAndAlignment, ElementAndBounds } from './types'; | ||
import { ElementAndAlignment, ElementAndBounds, ElementAndRoutingPoints } from './types'; | ||
@@ -30,3 +30,3 @@ /** | ||
*/ | ||
export interface RequestBoundsAction extends RequestAction<ComputedBoundsAction>, sprotty.RequestBoundsAction { | ||
export interface RequestBoundsAction extends RequestAction<ComputedBoundsAction>, Omit<sprotty.RequestBoundsAction, '_'> { | ||
kind: typeof RequestBoundsAction.KIND; | ||
@@ -37,3 +37,3 @@ | ||
*/ | ||
newRoot: SModelRootSchema; | ||
newRoot: GModelRootSchema; | ||
} | ||
@@ -44,7 +44,7 @@ | ||
export function is(object: any): object is RequestBoundsAction { | ||
export function is(object: unknown): object is RequestBoundsAction { | ||
return RequestAction.hasKind(object, KIND) && hasObjectProp(object, 'newRoot'); | ||
} | ||
export function create(newRoot: SModelRootSchema, options: { requestId?: string } = {}): RequestBoundsAction { | ||
export function create(newRoot: GModelRootSchema, options: { requestId?: string } = {}): RequestBoundsAction { | ||
return { | ||
@@ -81,2 +81,7 @@ kind: KIND, | ||
alignments?: ElementAndAlignment[]; | ||
/** | ||
* The route of the model elements. | ||
*/ | ||
routes?: ElementAndRoutingPoints[]; | ||
} | ||
@@ -87,3 +92,3 @@ | ||
export function is(object: any): object is ComputedBoundsAction { | ||
export function is(object: unknown): object is ComputedBoundsAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'bounds'); | ||
@@ -98,2 +103,3 @@ } | ||
alignments?: ElementAndAlignment[]; | ||
routes?: ElementAndRoutingPoints[]; | ||
} = {} | ||
@@ -119,5 +125,5 @@ ): ComputedBoundsAction { | ||
/** | ||
* The identifiers of the elements that should be layouted, may be just the root element. | ||
* The identifiers of the elements that should be layouted, will default to the root element if not defined. | ||
*/ | ||
elementIds: string[]; | ||
elementIds?: string[]; | ||
} | ||
@@ -128,7 +134,7 @@ | ||
export function is(object: any): object is LayoutOperation { | ||
export function is(object: unknown): object is LayoutOperation { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'elementIds'); | ||
} | ||
export function create(elementIds: string[]): LayoutOperation { | ||
export function create(elementIds?: string[]): LayoutOperation { | ||
return { | ||
@@ -135,0 +141,0 @@ kind: KIND, |
@@ -36,3 +36,3 @@ /******************************************************************************** | ||
export function is(object: any): object is SaveModelAction { | ||
export function is(object: unknown): object is SaveModelAction { | ||
return Action.hasKind(object, KIND); | ||
@@ -73,3 +73,3 @@ } | ||
export function is(object: any): object is SetDirtyStateAction { | ||
export function is(object: unknown): object is SetDirtyStateAction { | ||
return Action.hasKind(object, KIND) && hasBooleanProp(object, 'isDirty'); | ||
@@ -98,3 +98,3 @@ } | ||
export function is(object: any): object is RequestExportSvgAction { | ||
export function is(object: unknown): object is RequestExportSvgAction { | ||
return RequestAction.hasKind(object, KIND); | ||
@@ -127,3 +127,3 @@ } | ||
export function is(object: any): object is RequestExportSvgAction { | ||
export function is(object: unknown): object is ExportSvgAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'svg'); | ||
@@ -130,0 +130,0 @@ } |
@@ -22,3 +22,3 @@ /******************************************************************************** | ||
/** | ||
* The schema of an SModelElement describes its serializable form. The actual class-based model is derived | ||
* The schema of an GModelElement describes its serializable form. The actual class-based model is derived | ||
* its schema whenever the client or server deserializes a received schema`. | ||
@@ -25,0 +25,0 @@ * Each model element must have a unique ID and a type that is used on the client to look up its view. |
@@ -38,3 +38,3 @@ /******************************************************************************** | ||
export function is(object: any): object is ChangeBoundsOperation { | ||
export function is(object: unknown): object is ChangeBoundsOperation { | ||
return Operation.hasKind(object, KIND) && hasArrayProp(object, 'newBounds'); | ||
@@ -80,3 +80,3 @@ } | ||
export function is(object: any): object is ChangeContainerOperation { | ||
export function is(object: unknown): object is ChangeContainerOperation { | ||
return Operation.hasKind(object, KIND) && hasStringProp(object, 'elementId') && hasStringProp(object, 'targetContainerId'); | ||
@@ -83,0 +83,0 @@ } |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -21,3 +21,3 @@ * This program and the accompanying materials are made available under the | ||
describe('Tool palette Actions', () => { | ||
describe('TrigerNodeCreationAction', () => { | ||
describe('TriggerNodeCreationAction', () => { | ||
describe('is', () => { | ||
@@ -24,0 +24,0 @@ it('should return true for an object having the correct type and a value for all required interface properties', () => { |
@@ -44,3 +44,3 @@ /******************************************************************************** | ||
export function is(object: any): object is TriggerNodeCreationAction { | ||
export function is(object: unknown): object is TriggerNodeCreationAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'elementTypeId'); | ||
@@ -82,3 +82,3 @@ } | ||
export function is(object: any): object is TriggerEdgeCreationAction { | ||
export function is(object: unknown): object is TriggerEdgeCreationAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'elementTypeId'); | ||
@@ -85,0 +85,0 @@ } |
@@ -101,4 +101,4 @@ /******************************************************************************** | ||
export namespace EditorContext { | ||
export function is(object: any): object is EditorContext { | ||
return object !== undefined && hasArrayProp(object, 'selectedElementIds'); | ||
export function is(object: unknown): object is EditorContext { | ||
return AnyObject.is(object) && hasArrayProp(object, 'selectedElementIds'); | ||
} | ||
@@ -128,3 +128,3 @@ } | ||
export namespace LabeledAction { | ||
export function is(object: any): object is LabeledAction { | ||
export function is(object: unknown): object is LabeledAction { | ||
return AnyObject.is(object) && hasStringProp(object, 'label') && hasArrayProp(object, 'actions'); | ||
@@ -157,3 +157,3 @@ } | ||
export namespace PaletteItem { | ||
export function is(object: any): object is PaletteItem { | ||
export function is(object: unknown): object is PaletteItem { | ||
return LabeledAction.is(object) && hasStringProp(object, 'id') && hasStringProp(object, 'sortString'); | ||
@@ -174,3 +174,3 @@ } | ||
export function isTriggerElementCreationAction(object: any): object is TriggerElementCreationAction { | ||
export function isTriggerElementCreationAction(object: unknown): object is TriggerElementCreationAction { | ||
return TriggerNodeCreationAction.is(object) || TriggerEdgeCreationAction.is(object); | ||
@@ -207,5 +207,5 @@ } | ||
export namespace MenuItem { | ||
export function is(object: any): object is MenuItem { | ||
export function is(object: unknown): object is MenuItem { | ||
return LabeledAction.is(object) && hasStringProp(object, 'id'); | ||
} | ||
} |
@@ -17,19 +17,18 @@ /******************************************************************************** | ||
import { expect } from 'chai'; | ||
import { RedoOperation, UndoOperation } from './undo-redo'; | ||
import { RedoAction, UndoAction } from './undo-redo'; | ||
describe('Undo & Redo Actions', () => { | ||
describe('UndoOperation', () => { | ||
describe('UndoAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action: UndoOperation = { | ||
kind: 'glspUndo', | ||
isOperation: true | ||
const action: UndoAction = { | ||
kind: 'glspUndo' | ||
}; | ||
expect(UndoOperation.is(action)).to.be.true; | ||
expect(UndoAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(UndoOperation.is(undefined)).to.be.false; | ||
expect(UndoAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(UndoOperation.is({ kind: 'notTheRightOne' })).to.be.false; | ||
expect(UndoAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -40,7 +39,6 @@ }); | ||
it('should return an object conforming to the interface with matching properties for the given required arguments', () => { | ||
const expected: UndoOperation = { | ||
kind: 'glspUndo', | ||
isOperation: true | ||
const expected: UndoAction = { | ||
kind: 'glspUndo' | ||
}; | ||
expect(UndoOperation.create()).to.deep.equals(expected); | ||
expect(UndoAction.create()).to.deep.equals(expected); | ||
}); | ||
@@ -50,16 +48,15 @@ }); | ||
describe('RedoOperation', () => { | ||
describe('RedoAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const action: RedoOperation = { | ||
kind: 'glspRedo', | ||
isOperation: true | ||
const action: RedoAction = { | ||
kind: 'glspRedo' | ||
}; | ||
expect(RedoOperation.is(action)).to.be.true; | ||
expect(RedoAction.is(action)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(RedoOperation.is(undefined)).to.be.false; | ||
expect(RedoAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(RedoOperation.is({ kind: 'notTheRightOne' })).to.be.false; | ||
expect(RedoAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
@@ -70,7 +67,6 @@ }); | ||
it('should return an object conforming to the interface with matching properties for the given required arguments', () => { | ||
const expected: RedoOperation = { | ||
kind: 'glspRedo', | ||
isOperation: true | ||
const expected: RedoAction = { | ||
kind: 'glspRedo' | ||
}; | ||
expect(RedoOperation.create()).to.deep.equals(expected); | ||
expect(RedoAction.create()).to.deep.equals(expected); | ||
}); | ||
@@ -77,0 +73,0 @@ }); |
@@ -17,24 +17,23 @@ /******************************************************************************** | ||
import { Operation } from './base-protocol'; | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { Action } from './base-protocol'; | ||
/** | ||
* Trigger an undo of the latest executed command. | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `UndoOperations`. | ||
* and creating new `UndoAction`. | ||
*/ | ||
export interface UndoOperation extends Operation { | ||
kind: typeof UndoOperation.KIND; | ||
export interface UndoAction extends Omit<sprotty.UndoAction, 'kind'> { | ||
kind: typeof UndoAction.KIND; | ||
} | ||
export namespace UndoOperation { | ||
export namespace UndoAction { | ||
export const KIND = 'glspUndo'; | ||
export function is(object: any): object is UndoOperation { | ||
return Operation.hasKind(object, KIND); | ||
export function is(object: unknown): object is UndoAction { | ||
return Action.hasKind(object, KIND); | ||
} | ||
export function create(): UndoOperation { | ||
export function create(): UndoAction { | ||
return { | ||
kind: KIND, | ||
isOperation: true | ||
kind: KIND | ||
}; | ||
@@ -47,21 +46,20 @@ } | ||
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks | ||
* and creating new `RedoOperations`. | ||
* and creating new `RedoAction`. | ||
*/ | ||
export interface RedoOperation extends Operation { | ||
kind: typeof RedoOperation.KIND; | ||
export interface RedoAction extends Omit<sprotty.RedoAction, 'kind'> { | ||
kind: typeof RedoAction.KIND; | ||
} | ||
export namespace RedoOperation { | ||
export namespace RedoAction { | ||
export const KIND = 'glspRedo'; | ||
export function is(object: any): object is RedoOperation { | ||
return Operation.hasKind(object, KIND); | ||
export function is(object: unknown): object is RedoAction { | ||
return Action.hasKind(object, KIND); | ||
} | ||
export function create(): RedoOperation { | ||
export function create(): RedoAction { | ||
return { | ||
kind: KIND, | ||
isOperation: true | ||
kind: KIND | ||
}; | ||
} | ||
} |
@@ -50,3 +50,3 @@ /******************************************************************************** | ||
export function is(object: any): object is CenterAction { | ||
export function is(object: unknown): object is CenterAction { | ||
return Action.hasKind(object, KIND) && hasBooleanProp(object, 'animate') && hasBooleanProp(object, 'retainZoom'); | ||
@@ -98,3 +98,3 @@ } | ||
export function is(object: any): object is FitToScreenAction { | ||
export function is(object: unknown): object is FitToScreenAction { | ||
return Action.hasKind(object, KIND) && hasArrayProp(object, 'elementIds') && hasBooleanProp(object, 'animate'); | ||
@@ -101,0 +101,0 @@ } |
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource and others. | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
@@ -16,28 +16,3 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
import { SetBoundsAction, SetViewportAction } from 'sprotty-protocol/lib/actions'; | ||
import { Action } from './action-protocol'; | ||
import { hasBooleanProp, hasObjectProp, hasStringProp } from './utils/type-util'; | ||
// Add the is() function to the namespace declarations of sprotty-protocol actions | ||
declare module 'sprotty-protocol/lib/actions' { | ||
// eslint-disable-next-line no-shadow | ||
namespace SetViewportAction { | ||
export function is(object: any): object is SetViewportAction; | ||
} | ||
// eslint-disable-next-line no-shadow | ||
namespace SetBoundsAction { | ||
export function is(object: any): object is SetBoundsAction; | ||
} | ||
} | ||
SetViewportAction.is = (object: any): object is SetViewportAction => | ||
Action.hasKind(object, SetViewportAction.KIND) && | ||
hasStringProp(object, 'elementId') && | ||
hasObjectProp(object, 'newViewport') && | ||
hasBooleanProp(object, 'animate'); | ||
SetBoundsAction.is = (object: any): object is SetBoundsAction => | ||
Action.hasKind(object, SetBoundsAction.KIND) && hasObjectProp(object, 'bounds'); | ||
// Partial reexport of sprotty-protocol | ||
@@ -48,12 +23,21 @@ export { Viewport } from 'sprotty-protocol/lib/model'; | ||
export * from 'sprotty-protocol/lib/utils/json'; | ||
export * from 'sprotty-protocol/lib/utils/model-utils'; | ||
export { applyBounds, cloneModel, findElement, getBasicType, getSubType } from 'sprotty-protocol/lib/utils/model-utils'; | ||
// Default export of @eclipse-glsp/protocol | ||
export * from './action-protocol'; | ||
export * from './glsp-client'; | ||
export * from './jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './jsonrpc/glsp-jsonrpc-client'; | ||
export * from './client-server-protocol/base-glsp-client'; | ||
export * from './client-server-protocol/glsp-client'; | ||
export * from './client-server-protocol/glsp-server'; | ||
export * from './client-server-protocol/jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-server'; | ||
export * from './client-server-protocol/jsonrpc/websocket-connection'; | ||
export * from './client-server-protocol/jsonrpc/ws-connection-provider'; | ||
export * from './client-server-protocol/types'; | ||
export * from './model/default-types'; | ||
export * from './model/model-schema'; | ||
export * from './sprotty-actions'; | ||
export * from './utils/array-util'; | ||
export * from './utils/di-util'; | ||
export * from './utils/disposable'; | ||
export * from './utils/event'; | ||
export * from './utils/type-util'; | ||
export { SetBoundsAction, SetViewportAction }; |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -16,20 +16,47 @@ * This program and the accompanying materials are made available under the | ||
********************************************************************************/ | ||
/** | ||
* Reexport of the sprotty-protocol model definitions with a `Schema` suffix. We use a class based | ||
* model representation on client and server side. The `Schema` suffix is used for type that represent | ||
* the serializable description of these graphical model elements. | ||
* The basic types `SModelElementSchema` and `SRootElementSchema` are already exported by the base action protocol so | ||
* we only have to reexport the advanced model element interfaces from sprotty-protocol. | ||
import { | ||
SCompartment as GCompartmentSchema, | ||
SEdge as GEdgeSchema, | ||
ForeignObjectElement as GForeignObjectElementSchema, | ||
SGraph as GGraphSchema, | ||
HtmlRoot as GHtmlRootSchema, | ||
SLabel as GLabelSchema, | ||
SModelElement as GModelElementSchema, | ||
SModelRoot as GModelRootSchema, | ||
SNode as GNodeSchema, | ||
SPort as GPortSchema, | ||
PreRenderedElement as GPreRenderedElementSchema, | ||
SShapeElement as GShapeElementSchema, | ||
ShapedPreRenderedElement as GShapePreRenderedElementSchema, | ||
ViewportRootElement as GViewPortRootElementSchema | ||
} from 'sprotty-protocol/lib/model'; | ||
import { hasStringProp } from '../utils/type-util'; | ||
/** Serializable representation of GModel elements. This is the transfer format | ||
* used to exchange model information between client and server. Both the client and | ||
* server have a deserialization mechanism in place to convert a GModelElementSchema | ||
* into the corresponding class-based model (or EMF-based in case of the Java Server). | ||
* | ||
* To ensure sprotty compatibility all types are just aliases of the corresponding Sprotty SModel API element. | ||
*/ | ||
export function isGModelElementSchema(object: any): object is GModelElementSchema { | ||
return typeof object === 'object' && hasStringProp(object, 'type') && hasStringProp(object, 'id'); | ||
} | ||
export { | ||
HtmlRoot as HtmlRootSchema, | ||
PreRenderedElement as PreRenderedElementSchema, | ||
SCompartment as SCompartmentSchema, | ||
SEdge as SEdgeSchema, | ||
SGraph as SGraphSchema, | ||
ShapedPreRenderedElement as ShapedPreRenderedElementSchema, | ||
SLabel as SLabelSchema, | ||
SNode as SNodeSchema, | ||
SPort as SPortSchema, | ||
SShapeElement as SShapeElementSchema | ||
} from 'sprotty-protocol/lib/model'; | ||
GCompartmentSchema, | ||
GEdgeSchema, | ||
GForeignObjectElementSchema, | ||
GGraphSchema, | ||
GHtmlRootSchema, | ||
GLabelSchema, | ||
GModelElementSchema, | ||
GModelRootSchema, | ||
GNodeSchema, | ||
GPortSchema, | ||
GPreRenderedElementSchema, | ||
GShapeElementSchema, | ||
GShapePreRenderedElementSchema, | ||
GViewPortRootElementSchema | ||
}; |
/******************************************************************************** | ||
* Copyright (c) 2019-2022 EclipseSource and others. | ||
* Copyright (c) 2019-2023 EclipseSource and others. | ||
* | ||
@@ -102,2 +102,13 @@ * This program and the accompanying materials are made available under the | ||
/** | ||
* Helper function to convert a {@link MaybeArray} into an array. | ||
* @param maybe The MaybeArray to convert | ||
* @returns The corresponding array | ||
*/ | ||
export function asArray<T>(maybe: MaybeArray<T>): T[] { | ||
if (Array.isArray(maybe)) { | ||
return maybe; | ||
} | ||
return [maybe]; | ||
} | ||
/** | ||
* Adds the given values to the given array. The add operation is executed distinct meaning | ||
@@ -124,3 +135,3 @@ * a value will not be pushed to the array if its already present in the array. | ||
*/ | ||
export function isArrayOfType<T>(object: any, typeGuard: (elem: any) => elem is T, supportEmpty = false): object is T[] { | ||
export function isArrayOfType<T>(object: unknown, typeGuard: (elem: unknown) => elem is T, supportEmpty = false): object is T[] { | ||
return isArrayMatching(object, element => typeGuard(element), supportEmpty); | ||
@@ -137,3 +148,3 @@ } | ||
*/ | ||
export function isArrayOfClass<T>(object: any, constructor: Constructor<T>, supportEmpty = false): object is T[] { | ||
export function isArrayOfClass<T>(object: unknown, constructor: Constructor<T>, supportEmpty = false): object is T[] { | ||
return isArrayMatching(object, element => element instanceof constructor, supportEmpty); | ||
@@ -150,3 +161,3 @@ } | ||
*/ | ||
export function isArrayOfPrimitive<T>(object: any, primitiveType: Primitive, supportEmpty = false): object is T[] { | ||
export function isArrayOfPrimitive<T>(object: unknown, primitiveType: Primitive, supportEmpty = false): object is T[] { | ||
return isArrayMatching(object, element => typeof element === primitiveType, supportEmpty); | ||
@@ -162,3 +173,3 @@ } | ||
*/ | ||
export function isStringArray(object: any, supportEmpty = false): object is string[] { | ||
export function isStringArray(object: unknown, supportEmpty = false): object is string[] { | ||
return isArrayOfPrimitive(object, 'string', supportEmpty); | ||
@@ -174,4 +185,4 @@ } | ||
*/ | ||
export function isArrayMatching(object: any, predicate: (elem: any) => boolean, supportEmpty = false): boolean { | ||
export function isArrayMatching(object: unknown, predicate: (elem: unknown) => boolean, supportEmpty = false): boolean { | ||
return Array.isArray(object) && object.every(predicate) && (supportEmpty || object.length > 0); | ||
} |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -17,3 +17,3 @@ * This program and the accompanying materials are made available under the | ||
import { expect } from 'chai'; | ||
import { AnyObject, hasArrayProp, hasBooleanProp, hasNumberProp, hasObjectProp, hasStringProp } from './type-util'; | ||
import { AnyObject, hasArrayProp, hasBooleanProp, hasFunctionProp, hasNumberProp, hasObjectProp, hasStringProp } from './type-util'; | ||
@@ -36,3 +36,3 @@ describe('TypeUtil', () => { | ||
}); | ||
it('should return false for any object of primitive type', () => { | ||
it('should return false for unknown object of primitive type', () => { | ||
expect(AnyObject.is('')).to.be.false; | ||
@@ -59,5 +59,17 @@ expect(AnyObject.is(5)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
expect(hasStringProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
expect(hasStringProp({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
expect(hasStringProp({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasStringProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasStringProp({ someProp: 'someKey' }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -72,5 +84,17 @@ | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
expect(hasBooleanProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
expect(hasBooleanProp({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
expect(hasBooleanProp({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasBooleanProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasBooleanProp({ someProp: true }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -85,5 +109,17 @@ | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
expect(hasBooleanProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
expect(hasNumberProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
expect(hasNumberProp({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
expect(hasNumberProp({ someProp: '123' }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasNumberProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasNumberProp({ someProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -98,7 +134,45 @@ | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
expect(hasObjectProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
expect(hasObjectProp({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
expect(hasObjectProp({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasObjectProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasObjectProp({ someProp: { value: 'someKey' } }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
describe('hasFunctionProp', () => { | ||
it('should return true for an object that has a property that matches the given key and type', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
expect(hasFunctionProp({ someProp: () => {} }, 'someProp')).to.be.true; | ||
}); | ||
it('should return false for an object that has a property that matches the given but not the given type', () => { | ||
expect(hasFunctionProp({ someProp: '123' }, 'someProp')).to.be.false; | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
expect(hasFunctionProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
expect(hasFunctionProp({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
expect(hasFunctionProp({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasFunctionProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
expect(hasFunctionProp({ someProp: () => {} }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
describe('hasArrayProp', () => { | ||
@@ -111,6 +185,18 @@ it('should return true for an object that has a property that matches the given key and type', () => { | ||
}); | ||
it('should return false for an object that does not have a property that matches the given key.', () => { | ||
it('should return false for an object that does not have a property that matches the given key', () => { | ||
expect(hasArrayProp({ anotherProp: 123 }, 'someProp')).to.be.false; | ||
}); | ||
it('should return true for an object that does not have a matching key when using the optional flag', () => { | ||
expect(hasArrayProp({ anotherProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return false for an object that has a property with matching name but invalid type when using the optional flag', () => { | ||
expect(hasArrayProp({ someProp: 123 }, 'someProp', true)).to.be.false; | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasArrayProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasArrayProp({ someProp: ['some', 'prop'] }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
}); |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 EclipseSource and others. | ||
* Copyright (c) 2021-2023 EclipseSource and others. | ||
* | ||
@@ -17,8 +17,4 @@ * This program and the accompanying materials are made available under the | ||
/** | ||
* The built-in 'object' & 'Object' types are currently hard to use | ||
* an should be avoided. It's recommended to use Record instead to describe the | ||
* type meaning of "any object"; | ||
*/ | ||
export type AnyObject = Record<PropertyKey, unknown>; | ||
/** Helper type to describe any defined object*/ | ||
export type AnyObject = object; | ||
@@ -45,4 +41,4 @@ export namespace AnyObject { | ||
*/ | ||
export interface Constructor<T> { | ||
new (...args: any[]): T; | ||
export interface Constructor<T, A extends any[] = any[]> { | ||
new (...args: A): T; | ||
} | ||
@@ -53,3 +49,3 @@ | ||
* all readonly modifiers of the type`s properties. Please use with care and only in instances | ||
* where you know that overwriting a readonly property is safe and doesn't cause any unintended side effects. | ||
* where you know that overwriting a readonly property is safe and doesn't cause unknown unintended side effects. | ||
*/ | ||
@@ -60,5 +56,10 @@ // eslint-disable-next-line @typescript-eslint/ban-types | ||
/** | ||
* Utility type to describe a value as might be provided as a promise. | ||
*/ | ||
export type MaybePromise<T> = T | PromiseLike<T>; | ||
/** | ||
* Utility type to describe typeguard functions. | ||
*/ | ||
export type TypeGuard<T> = (element: any, ...args: any[]) => element is T; | ||
export type TypeGuard<T> = (element: any) => element is T; | ||
@@ -68,3 +69,3 @@ /** | ||
* Essentially this wraps an instance of check as typeguard function. | ||
* @param constructor The constructor fo the class for which the typeguard should be created. | ||
* @param constructor The constructor of the class for which the typeguard should be created. | ||
* @returns The typeguard for this class. | ||
@@ -77,49 +78,77 @@ */ | ||
/** | ||
* Validates whether the given object as a property of type `string` with the given key. | ||
* Utility type that represents an arbitrary function. Should be used instead | ||
* of the default `Function` type which is considered to be unsafe. | ||
*/ | ||
export type SafeFunction<T = any> = (...args: any[]) => T; | ||
/** | ||
* Validates whether the given object has a property of type `string` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `string`. | ||
*/ | ||
export function hasStringProp(object: AnyObject, propertyKey: string): boolean { | ||
return propertyKey in object && typeof object[propertyKey] === 'string'; | ||
export function hasStringProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'string' : optional; | ||
} | ||
/** | ||
* Validates whether the given object as a property of type `boolean` with the given key. | ||
* Validates whether the given object has a property of type `boolean` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `boolean`. | ||
*/ | ||
export function hasBooleanProp(object: AnyObject, propertyKey: string): boolean { | ||
return propertyKey in object && typeof object[propertyKey] === 'boolean'; | ||
export function hasBooleanProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'boolean' : optional; | ||
} | ||
/** | ||
* Validates whether the given object as a property of type `number` with the given key. | ||
* Validates whether the given object has a property of type `number` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `number`. | ||
*/ | ||
export function hasNumberProp(object: AnyObject, propertyKey: string): boolean { | ||
return propertyKey in object && typeof object[propertyKey] === 'number'; | ||
export function hasNumberProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'number' : optional; | ||
} | ||
/** | ||
* Validates whether the given object as a property of type `object` with the given key. | ||
* Validates whether the given object has a property of type `object` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `object`. | ||
*/ | ||
export function hasObjectProp(object: AnyObject, propertyKey: string): boolean { | ||
return propertyKey in object && AnyObject.is(object[propertyKey]); | ||
export function hasObjectProp<T extends string>(object: AnyObject, propertyKey: T, optional = false): boolean { | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? AnyObject.is(property) : optional; | ||
} | ||
/** | ||
* Validates whether the given object as a property of type `Array` with the given key. | ||
* Validates whether the given object has a property of type `function` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `function`. | ||
*/ | ||
export function hasFunctionProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'function' : optional; | ||
} | ||
/** | ||
* Validates whether the given object has a property of type `Array` with the given key. | ||
* @param object The object that should be validated | ||
* @param propertyKey The key of the property | ||
* @param optional Flag to indicate wether the property can be optional i.e. also return true if the given key is undefined | ||
* @returns `true` if the object has property with matching key of type `Array`. | ||
*/ | ||
export function hasArrayProp(object: AnyObject, propertyKey: string): boolean { | ||
return propertyKey in object && Array.isArray(object[propertyKey]); | ||
export function hasArrayProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? Array.isArray(property) : optional; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 14 instances in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 4 instances in 1 package
1243712
333
19074
14
4
23
+ Addedvscode-jsonrpc@^8.0.2
+ Added@inversifyjs/common@1.4.0(transitive)
+ Added@inversifyjs/core@1.3.5(transitive)
+ Added@inversifyjs/reflect-metadata-utils@0.2.4(transitive)
+ Addedinversify@6.2.2(transitive)
+ Addedreflect-metadata@0.2.2(transitive)
+ Addedsprotty-protocol@0.15.0-next.044bba2.13(transitive)
+ Addedvscode-jsonrpc@8.2.1(transitive)
- Removedvscode-ws-jsonrpc@0.2.0
- Removedsprotty-protocol@0.12.0(transitive)
- Removedvscode-jsonrpc@5.0.1(transitive)
- Removedvscode-ws-jsonrpc@0.2.0(transitive)