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

@aws/language-server-runtimes

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws/language-server-runtimes - npm Package Compare versions

Comparing version 0.2.17 to 0.2.18

protocol/getConfigurationFromServer.d.ts

4

package.json
{
"name": "@aws/language-server-runtimes",
"version": "0.2.17",
"version": "0.2.18",
"description": "Runtimes to host Language Servers for AWS",

@@ -51,3 +51,3 @@ "files": [

"ts-sinon": "^2.0.2",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
},

@@ -54,0 +54,0 @@ "typesVersions": {

@@ -5,1 +5,2 @@ export * from './lsp';

export * from './telemetry';
export * from './getConfigurationFromServer';

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

__exportStar(require("./telemetry"), exports);
__exportStar(require("./getConfigurationFromServer"), exports);
//# sourceMappingURL=index.js.map

@@ -78,3 +78,11 @@ import { _EM } from 'vscode-jsonrpc';

chatOptions?: ChatOptions;
configurationProvider?: ConfigurationOptions;
};
}
/**
* Configuration options for AWS Runtimes
* Sent back to the client to signal available configuration values
*/
export interface ConfigurationOptions {
sections: string[];
}

@@ -38,2 +38,3 @@ # Language Server Runtimes

| ----------------------------------- | ------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| getConfigurationFromServer | `aws/getConfigurationFromServer` | `GetConfigurationFromServerParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) | `LSPAny` | Retrieves configuration from the server for a specified section |
| onInlineCompletionWithReferences | `aws/textDocument/inlineCompletionWithReferences` | `InlineCompletionWithReferencesParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) | `InlineCompletionListWithReferences` | Provides list of inline completion suggestions from the Server with references for each of its suggestion |

