New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-glsp/protocol

Package Overview
Dependencies
Maintainers
5
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-glsp/protocol - npm Package Compare versions

Comparing version 0.10.0-next.c073915.168 to 0.10.0-next.c1d28ed.179

2

lib/action-protocol/element-navigation.d.ts

@@ -216,3 +216,3 @@ /********************************************************************************

/**
* If a {@link NavigationTarget} cannot be resolved or the resolved target is something that is not part of our model source, e.g.,
* If a {@link NavigationTarget} cannot be resolved or the resolved target is something that is not part of our source model, e.g.,
* a separate documentation file, a {@link NavigateToExternalTargetAction} may be sent. Since the target it outside of the model scope such

@@ -219,0 +219,0 @@ * an action would be typically handled by an integration layer (such as the surrounding IDE).

@@ -41,3 +41,3 @@ /********************************************************************************

/**
* Sent from the model source to the client in order to set the model. If a model is already present, it is replaced.
* Sent from the server to the client in order to set the model. If a model is already present, it is replaced.
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks

@@ -82,19 +82,19 @@ * and creating new `SetModelActions`.

/**
* Sent from the server to the client in order to indicate that the model source has changed.
* The model source denotes the data source from which the diagram has been originally derived (such as a file, a database, etc.).
* Sent from the server to the client in order to indicate that the source model has changed.
* The source model denotes the data source from which the diagram has been originally derived (such as a file, a database, etc.).
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks
* and creating new `ModelSourceChangedActions`.
* and creating new `SourceModelChangedActions`.
*/
export interface ModelSourceChangedAction extends Action {
kind: typeof ModelSourceChangedAction.KIND;
export interface SourceModelChangedAction extends Action {
kind: typeof SourceModelChangedAction.KIND;
/**
* A human readable name of the model source (e.g. the file name).
* A human readable name of the source model (e.g. the file name).
*/
modelSourceName: string;
sourceModelName: string;
}
export declare namespace ModelSourceChangedAction {
const KIND = "modelSourceChanged";
function is(object: any): object is ModelSourceChangedAction;
function create(modelSourceName: string): ModelSourceChangedAction;
export declare namespace SourceModelChangedAction {
const KIND = "sourceModelChanged";
function is(object: any): object is SourceModelChangedAction;
function create(sourceModelName: string): SourceModelChangedAction;
}
//# sourceMappingURL=model-data.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModelSourceChangedAction = exports.UpdateModelAction = exports.SetModelAction = exports.RequestModelAction = void 0;
exports.SourceModelChangedAction = exports.UpdateModelAction = exports.SetModelAction = exports.RequestModelAction = void 0;
const type_util_1 = require("../utils/type-util");

@@ -42,17 +42,17 @@ const base_protocol_1 = require("./base-protocol");

})(UpdateModelAction = exports.UpdateModelAction || (exports.UpdateModelAction = {}));
var ModelSourceChangedAction;
(function (ModelSourceChangedAction) {
ModelSourceChangedAction.KIND = 'modelSourceChanged';
var SourceModelChangedAction;
(function (SourceModelChangedAction) {
SourceModelChangedAction.KIND = 'sourceModelChanged';
function is(object) {
return base_protocol_1.Action.hasKind(object, ModelSourceChangedAction.KIND) && (0, type_util_1.hasStringProp)(object, 'modelSourceName');
return base_protocol_1.Action.hasKind(object, SourceModelChangedAction.KIND) && (0, type_util_1.hasStringProp)(object, 'sourceModelName');
}
ModelSourceChangedAction.is = is;
function create(modelSourceName) {
SourceModelChangedAction.is = is;
function create(sourceModelName) {
return {
kind: ModelSourceChangedAction.KIND,
modelSourceName
kind: SourceModelChangedAction.KIND,
sourceModelName: sourceModelName
};
}
ModelSourceChangedAction.create = create;
})(ModelSourceChangedAction = exports.ModelSourceChangedAction || (exports.ModelSourceChangedAction = {}));
SourceModelChangedAction.create = create;
})(SourceModelChangedAction = exports.SourceModelChangedAction || (exports.SourceModelChangedAction = {}));
//# sourceMappingURL=model-data.js.map

@@ -138,16 +138,16 @@ "use strict";

});
describe('ModelSourceChangedAction', () => {
describe('SourceModelChangedAction', () => {
describe('is', () => {
it('should return true for an object having the correct type and a value for all required interface properties', () => {
const action = {
kind: 'modelSourceChanged',
modelSourceName: ''
kind: 'sourceModelChanged',
sourceModelName: ''
};
(0, chai_1.expect)(model_data_1.ModelSourceChangedAction.is(action)).to.be.true;
(0, chai_1.expect)(model_data_1.SourceModelChangedAction.is(action)).to.be.true;
});
it('should return false for `undefined`', () => {
(0, chai_1.expect)(model_data_1.ModelSourceChangedAction.is(undefined)).to.be.false;
(0, chai_1.expect)(model_data_1.SourceModelChangedAction.is(undefined)).to.be.false;
});
it('should return false for an object that does not have all required interface properties', () => {
(0, chai_1.expect)(model_data_1.ModelSourceChangedAction.is({ kind: 'notTheRightOne' })).to.be.false;
(0, chai_1.expect)(model_data_1.SourceModelChangedAction.is({ kind: 'notTheRightOne' })).to.be.false;
});

@@ -158,7 +158,7 @@ });

const expected = {
kind: 'modelSourceChanged',
modelSourceName: 'myModelSource'
kind: 'sourceModelChanged',
sourceModelName: 'myModelSource'
};
const { modelSourceName } = expected;
(0, chai_1.expect)(model_data_1.ModelSourceChangedAction.create(modelSourceName)).to.deep.equals(expected);
const { sourceModelName: sourceModelName } = expected;
(0, chai_1.expect)(model_data_1.SourceModelChangedAction.create(sourceModelName)).to.deep.equals(expected);
});

@@ -165,0 +165,0 @@ });

