Check and add tests for notification capabilities too
This commit is contained in:
parent
dc45f5d148
commit
64c2862883
1 changed files with 214 additions and 12 deletions
|
|
@ -28,6 +28,8 @@ export type ProtocolOptions = {
|
|||
/**
|
||||
* Whether to restrict emitted requests to only those that the remote side has indicated that they can handle, through their advertised capabilities.
|
||||
*
|
||||
* Note that this DOES NOT affect checking of _local_ side capabilities, as it is considered a logic error to mis-specify those.
|
||||
*
|
||||
* Currently this defaults to false, for backwards compatibility with SDK versions that did not advertise capabilities correctly. In future, this will default to true.
|
||||
*/
|
||||
enforceStrictCapabilities?: boolean;
|
||||
|
|
@ -266,6 +268,15 @@ export abstract class Protocol<
|
|||
method: SendRequestT["method"],
|
||||
): void;
|
||||
|
||||
/**
|
||||
* A method to check if a notification is supported by the local side, for the given method to be sent.
|
||||
*
|
||||
* This should be implemented by subclasses.
|
||||
*/
|
||||
protected abstract assertNotificationCapability(
|
||||
method: SendNotificationT["method"],
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Sends a request and wait for a response, with optional progress notifications in the meantime (if supported by the server).
|
||||
*
|
||||
|
|
@ -326,6 +337,8 @@ export abstract class Protocol<
|
|||
throw new Error("Not connected");
|
||||
}
|
||||
|
||||
this.assertNotificationCapability(notification.method);
|
||||
|
||||
const jsonrpcNotification: JSONRPCNotification = {
|
||||
...notification,
|
||||
jsonrpc: "2.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue