@eclipse-glsp/protocol
Advanced tools
Comparing version 1.1.0-next.964b0af.221 to 1.1.0-next.97e90c6.246
@@ -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,2 +52,6 @@ * 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; | ||
} | ||
@@ -50,2 +63,3 @@ export declare namespace RequestMarkersAction { | ||
requestId?: string; | ||
reason?: string; | ||
}): RequestMarkersAction; | ||
@@ -66,2 +80,6 @@ } | ||
readonly markers: Marker[]; | ||
/** | ||
* The reason for message, such as `batch` or `live` validation. | ||
*/ | ||
reason?: string; | ||
} | ||
@@ -73,2 +91,3 @@ export declare namespace SetMarkersAction { | ||
responseId?: string; | ||
reason?: string; | ||
}): SetMarkersAction; | ||
@@ -75,0 +94,0 @@ } |
"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. | ||
* | ||
@@ -30,2 +30,12 @@ * This program and the accompanying materials are made available under the | ||
})(MarkerKind = exports.MarkerKind || (exports.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 || (exports.MarkersReason = {})); | ||
var RequestMarkersAction; | ||
@@ -39,3 +49,3 @@ (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); | ||
} | ||
@@ -52,3 +62,3 @@ RequestMarkersAction.create = create; | ||
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); | ||
} | ||
@@ -55,0 +65,0 @@ SetMarkersAction.create = create; |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -81,5 +81,5 @@ * This program and the accompanying materials are made available under the | ||
/** | ||
* 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[]; | ||
} | ||
@@ -89,4 +89,4 @@ export declare namespace LayoutOperation { | ||
function is(object: any): object is LayoutOperation; | ||
function create(elementIds: string[]): LayoutOperation; | ||
function create(elementIds?: string[]): LayoutOperation; | ||
} | ||
//# sourceMappingURL=model-layout.d.ts.map |
@@ -31,11 +31,17 @@ /******************************************************************************** | ||
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/types'; | ||
export * from './disposable/disposable'; | ||
export * from './model/default-types'; | ||
export * from './model/model-schema'; | ||
export * from './utils/array-util'; | ||
export * from './utils/disposable'; | ||
export * from './utils/di-util'; | ||
export * from './utils/type-util'; | ||
export { SetBoundsAction, SetViewportAction }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -49,10 +49,16 @@ "use strict"; | ||
__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/types"), exports); | ||
__exportStar(require("./disposable/disposable"), exports); | ||
__exportStar(require("./model/default-types"), exports); | ||
__exportStar(require("./model/model-schema"), exports); | ||
__exportStar(require("./utils/array-util"), exports); | ||
__exportStar(require("./utils/disposable"), exports); | ||
__exportStar(require("./utils/di-util"), exports); | ||
__exportStar(require("./utils/type-util"), exports); | ||
//# sourceMappingURL=index.js.map |
/******************************************************************************** | ||
* Copyright (c) 2019-2022 EclipseSource and others. | ||
* Copyright (c) 2019-2023 EclipseSource and others. | ||
* | ||
@@ -69,2 +69,8 @@ * 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 declare function asArray<T>(maybe: MaybeArray<T>): T[]; | ||
/** | ||
* Adds the given values to the given array. The add operation is executed distinct meaning | ||
@@ -71,0 +77,0 @@ * a value will not be pushed to the array if its already present in the array. |
"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. |
@@ -54,3 +54,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. | ||
@@ -60,43 +60,49 @@ */ | ||
/** | ||
* 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`. | ||
*/ | ||
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(object: AnyObject, propertyKey: string, optional?: boolean): boolean; | ||
/** | ||
* Validates whether the given object as a property of type `function` 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): boolean; | ||
export declare function hasFunctionProp(object: AnyObject, propertyKey: string, 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 `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 |
@@ -35,3 +35,3 @@ "use strict"; | ||
* 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. | ||
@@ -44,61 +44,67 @@ */ | ||
/** | ||
* 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 !!object && propertyKey in object && typeof object[propertyKey] === 'string'; | ||
function hasStringProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? typeof object[propertyKey] === '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) { | ||
return propertyKey in object ? typeof object[propertyKey] === '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) { | ||
return propertyKey in object ? typeof object[propertyKey] === '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) { | ||
return propertyKey in object ? AnyObject.is(object[propertyKey]) : optional; | ||
} | ||
exports.hasObjectProp = hasObjectProp; | ||
/** | ||
* Validates whether the given object as a property of type `function` 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) { | ||
return propertyKey in object && typeof object[propertyKey] === 'function'; | ||
function hasFunctionProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? typeof object[propertyKey] === 'function' : optional; | ||
} | ||
exports.hasFunctionProp = hasFunctionProp; | ||
/** | ||
* 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 `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) { | ||
return propertyKey in object ? Array.isArray(object[propertyKey]) : optional; | ||
} | ||
exports.hasArrayProp = hasArrayProp; | ||
//# sourceMappingURL=type-util.js.map |
{ | ||
"name": "@eclipse-glsp/protocol", | ||
"version": "1.1.0-next.964b0af.221+964b0af", | ||
"version": "1.1.0-next.97e90c6.246+97e90c6", | ||
"description": "The protocol definition for client-server communication in GLSP", | ||
@@ -51,3 +51,3 @@ "keywords": [ | ||
"uuid": "7.0.3", | ||
"vscode-ws-jsonrpc": "^2.0.1" | ||
"vscode-jsonrpc": "^8.0.2" | ||
}, | ||
@@ -57,6 +57,9 @@ "devDependencies": { | ||
}, | ||
"peerDependencies": { | ||
"inversify": "^5.1.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "964b0afec183bf5f0b7195f9020ea57b3d0c327f" | ||
"gitHead": "97e90c674e0112fabfe4259fbf5f1c944f40da67" | ||
} |
# 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. | ||
@@ -5,0 +6,0 @@ This project is built with `yarn` and is available from npm via [@eclipse-glsp/protocol](https://www.npmjs.com/package/@eclipse-glsp/protocol). |
/******************************************************************************** | ||
* 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) 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; | ||
} | ||
@@ -73,3 +88,3 @@ | ||
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 | ||
@@ -99,2 +115,7 @@ }; | ||
readonly markers: Marker[]; | ||
/** | ||
* The reason for message, such as `batch` or `live` validation. | ||
*/ | ||
reason?: string; | ||
} | ||
@@ -109,3 +130,3 @@ | ||
export function create(markers: Marker[], options: { responseId?: string } = {}): SetMarkersAction { | ||
export function create(markers: Marker[], options: { responseId?: string; reason?: string } = {}): SetMarkersAction { | ||
return { | ||
@@ -115,2 +136,3 @@ kind: KIND, | ||
markers, | ||
reason: MarkersReason.BATCH, | ||
...options | ||
@@ -117,0 +139,0 @@ }; |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -118,5 +118,5 @@ * This program and the accompanying materials are made available under the | ||
/** | ||
* 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[]; | ||
} | ||
@@ -131,3 +131,3 @@ | ||
export function create(elementIds: string[]): LayoutOperation { | ||
export function create(elementIds?: string[]): LayoutOperation { | ||
return { | ||
@@ -134,0 +134,0 @@ kind: KIND, |
/******************************************************************************** | ||
* 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', () => { |
@@ -50,10 +50,16 @@ /******************************************************************************** | ||
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/types'; | ||
export * from './disposable/disposable'; | ||
export * from './model/default-types'; | ||
export * from './model/model-schema'; | ||
export * from './utils/array-util'; | ||
export * from './utils/disposable'; | ||
export * from './utils/di-util'; | ||
export * from './utils/type-util'; | ||
export { SetBoundsAction, SetViewportAction }; |
/******************************************************************************** | ||
* 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 | ||
@@ -104,0 +115,0 @@ * a value will not be pushed to the array if its already present in the array. |
@@ -57,5 +57,11 @@ /******************************************************************************** | ||
}); | ||
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; | ||
}); | ||
}); | ||
@@ -70,5 +76,11 @@ | ||
}); | ||
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; | ||
}); | ||
}); | ||
@@ -83,5 +95,11 @@ | ||
}); | ||
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; | ||
}); | ||
}); | ||
@@ -96,5 +114,11 @@ | ||
}); | ||
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; | ||
}); | ||
}); | ||
@@ -110,5 +134,11 @@ | ||
}); | ||
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(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; | ||
}); | ||
}); | ||
@@ -123,6 +153,12 @@ | ||
}); | ||
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; | ||
}); | ||
}); | ||
}); |
@@ -64,3 +64,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. | ||
@@ -73,59 +73,65 @@ */ | ||
/** | ||
* 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`. | ||
*/ | ||
export function hasStringProp(object: AnyObject, propertyKey: string): boolean { | ||
return !!object && propertyKey in object && typeof (object as any)[propertyKey] === 'string'; | ||
export function hasStringProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === '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 as any)[propertyKey] === 'boolean'; | ||
export function hasBooleanProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === '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 as any)[propertyKey] === 'number'; | ||
export function hasNumberProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === '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 as any)[propertyKey]); | ||
export function hasObjectProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? AnyObject.is((object as any)[propertyKey]) : optional; | ||
} | ||
/** | ||
* Validates whether the given object as a property of type `function` 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): boolean { | ||
return propertyKey in object && typeof (object as any)[propertyKey] === 'function'; | ||
export function hasFunctionProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === 'function' : 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 `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 as any)[propertyKey]); | ||
export function hasArrayProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? Array.isArray((object as any)[propertyKey]) : 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance 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 14 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance 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 8 instances in 1 package
14
769059
4
218
22
13265
+ Addedvscode-jsonrpc@^8.0.2
+ Addedinversify@5.1.1(transitive)
+ Addedvscode-jsonrpc@8.2.1(transitive)
- Removedvscode-ws-jsonrpc@^2.0.1
- Removedvscode-jsonrpc@8.0.2(transitive)
- Removedvscode-ws-jsonrpc@2.0.2(transitive)