@@ -40,0 +41,0 @@ | onLogInlineCompletionSessionResults | `aws/logInlineCompletionSessionResults` | `LogInlineCompletionSessionResultsParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) | n/a | Logs the results from inline completion suggestions from the Server |

@@ -1,5 +0,6 @@

import { CancellationToken, ExecuteCommandParams, InitializeError, InitializeParams, InitializeResult, ResponseError } from '../../../protocol';
import { CancellationToken, DidChangeConfigurationParams, ExecuteCommandParams, GetConfigurationFromServerParams, InitializedParams, InitializeError, InitializeParams, InitializeResult, ResponseError } from '../../../protocol';
import { Connection } from 'vscode-languageserver/node';
import { LspServer } from './lspServer';
export declare class LspRouter {
private lspConnection;
private name;

@@ -12,2 +13,5 @@ private version?;

executeCommand: (params: ExecuteCommandParams, token: CancellationToken) => Promise<any | undefined | null>;
didChangeConfiguration: (params: DidChangeConfigurationParams) => void;
onInitialized: (params: InitializedParams) => void;
handleGetConfigurationFromServer: (params: GetConfigurationFromServerParams, token: CancellationToken) => Promise<any>;
}

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

constructor(lspConnection, name, version) {
this.lspConnection = lspConnection;
this.name = name;

@@ -54,4 +55,31 @@ this.version = version;

});
this.didChangeConfiguration = (params) => {
for (const s of this.servers) {
s.sendDidChangeConfigurationNotification(params);
}
};
this.onInitialized = (params) => {
var _a, _b;
const workspaceCapabilities = (_a = this.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace;
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) {
// Ask the client to notify the server on configuration changes
this.lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined);
}
for (const s of this.servers) {
s.sendInitializedNotification(params);
}
};
this.handleGetConfigurationFromServer = (params, token) => __awaiter(this, void 0, void 0, function* () {
for (const s of this.servers) {
const [executed, result] = yield s.tryGetServerConfiguration(params, token);
if (executed) {
return result;
}
}
});
lspConnection.onDidChangeConfiguration(this.didChangeConfiguration);
lspConnection.onExecuteCommand(this.executeCommand);
lspConnection.onInitialize(this.initialize);
lspConnection.onExecuteCommand(this.executeCommand);
lspConnection.onInitialized(this.onInitialized);
lspConnection.onRequest(protocol_1.getConfigurationFromServerRequestType, this.handleGetConfigurationFromServer);
}

@@ -58,0 +86,0 @@ }

@@ -24,6 +24,9 @@ "use strict";

onInitialize: (handler) => { },
onInitialized: (handler) => { },
onExecuteCommand: (handler) => { },
onRequest: (handler) => { },
onDidChangeConfiguration: (handler) => { },
};
let executeCommandHandler;
let initializeHandler;
let executeCommandHandler;
let lspRouter;

@@ -203,6 +206,108 @@ beforeEach(() => {

});
function newServer({ initializeHandler, executeCommandHandler, }) {
describe('onInitialized', () => {
it('should send InitializedNotification to all servers', () => {
const spy1 = sandbox.spy();
const spy2 = sandbox.spy();
const server1 = newServer({ initializedHandler: spy1 });
const server2 = newServer({ initializedHandler: spy2 });
lspRouter.servers = [server1, server2];
lspRouter.onInitialized({});
(0, assert_1.default)(spy1.calledOnce);
(0, assert_1.default)(spy2.calledOnce);
});
});
describe('didChangeConfiguration', () => {
it('should send DidChangeConfigurationNotification to all servers', () => {
const params = {
settings: {},
};
const spy1 = sandbox.spy();
const spy2 = sandbox.spy();
const server1 = newServer({ didChangeConfigurationHandler: spy1 });
const server2 = newServer({ didChangeConfigurationHandler: spy2 });
lspRouter.servers = [server1, server2];
lspRouter.didChangeConfiguration(params);
(0, assert_1.default)(spy1.calledWith(params));
(0, assert_1.default)(spy2.calledWith(params));
});
});
describe('handleGetConfigurationFromServer', () => {
it('should return the result from the first server that handles the request', () => __awaiter(void 0, void 0, void 0, function* () {
const initHandler1 = () => {
return {
awsServerCapabilities: {
configurationProvider: { sections: ['log'] },
},
};
};
const initHandler2 = () => {
return {
awsServerCapabilities: {
configurationProvider: { sections: ['log', 'test'] },
},
};
};
const initHandler3 = () => {
return {
awsServerCapabilities: {
configurationProvider: { sections: ['test'] },
},
};
};
const servers = [
newServer({ initializeHandler: initHandler1, getServerConfigurationHandler: () => 'server1' }),
newServer({ initializeHandler: initHandler2, getServerConfigurationHandler: () => 'server2' }),
newServer({ initializeHandler: initHandler3, getServerConfigurationHandler: () => 'server3' }),
];
for (const server of servers) {
lspRouter.servers.push(server);
yield server.initialize({}, {});
}
const params = { section: 'test' };
const result = yield lspRouter.handleGetConfigurationFromServer(params, {});
assert_1.default.strictEqual(result, 'server2');
}));
it('should return undefined if no server handles the request', () => __awaiter(void 0, void 0, void 0, function* () {
const initHandler1 = () => {
return {
awsServerCapabilities: {
configurationProvider: { sections: [] },
},
};
};
const initHandler2 = () => {
return {
awsServerCapabilities: {
configurationProvider: { sections: ['log', 'test'] },
},
};
};
const initHandler3 = () => {
return {
awsServerCapabilities: {
configurationProvider: { sections: ['test'] },
},
};
};
const servers = [
newServer({ initializeHandler: initHandler1, getServerConfigurationHandler: () => 'server1' }),
newServer({ initializeHandler: initHandler2, getServerConfigurationHandler: () => 'server2' }),
newServer({ initializeHandler: initHandler3, getServerConfigurationHandler: () => 'server3' }),
];
for (const server of servers) {
lspRouter.servers.push(server);
yield server.initialize({}, {});
}
const params = { section: 'something' };
const result = yield lspRouter.handleGetConfigurationFromServer(params, {});
assert_1.default.strictEqual(result, undefined);
}));
});
function newServer({ didChangeConfigurationHandler, executeCommandHandler, getServerConfigurationHandler, initializeHandler, initializedHandler, }) {
const server = new lspServer_1.LspServer();
server.setDidChangeConfigurationHandler(didChangeConfigurationHandler);
server.setExecuteCommandHandler(executeCommandHandler);
server.setServerConfigurationHandler(getServerConfigurationHandler);
server.setInitializeHandler(initializeHandler);
server.setExecuteCommandHandler(executeCommandHandler);
server.setInitializedHandler(initializedHandler);
return server;

@@ -209,0 +314,0 @@ }

@@ -1,11 +0,21 @@

import { CancellationToken, ExecuteCommandParams, InitializeError, RequestHandler, ResponseError } from '../../../protocol';
import { CancellationToken, DidChangeConfigurationParams, ExecuteCommandParams, GetConfigurationFromServerParams, InitializedParams, InitializeError, NotificationHandler, RequestHandler, ResponseError } from '../../../protocol';
import { InitializeParams, PartialInitializeResult } from '../../../server-interface/lsp';
export declare class LspServer {
private didChangeConfigurationHandler?;
private executeCommandHandler?;
private getServerConfigurationHandler?;
private initializeHandler?;
private executeCommandHandler?;
private initializedHandler?;
private serverCapabilities?;
private awsServerCapabilities?;
setInitializedHandler: (handler: NotificationHandler<InitializedParams>) => void;
setDidChangeConfigurationHandler: (handler: NotificationHandler<DidChangeConfigurationParams>) => void;
setInitializeHandler: (handler: RequestHandler<InitializeParams, PartialInitializeResult, InitializeError>) => void;
setExecuteCommandHandler: (handler: RequestHandler<ExecuteCommandParams, any | undefined | null, void>) => void;
setServerConfigurationHandler: (handler: RequestHandler<GetConfigurationFromServerParams, any, void>) => void;
initialize: (params: InitializeParams, token: CancellationToken) => Promise<PartialInitializeResult | ResponseError<InitializeError> | undefined>;
tryExecuteCommand: (params: ExecuteCommandParams, token: CancellationToken) => Promise<[boolean, any | undefined | null]>;
tryGetServerConfiguration: (params: GetConfigurationFromServerParams, token: CancellationToken) => Promise<[boolean, any | undefined | null]>;
sendDidChangeConfigurationNotification: (params: DidChangeConfigurationParams) => void;
sendInitializedNotification: (params: InitializedParams) => void;
}

@@ -17,2 +17,8 @@ "use strict";

constructor() {
this.setInitializedHandler = (handler) => {
this.initializedHandler = handler;
};
this.setDidChangeConfigurationHandler = (handler) => {
this.didChangeConfigurationHandler = handler;
};
this.setInitializeHandler = (handler) => {

@@ -24,2 +30,5 @@ this.initializeHandler = handler;

};
this.setServerConfigurationHandler = (handler) => {
this.getServerConfigurationHandler = handler;
};
this.initialize = (params, token) => __awaiter(this, void 0, void 0, function* () {

@@ -32,2 +41,3 @@ if (!this.initializeHandler) {

this.serverCapabilities = initializeResult.capabilities;
this.awsServerCapabilities = initializeResult.awsServerCapabilities;
}

@@ -45,2 +55,21 @@ return initializeResult;

});
this.tryGetServerConfiguration = (params, token) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
if (((_b = (_a = this.awsServerCapabilities) === null || _a === void 0 ? void 0 : _a.configurationProvider) === null || _b === void 0 ? void 0 : _b.sections.some(c => c === params.section)) &&
this.getServerConfigurationHandler) {
const result = yield (0, util_1.asPromise)(this.getServerConfigurationHandler(params, token));
return [true, result];
}
return [false, undefined];
});
this.sendDidChangeConfigurationNotification = (params) => {
if (this.didChangeConfigurationHandler) {
this.didChangeConfigurationHandler(params);
}
};
this.sendInitializedNotification = (params) => {
if (this.initializedHandler) {
this.initializedHandler(params);
}
};
}

@@ -47,0 +76,0 @@ }

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

getTextDocument: (uri) => __awaiter(this, void 0, void 0, function* () { return documents.get(uri); }),
getAllTextDocuments: () => __awaiter(this, void 0, void 0, function* () { return documents.all(); }),
// Get all workspace folders and return the workspace folder that contains the uri

@@ -188,14 +189,6 @@ getWorkspaceFolder: uri => {

addInitializer: lspServer.setInitializeHandler,
onInitialized: handler => lspConnection.onInitialized(p => {
var _a, _b;
const workspaceCapabilities = (_a = lspRouter.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace;
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) {
// Ask the client to notify the server on configuration changes
lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined);
}
handler(p);
}),
onInitialized: lspServer.setInitializedHandler,
onCompletion: handler => lspConnection.onCompletion(handler),
onInlineCompletion: handler => lspConnection.onRequest(protocol_1.inlineCompletionRequestType, handler),
didChangeConfiguration: handler => lspConnection.onDidChangeConfiguration(handler),
didChangeConfiguration: lspServer.setDidChangeConfigurationHandler,
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler),

@@ -227,2 +220,3 @@ onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler),

extensions: {
onGetConfigurationFromServer: lspServer.setServerConfigurationHandler,
onInlineCompletionWithReferences: handler => lspConnection.onRequest(protocol_1.inlineCompletionWithReferencesRequestType, handler),

@@ -229,0 +223,0 @@ onLogInlineCompletionSessionResults: handler => {

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

getTextDocument: (uri) => __awaiter(void 0, void 0, void 0, function* () { return documents.get(uri); }),
getAllTextDocuments: () => __awaiter(void 0, void 0, void 0, function* () { return documents.all(); }),
getWorkspaceFolder: _uri => lspRouter.clientInitializeParams.workspaceFolders && lspRouter.clientInitializeParams.workspaceFolders[0],

@@ -86,14 +87,6 @@ fs: {

addInitializer: lspServer.setInitializeHandler,
onInitialized: handler => lspConnection.onInitialized(p => {
var _a, _b;
const workspaceCapabilities = (_a = lspRouter.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.capabilities.workspace;
if ((_b = workspaceCapabilities === null || workspaceCapabilities === void 0 ? void 0 : workspaceCapabilities.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) {
// Ask the client to notify the server on configuration changes
lspConnection.client.register(protocol_1.DidChangeConfigurationNotification.type, undefined);
}
handler(p);
}),
onInitialized: lspServer.setInitializedHandler,
onCompletion: handler => lspConnection.onCompletion(handler),
onInlineCompletion: handler => lspConnection.onRequest(protocol_1.inlineCompletionRequestType, handler),
didChangeConfiguration: handler => lspConnection.onDidChangeConfiguration(handler),
didChangeConfiguration: lspServer.setDidChangeConfigurationHandler,
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler),

@@ -121,2 +114,3 @@ onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler),

extensions: {
onGetConfigurationFromServer: lspServer.setServerConfigurationHandler,
onInlineCompletionWithReferences: handler => lspConnection.onRequest(protocol_1.inlineCompletionWithReferencesRequestType, handler),

@@ -123,0 +117,0 @@ onLogInlineCompletionSessionResults: handler => {

@@ -1,3 +0,4 @@

import { CompletionItem, CompletionList, CompletionParams, DidChangeConfigurationParams, DidChangeTextDocumentParams, DidChangeWorkspaceFoldersParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, DocumentFormattingParams, ExecuteCommandParams, Hover, HoverParams, InitializeError, InitializeParams, InitializedParams, InlineCompletionItem, InlineCompletionItemWithReferences, InlineCompletionList, InlineCompletionListWithReferences, InlineCompletionParams, LogInlineCompletionSessionResultsParams, NotificationHandler, ProgressToken, ProgressType, PublishDiagnosticsParams, ChatOptions, RequestHandler, ServerCapabilities, TextEdit, SemanticTokensParams, SemanticTokens, SignatureHelp, SignatureHelpParams, ShowMessageParams, ShowMessageRequestParams, MessageActionItem, ShowDocumentParams, ShowDocumentResult } from '../protocol';
import { CompletionItem, CompletionList, CompletionParams, ConfigurationOptions, DidChangeConfigurationParams, DidChangeTextDocumentParams, DidChangeWorkspaceFoldersParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, DocumentFormattingParams, ExecuteCommandParams, GetConfigurationFromServerParams, Hover, HoverParams, InitializeError, InitializeParams, InitializedParams, InlineCompletionItem, InlineCompletionItemWithReferences, InlineCompletionList, InlineCompletionListWithReferences, InlineCompletionParams, LogInlineCompletionSessionResultsParams, NotificationHandler, ProgressToken, ProgressType, PublishDiagnosticsParams, ChatOptions, RequestHandler, ServerCapabilities, TextEdit, SemanticTokensParams, SemanticTokens, SignatureHelp, SignatureHelpParams, ShowMessageParams, ShowMessageRequestParams, MessageActionItem, ShowDocumentParams, ShowDocumentResult, LSPAny } from '../protocol';
export * from '../protocol/lsp';
export { GetConfigurationFromServerParams } from '../protocol';
export type PartialServerCapabilities<T = any> = Pick<ServerCapabilities<T>, 'completionProvider' | 'hoverProvider' | 'executeCommandProvider' | 'semanticTokensProvider' | 'signatureHelpProvider'>;

@@ -8,2 +9,3 @@ export type PartialInitializeResult<T = any> = {

chatOptions?: ChatOptions;
configurationProvider?: ConfigurationOptions;
};

@@ -46,3 +48,4 @@ };

onLogInlineCompletionSessionResults: (handler: NotificationHandler<LogInlineCompletionSessionResultsParams>) => void;
onGetConfigurationFromServer: (handler: RequestHandler<GetConfigurationFromServerParams, LSPAny, void>) => void;
};
};

@@ -16,2 +16,3 @@ import { TextDocument, WorkspaceFolder } from '../protocol';

getTextDocument: (uri: string) => Promise<TextDocument | undefined>;
getAllTextDocuments: () => Promise<TextDocument[]>;
getWorkspaceFolder: (uri: string) => WorkspaceFolder | null | undefined;

@@ -18,0 +19,0 @@ fs: {

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

this.workspace.getTextDocument.callsFake((uri) => __awaiter(this, void 0, void 0, function* () { return this.documents[uri]; }));
this.workspace.getAllTextDocuments.callsFake(() => __awaiter(this, void 0, void 0, function* () { return Object.values(this.documents); }));
}

@@ -41,0 +42,0 @@ start(server) {

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