import { Action, RequestAction, ResponseAction } from './base-protocol';
/**
* Sent from the client to the server in order to persist the current model state back to the model source.
* A new fileUri can be defined to save the model to a new destination different from its original model source.
* Sent from the client to the server in order to persist the current model state back to the source model.
* A new fileUri can be defined to save the model to a new destination different from its original source model.
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks

@@ -24,3 +24,3 @@ * and creating new `SaveModelActions`.

* The server sends this action to indicate to the client that the current model state on the server does not correspond
* to the persisted model state of the model source. A client may ignore such an action or use it to indicate to the user the dirty state.
* to the persisted model state of the source model. A client may ignore such an action or use it to indicate to the user the dirty state.
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks

@@ -27,0 +27,0 @@ * and creating new `SetDirtyStateActions`.

@@ -34,2 +34,3 @@ /********************************************************************************

const LABEL = "label";
const BUTTON = "button";
const BUTTON_EXPAND = "button:expand";

@@ -36,0 +37,0 @@ const ISSUE_MARKER = "marker";

@@ -43,2 +43,3 @@ "use strict";

// UI elements
DefaultTypes.BUTTON = 'button';
DefaultTypes.BUTTON_EXPAND = 'button:expand';

@@ -45,0 +46,0 @@ DefaultTypes.ISSUE_MARKER = 'marker';

@@ -16,2 +16,3 @@ /********************************************************************************

********************************************************************************/
import { Constructor, Primitive } from './type-util';
/**

@@ -26,11 +27,31 @@ * A union type for for objects that can either be a single element or and array of elements.

*/
export declare function first<T>(array: T[]): number;
export declare function first<T>(array: T[]): T;
/**
* Returns the first n elements of the given array.
* @param array the array.
* @param n the number of elements that should be returned
* @returns the first n elements of the array
* @param array The array.
* @param n The number of elements that should be returned
* @returns The first n elements of the array
*/
export declare function first<T>(array: T[], n: number): T[];
/**
* Returns the last element of the given array.
* @param array The array.
* @returns The last element in the array.
*/
export declare function last<T>(array: T[]): T;
/**
* Returns the last n elements of the given array.
* @param array The array.
* @param n The number of elements that should be returned
* @returns The last n elements of the array
*/
export declare function last<T>(array: T[], n: number): T[];
/**
* Plucks (i.e. extracts) the property value that corresponds to the given key from all objects of the array.
* @param array The array which should be plucked.
* @param key The key of the property that should be extracted.
* @returns A new array containing the plugged property for each element of the array.
*/
export declare function pluck<T, K extends keyof T>(array: T[], key: K): Array<T[K]>;
/**
* Removes the given values from the given array (if present).

@@ -56,6 +77,2 @@ * @param array The array to execute the remove operation on.

export declare function distinctAdd<T>(array: T[], ...values: T[]): void;
interface Constructor<T> {
new (...args: any[]): T;
}
declare type PrimitiveType = 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined';
/**

@@ -87,3 +104,3 @@ * A typeguard function to check wether a given object is an array of a specific type `T`. As it checks the type of each individual

*/
export declare function isArrayOfPrimitive<T>(object: any, primitiveType: PrimitiveType, supportEmpty?: boolean): object is T[];
export declare function isArrayOfPrimitive<T>(object: any, primitiveType: Primitive, supportEmpty?: boolean): object is T[];
/**

@@ -105,3 +122,2 @@ * 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 isArrayMatching(object: any, predicate: (elem: any) => boolean, supportEmpty?: boolean): boolean;
export {};
//# sourceMappingURL=array-util.d.ts.map
"use strict";
/********************************************************************************
* Copyright (c) 2019-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
********************************************************************************/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArrayMatching = exports.isStringArray = exports.isArrayOfPrimitive = exports.isArrayOfClass = exports.isArrayOfType = exports.distinctAdd = exports.flatPush = exports.remove = exports.first = void 0;
exports.isArrayMatching = exports.isStringArray = exports.isArrayOfPrimitive = exports.isArrayOfClass = exports.isArrayOfType = exports.distinctAdd = exports.flatPush = exports.remove = exports.pluck = exports.last = exports.first = void 0;
function first(array, n) {

@@ -11,3 +26,20 @@ if (n) {

exports.first = first;
function last(array, n) {
if (n) {
return array.filter((_, index) => array.length - index <= n);
}
return array[array.length - 1];
}
exports.last = last;
/**
* Plucks (i.e. extracts) the property value that corresponds to the given key from all objects of the array.
* @param array The array which should be plucked.
* @param key The key of the property that should be extracted.
* @returns A new array containing the plugged property for each element of the array.
*/
function pluck(array, key) {
return array.map(element => element[key]);
}
exports.pluck = pluck;
/**
* Removes the given values from the given array (if present).

@@ -14,0 +46,0 @@ * @param array The array to execute the remove operation on.

@@ -31,2 +31,20 @@ /********************************************************************************

/**
* Utility type to capture all primitive types.
*/
export declare 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;
}
/**
* Utility type to declare a given type `T` as writable. Essentially this removes
* 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.
*/
export declare type Writable<T> = {
-readonly [P in keyof T]: Writable<T[P]>;
};
/**
* Utility type to describe typeguard functions.

@@ -36,2 +54,9 @@ */

/**
* 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.
* @returns The typeguard for this class.
*/
export declare function toTypeGuard<G>(constructor: Constructor<G>): TypeGuard<G>;
/**
* Validates whether the given object as a property of type `string` with the given key.

@@ -38,0 +63,0 @@ * @param object The object that should be validated

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.hasArrayProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.AnyObject = void 0;
exports.hasArrayProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.toTypeGuard = exports.AnyObject = void 0;
var AnyObject;

@@ -34,2 +34,12 @@ (function (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.
* @returns The typeguard for this class.
*/
function toTypeGuard(constructor) {
return (element) => element instanceof constructor;
}
exports.toTypeGuard = toTypeGuard;
/**
* Validates whether the given object as a property of type `string` with the given key.

@@ -36,0 +46,0 @@ * @param object The object that should be validated

{
"name": "@eclipse-glsp/protocol",
"version": "0.10.0-next.c073915.168+c073915",
"version": "0.10.0-next.c1d28ed.179+c1d28ed",
"description": "The protocol definition for client-server communication in GLSP",

@@ -57,3 +57,3 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",

"types": "lib/index",
"gitHead": "c07391569ed6aae905581e61d0dda37c061b9e17"
"gitHead": "c1d28edbcd76cef9b52307167e2d4ed64119bda8"
}

@@ -327,3 +327,3 @@ /********************************************************************************

/**
* If a {@link NavigationTarget} cannot be resolved or the resolved target is something that is not part of our model source, e.g.,
* If a {@link NavigationTarget} cannot be resolved or the resolved target is something that is not part of our source model, e.g.,
* a separate documentation file, a {@link NavigateToExternalTargetAction} may be sent. Since the target it outside of the model scope such

@@ -330,0 +330,0 @@ * an action would be typically handled by an integration layer (such as the surrounding IDE).

@@ -18,3 +18,3 @@ /********************************************************************************

import { expect } from 'chai';
import { ModelSourceChangedAction, RequestModelAction, SetModelAction, UpdateModelAction } from './model-data';
import { RequestModelAction, SetModelAction, SourceModelChangedAction, UpdateModelAction } from './model-data';
/**

@@ -144,16 +144,16 @@ * Tests for the utility functions declared in the namespaces of the protocol

describe('ModelSourceChangedAction', () => {
describe('SourceModelChangedAction', () => {
describe('is', () => {
it('should return true for an object having the correct type and a value for all required interface properties', () => {
const action: ModelSourceChangedAction = {
kind: 'modelSourceChanged',
modelSourceName: ''
const action: SourceModelChangedAction = {
kind: 'sourceModelChanged',
sourceModelName: ''
};
expect(ModelSourceChangedAction.is(action)).to.be.true;
expect(SourceModelChangedAction.is(action)).to.be.true;
});
it('should return false for `undefined`', () => {
expect(ModelSourceChangedAction.is(undefined)).to.be.false;
expect(SourceModelChangedAction.is(undefined)).to.be.false;
});
it('should return false for an object that does not have all required interface properties', () => {
expect(ModelSourceChangedAction.is({ kind: 'notTheRightOne' })).to.be.false;
expect(SourceModelChangedAction.is({ kind: 'notTheRightOne' })).to.be.false;
});

@@ -164,8 +164,8 @@ });

it('should return an object conforming to the interface with matching properties for the given required arguments', () => {
const expected: ModelSourceChangedAction = {
kind: 'modelSourceChanged',
modelSourceName: 'myModelSource'
const expected: SourceModelChangedAction = {
kind: 'sourceModelChanged',
sourceModelName: 'myModelSource'
};
const { modelSourceName } = expected;
expect(ModelSourceChangedAction.create(modelSourceName)).to.deep.equals(expected);
const { sourceModelName: sourceModelName } = expected;
expect(SourceModelChangedAction.create(sourceModelName)).to.deep.equals(expected);
});

@@ -172,0 +172,0 @@ });

@@ -53,3 +53,3 @@ /********************************************************************************

/**
* Sent from the model source to the client in order to set the model. If a model is already present, it is replaced.
* Sent from the server to the client in order to set the model. If a model is already present, it is replaced.
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks

@@ -117,29 +117,29 @@ * and creating new `SetModelActions`.

/**
* Sent from the server to the client in order to indicate that the model source has changed.
* The model source denotes the data source from which the diagram has been originally derived (such as a file, a database, etc.).
* Sent from the server to the client in order to indicate that the source model has changed.
* The source model denotes the data source from which the diagram has been originally derived (such as a file, a database, etc.).
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks
* and creating new `ModelSourceChangedActions`.
* and creating new `SourceModelChangedActions`.
*/
export interface ModelSourceChangedAction extends Action {
kind: typeof ModelSourceChangedAction.KIND;
export interface SourceModelChangedAction extends Action {
kind: typeof SourceModelChangedAction.KIND;
/**
* A human readable name of the model source (e.g. the file name).
* A human readable name of the source model (e.g. the file name).
*/
modelSourceName: string;
sourceModelName: string;
}
export namespace ModelSourceChangedAction {
export const KIND = 'modelSourceChanged';
export namespace SourceModelChangedAction {
export const KIND = 'sourceModelChanged';
export function is(object: any): object is ModelSourceChangedAction {
return Action.hasKind(object, KIND) && hasStringProp(object, 'modelSourceName');
export function is(object: any): object is SourceModelChangedAction {
return Action.hasKind(object, KIND) && hasStringProp(object, 'sourceModelName');
}
export function create(modelSourceName: string): ModelSourceChangedAction {
export function create(sourceModelName: string): SourceModelChangedAction {
return {
kind: KIND,
modelSourceName
sourceModelName: sourceModelName
};
}
}

@@ -20,4 +20,4 @@ /********************************************************************************

/**
* Sent from the client to the server in order to persist the current model state back to the model source.
* A new fileUri can be defined to save the model to a new destination different from its original model source.
* Sent from the client to the server in order to persist the current model state back to the source model.
* A new fileUri can be defined to save the model to a new destination different from its original source model.
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks

@@ -51,3 +51,3 @@ * and creating new `SaveModelActions`.

* The server sends this action to indicate to the client that the current model state on the server does not correspond
* to the persisted model state of the model source. A client may ignore such an action or use it to indicate to the user the dirty state.
* to the persisted model state of the source model. A client may ignore such an action or use it to indicate to the user the dirty state.
* The corresponding namespace declares the action kind as constant and offers helper functions for type guard checks

@@ -54,0 +54,0 @@ * and creating new `SetDirtyStateActions`.

@@ -44,2 +44,3 @@ /********************************************************************************

// UI elements
export const BUTTON = 'button';
export const BUTTON_EXPAND = 'button:expand';

@@ -46,0 +47,0 @@ export const ISSUE_MARKER = 'marker';

@@ -16,2 +16,5 @@ /********************************************************************************

********************************************************************************/
import { Constructor, Primitive } from './type-util';
/**

@@ -27,8 +30,9 @@ * A union type for for objects that can either be a single element or and array of elements.

*/
export function first<T>(array: T[]): number;
export function first<T>(array: T[]): T;
/**
* Returns the first n elements of the given array.
* @param array the array.
* @param n the number of elements that should be returned
* @returns the first n elements of the array
* @param array The array.
* @param n The number of elements that should be returned
* @returns The first n elements of the array
*/

@@ -44,2 +48,33 @@ export function first<T>(array: T[], n: number): T[];

/**
* Returns the last element of the given array.
* @param array The array.
* @returns The last element in the array.
*/
export function last<T>(array: T[]): T;
/**
* Returns the last n elements of the given array.
* @param array The array.
* @param n The number of elements that should be returned
* @returns The last n elements of the array
*/
export function last<T>(array: T[], n: number): T[];
export function last<T>(array: T[], n?: number): T[] | T {
if (n) {
return array.filter((_, index) => array.length - index <= n);
}
return array[array.length - 1];
}
/**
* Plucks (i.e. extracts) the property value that corresponds to the given key from all objects of the array.
* @param array The array which should be plucked.
* @param key The key of the property that should be extracted.
* @returns A new array containing the plugged property for each element of the array.
*/
export function pluck<T, K extends keyof T>(array: T[], key: K): Array<T[K]> {
return array.map(element => element[key]);
}
/**
* Removes the given values from the given array (if present).

@@ -82,6 +117,2 @@ * @param array The array to execute the remove operation on.

}
interface Constructor<T> {
new (...args: any[]): T;
}
type PrimitiveType = 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined';

@@ -120,3 +151,3 @@ /**

*/
export function isArrayOfPrimitive<T>(object: any, primitiveType: PrimitiveType, supportEmpty = false): object is T[] {
export function isArrayOfPrimitive<T>(object: any, primitiveType: Primitive, supportEmpty = false): object is T[] {
return isArrayMatching(object, element => typeof element === primitiveType, supportEmpty);

@@ -123,0 +154,0 @@ }

@@ -37,2 +37,22 @@ /********************************************************************************

/**
* Utility type to capture all primitive types.
*/
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;
}
/**
* Utility type to declare a given type `T` as writable. Essentially this removes
* 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.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export type Writable<T> = { -readonly [P in keyof T]: Writable<T[P]> };
/**
* Utility type to describe typeguard functions.

@@ -43,2 +63,12 @@ */

/**
* 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.
* @returns The typeguard for this class.
*/
export function toTypeGuard<G>(constructor: Constructor<G>): TypeGuard<G> {
return (element: any): element is G => element instanceof constructor;
}
/**
* Validates whether the given object as a property of type `string` with the given key.

@@ -45,0 +75,0 @@ * @param object The object that should be validated

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc