Skip to content

Commit 34a4fd5

Browse files
fix: address review — assertCapability* params as RequestMethod|string for discoverability (KKonstantinov)
1 parent 10a7878 commit 34a4fd5

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/client/src/client/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
NotificationMethod,
2525
ProtocolOptions,
2626
ReadResourceRequest,
27+
RequestMethod,
2728
RequestOptions,
2829
Result,
2930
ServerCapabilities,
@@ -569,7 +570,7 @@ export class Client extends Protocol<ClientContext> {
569570
return this._instructions;
570571
}
571572

572-
protected assertCapabilityForMethod(method: string): void {
573+
protected assertCapabilityForMethod(method: RequestMethod | string): void {
573574
switch (method as ClientRequest['method']) {
574575
case 'logging/setLevel': {
575576
if (!this._serverCapabilities?.logging) {
@@ -632,7 +633,7 @@ export class Client extends Protocol<ClientContext> {
632633
}
633634
}
634635

635-
protected assertNotificationCapability(method: string): void {
636+
protected assertNotificationCapability(method: NotificationMethod | string): void {
636637
switch (method as ClientNotification['method']) {
637638
case 'notifications/roots/list_changed': {
638639
if (!this._capabilities.roots?.listChanged) {

packages/core/src/shared/protocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,14 +765,14 @@ export abstract class Protocol<ContextT extends BaseContext> {
765765
*
766766
* This should be implemented by subclasses.
767767
*/
768-
protected abstract assertCapabilityForMethod(method: string): void;
768+
protected abstract assertCapabilityForMethod(method: RequestMethod | string): void;
769769

770770
/**
771771
* A method to check if a notification is supported by the local side, for the given method to be sent.
772772
*
773773
* This should be implemented by subclasses.
774774
*/
775-
protected abstract assertNotificationCapability(method: string): void;
775+
protected abstract assertNotificationCapability(method: NotificationMethod | string): void;
776776

777777
/**
778778
* A method to check if a request handler is supported by the local side, for the given method to be handled.

packages/server/src/server/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import type {
1919
LoggingLevel,
2020
LoggingMessageNotification,
2121
MessageExtraInfo,
22+
NotificationMethod,
2223
NotificationOptions,
2324
ProtocolOptions,
25+
RequestMethod,
2426
RequestOptions,
2527
ResourceUpdatedNotification,
2628
Result,
@@ -264,7 +266,7 @@ export class Server extends Protocol<ServerContext> {
264266
};
265267
}
266268

267-
protected assertCapabilityForMethod(method: string): void {
269+
protected assertCapabilityForMethod(method: RequestMethod | string): void {
268270
switch (method) {
269271
case 'sampling/createMessage': {
270272
if (!this._clientCapabilities?.sampling) {
@@ -297,7 +299,7 @@ export class Server extends Protocol<ServerContext> {
297299
}
298300
}
299301

300-
protected assertNotificationCapability(method: string): void {
302+
protected assertNotificationCapability(method: NotificationMethod | string): void {
301303
switch (method) {
302304
case 'notifications/message': {
303305
if (!this._capabilities.logging) {

0 commit comments

Comments
 (0)